SomberNight
53a8453e3b
trampoline: fix off-by-one confusion of fees
...
The convention is that edges (start_node -> edge_node) store
the policy/fees for the *start_node*.
This is what the non-trampoline edges were already using (for a long time),
but the trampoline ones were off-by-one (policy was for end_node),
which was then worked around in multiple places, to correct for...
i.e. I think because of all the workarounds, there was no actual bug,
but it was just very confusing.
Also note that the prior usage of trampoline edges would not work if
we (sender) were not directly connected to a TF (trampoline-forwarder)
but had extra edges in the route to even get to the first TF.
Having the policy corresponding to the start_node of the edge would work
even in that case.
2023-10-27 14:24:19 +00:00
SomberNight
22a8348303
renames: use consistent naming of cltv delta vs cltv abs
...
to avoid confusing relative vs absolute cltvs
(see b0401a6386 )
2023-10-19 16:40:05 +00:00
ThomasV
4c42840c1c
lnpeer: obfuscate error pakets of forwarded htlcs, that we
...
propageate back to the sender.
lnworker: in htlc_fulfilled and htlc_failed, return early if the
htlc was forwarded, so that we do not trigger invoice callbacks
2023-10-19 15:59:26 +02:00
ThomasV
250884489e
Revert "lnonion: fix decode_onion_error"
...
This reverts commit 08132d6b7d .
2023-10-19 13:12:15 +02:00
ThomasV
08132d6b7d
lnonion: fix decode_onion_error
...
error_packet was side-effected by the loop. as a result, decoding
worked only for routes of length 1
2023-10-19 12:58:14 +02:00
SomberNight
a059a9a256
lnpeer.pay: also log hops_data for trampoline_onion
...
We were already logging the outer-layer hops_data,
now we also log the inner trampoline-onion hops_data.
Example:
```
1.12 | I | P/lnpeer.Peer.[MockLNWallet, alice->bob] | lnpeer.pay len(route)=1
1.12 | I | P/lnpeer.Peer.[MockLNWallet, alice->bob] | 0: edge=9926297x9781928x61754 hop_data=<OnionHopsDataSingle. payload={'amt_to_forward': {'amt_to_forward': 100000000}, 'outgoing_cltv_value': {'outgoing_cltv_value': 601299}, 'payment_data': {'payment_secret': b'\xd2\x9cl\xdfV\xd4\xea_\x06{\xed\xc9\xc7\xa6\xf5\xc0\n\x1a\x95\xad\xad\xd2F\xb8;&\x9f\xa1\xe1\xd1\x07H', 'total_msat': 100000000, 'amount_msat': 100000000}}. hmac=None>
1.12 | I | P/lnpeer.Peer.[MockLNWallet, alice->bob] | adding trampoline onion to final payload
1.12 | I | P/lnpeer.Peer.[MockLNWallet, alice->bob] | lnpeer.pay len(t_route)=3
1.12 | I | P/lnpeer.Peer.[MockLNWallet, alice->bob] | 0: t_node=02389c93b85ef8f7264c6fa3d3b239341c2631c2cab97e815b33453bd8d0254e77 hop_data=<OnionHopsDataSingle. payload={'amt_to_forward': {'amt_to_forward': 100000000}, 'outgoing_cltv_value': {'outgoing_cltv_value': 600723}, 'outgoing_node_id': {'outgoing_node_id': b'\x03\x06\xd9,\x9c\xabRe\x83Mr\x0b\x14(\xf5\x81\xf9\xfb\x9b\xfeV\xc1q\x85&L\xda\xffs\xe5y(\x81'}}. hmac=b'\xe7\x04\xe2>\x9a\xd9\xf0\x92<\xf8Q\xe4\xf4\xd8\x8cr{\x1e\xb1\xee\xb0\xd4R\xba\xe5\xfd\x83\xfc\xd7\xa7\x1dt'>
1.12 | I | P/lnpeer.Peer.[MockLNWallet, alice->bob] | 1: t_node=0306d92c9cab5265834d720b1428f581f9fb9bfe56c17185264cdaff73e5792881 hop_data=<OnionHopsDataSingle. payload={'amt_to_forward': {'amt_to_forward': 100000000}, 'outgoing_cltv_value': {'outgoing_cltv_value': 600147}, 'outgoing_node_id': {'outgoing_node_id': b'\x03\x85v\xac:\xf8AUW\xcf\x1d\x12e\xcc\xff\xb1\xea\xd6\x01\xd5\x17HX?\x12\x83\x9cD\xbe\xebC\x82o'}}. hmac=b's-\xe1\xdb\xbc\xa5\x88\x90\xc0\xafu\xab\xba\xb6k\x81\xeae)#\x85\x12fm\xe6\xc3\xbd\xf6\x86eR\xd2'>
1.12 | I | P/lnpeer.Peer.[MockLNWallet, alice->bob] | 2: t_node=038576ac3af8415557cf1d1265ccffb1ead601d51748583f12839c44beeb43826f hop_data=<OnionHopsDataSingle. payload={'amt_to_forward': {'amt_to_forward': 100000000}, 'outgoing_cltv_value': {'outgoing_cltv_value': 600147}, 'payment_data': {'payment_secret': b'B-P\x01\xc3\x1e#\x19\xf9!\xbb\xd8\xd1pu\xc7J\x11A\xa8J\xfe\xb8\x8a\xb8\xc4Oi\x0f\xe8\xac\xab', 'total_msat': 100000000}}. hmac=b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'>
1.12 | I | P/lnpeer.Peer.[MockLNWallet, alice->bob] | starting payment. len(route)=1.
```
2023-10-18 18:07:21 +00:00
SomberNight
98ccad68c1
channel_db: add TTLs to channel_updates_for_private_channels
...
eclair sends CHANNEL_DISABLED if its peer is offline. E.g. we might be
trying to pay a mobile phone with the app closed. In that case we
should not cache the CHANNEL_DISABLED for too long.
2023-08-15 16:34:51 +00:00
SomberNight
6b43eac6fd
lnonion: rm support for legacy (pre-TLV) onions
...
see https://github.com/lightning/bolts/pull/962
2023-06-29 14:34:06 +00:00
SomberNight
fc6486ecdb
lnaddr: make payment_secret field mandatory, in both directions
...
we now require payment_secret both for sending and for receiving
(previously was optional for both)
see
https://github.com/lightning/bolts/pull/898
https://github.com/ACINQ/eclair/pull/1810
https://github.com/ElementsProject/lightning/pull/4646
note: payment_secret depends on var_onion_optin, so that becomes mandatory as well,
however this commit does not yet remove the ability of creating legacy onions
2023-06-29 14:34:02 +00:00
SomberNight
373db76ac9
util: kill bh2u
...
no longer useful, and the name is so confusing...
2023-02-17 11:43:11 +00:00
ThomasV
c109d5e722
lnwire: update csv files with recent BOLTs
...
Note: there are no more optional fields in msgdata, per f068dd0d8d
2023-01-13 12:50:48 +01:00
SomberNight
1b6706bed6
replace some erroneous usages of IntFlag with IntEnum
2022-06-29 18:07:03 +02:00
Benoit Verret
f731c38293
Minor style changes
2021-03-21 00:36:23 -04:00
SomberNight
65e16fabd2
follow-up d8352f1a0a
...
message-induced exceptions should not propagate out
2021-03-19 21:21:09 +01:00
SomberNight
d8352f1a0a
lnworker: nicer logs/error msgs for payment failure
...
try to decode onion error and log it in human-readable form
2021-03-19 19:13:50 +01:00
ThomasV
51f3c613a5
(minor) fix typos and indentation
2021-03-03 10:03:29 +01:00
SomberNight
691ebaf4f8
lnworker/lnpeer: add some type hints, force some kwargs
2021-02-24 20:03:12 +01:00
ThomasV
152894e6a9
calc_hops_data: total_msat should be optional
2021-02-24 16:14:19 +01:00
bitromortac
9f84fa9580
lnonion: add total_msat to onion payment data
2021-02-22 11:25:00 +01:00
ThomasV
cf818fe08c
Trampoline routing:
...
- add support for trampoline forwarding
- add regtest with trampoline payment
2021-02-17 17:28:56 +01:00
ThomasV
ded449233e
Trampoline routing.
...
- trampoline is enabled by default in config, to prevent download of `gossip_db`.
(if disabled, `gossip_db` will be downloaded, regardless of the existence of channels)
- if trampoline is enabled:
- the wallet can only open channels with trampoline nodes
- already-existing channels with non-trampoline nodes are frozen for sending.
- there are two types of trampoline payments: legacy and end-to-end (e2e).
- we decide to perform legacy or e2e based on the invoice:
- we use trampoline_routing_opt in features to detect Eclair and Phoenix invoices
- we use trampoline_routing_hints to detect Electrum invoices
- when trying a legacy payment, we add a second trampoline to the path to preserve privacy.
(we fall back to a single trampoline if the payment fails for all trampolines)
- the trampoline list is hardcoded, it will remain so until `trampoline_routing_opt` feature flag is in INIT.
- there are currently only two nodes in the hardcoded list, it would be nice to have more.
- similar to Phoenix, we find the fee/cltv by trial-and-error.
- if there is a second trampoline in the path, we use the same fee for both.
- the final spec should add fee info in error messages, so we will be able to fine-tune fees
2021-02-17 17:28:13 +01:00
ThomasV
87a080d30e
split code in htlc_switch:
...
- raise OnionRoutingFailure whenever we want to fail a htlc
- catch that exception in htlc_switch
- this will avoid code duplication in the case of trampoline
2021-02-11 06:19:17 +01:00
ThomasV
ef5a265449
basic_mpp: receive multi-part payments
2021-02-04 16:31:17 +01:00
SomberNight
89ddc1345d
lnutil.PaymentAttemptLog: fix error formatting
...
fixes #6249
2020-06-22 03:40:04 +02:00
ThomasV
c1b1638615
fix htlc forwarding:
...
- persist fail_htlc error messages
- do not rely on payment_hash in htlc_switch
2020-05-05 09:23:48 +02:00
SomberNight
1be0a710c3
ln: implement option payment_secret
2020-04-01 21:49:12 +02:00
SomberNight
d424487814
lnpeer: better error handling when processing onion packets
2020-04-01 21:47:45 +02:00
SomberNight
30bf32b34b
use option varonion: actually use TLV payloads, and signal support
2020-04-01 21:47:42 +02:00
SomberNight
4b78bf94d4
lnaddr: add feature bit support to invoices
...
see https://github.com/lightningnetwork/lightning-rfc/pull/656
2020-04-01 21:42:52 +02:00
SomberNight
a66437f399
lnonion: implement basis of varonion support
2020-04-01 21:42:48 +02:00
SomberNight
b524460fdf
lnpeer: implement basic handling of "update_fail_malformed_htlc"
2020-03-17 20:31:50 +01:00
SomberNight
5e59d1a0ed
lnonion: use random starting bytes in Sphinx packet as in updated BOLT4
...
see https://github.com/lightningnetwork/lightning-rfc/pull/697
2020-03-16 04:37:52 +01:00
SomberNight
18f3a37032
crypto: move LN-related chacha20/poly1305 code into crypto.py
2020-03-04 17:58:43 +01:00
SomberNight
a32af44ff9
trivial clean-up (typing/imports)
2020-02-28 20:27:35 +01:00
SomberNight
b99add59c3
lnworker: introduce PaymentAttemptLog NamedTuple
2019-12-10 03:17:57 +01:00
SomberNight
2a604b1676
lnonion: get_failure_msg_from_onion_error might raise in python 3.7
...
this used to work in py3.6 but raises in py3.7 :(
(see https://bugs.python.org/issue34536 )
2019-10-12 00:05:38 +02:00
SomberNight
509df9ddaf
create class for ShortChannelID and use it
2019-09-06 18:09:05 +02:00
SomberNight
d2d4d19fcb
lnpeer: add a few sanity checks to payment-forwarding (and related)
2019-08-20 09:03:12 +02:00
ThomasV
d493dd1953
add pycryptodomex to requirements
2019-08-20 09:03:11 +02:00
SomberNight
9256472485
rm 'cryptography' as dependency; use new pycryptodomex version
...
pycryptodomex 3.7 implemented chacha20_poly1305 and chacha20,
and it is already used (although optionally) to speed up AES,
so we can remove cryptography and make pycryptodomex mandatory for LN
2019-08-20 09:03:11 +02:00
SomberNight
f70e679aba
some more type annotations that needed conditional imports
2019-08-20 09:03:10 +02:00
SomberNight
7edbd5682a
fix confusion re max path length
2019-08-20 09:03:10 +02:00
SomberNight
2fafd01945
protect against getting robbed through routing fees
2019-08-20 09:03:10 +02:00
SomberNight
d511ecdc00
start failing htlcs
2019-08-20 09:03:10 +02:00
SomberNight
ded11b4d9e
lnonion: implement error packet construction
2019-08-20 09:03:10 +02:00
SomberNight
3ac9858d59
follow-up prev
2019-08-20 09:03:10 +02:00
SomberNight
a8ace7ef4f
lnonion: use IntEnum and IntFlag for failure codes
2019-08-20 09:03:10 +02:00
SomberNight
bab9f163f7
decode onion errors to failure message type
2019-08-20 09:03:10 +02:00
SomberNight
5a05a92b3d
move bolt-04 onion stuff to its own module
2019-08-20 09:03:10 +02:00