1
0
Commit Graph

47 Commits

Author SHA1 Message Date
f321x
3034df61c7 remove wakiyamap lnd node from signet nodes 2025-01-14 11:21:33 +01:00
ThomasV
c58c4d7451 Make lntransport not require lnutil.
This will be useful if we decide to ship lntransport as a separate
package. It is also a conceptual cleanup.

Notes:
 - lntransport still requires crypto.py
 - parsing node id from a bolt11 invoice is not supported.
2024-10-22 09:26:36 +02:00
wakiyamap
1d9ff40d0b Add suport testnet4 2024-09-14 03:52:03 +09:00
SomberNight
79d2b19fc0 trampoline: rm hardcoded TRAMPOLINE_FEES. just use exponential search
Values for exponential search are based on available fee budget:
we try with budget/64, budget/32, ..., budget/1  (spread uniformly among the selected Trampoline Forwarders).
Hence, if we make the fee budget configurable, that will usefully affect the trampoline fees as well.

related https://github.com/spesmilo/electrum/issues/9033
2024-05-06 18:36:29 +00:00
SomberNight
cf2ed509b4 dependencies: remove bitstring
- `bitstring` started depending on `bitarray` in version 4.1 [0]
  - that would mean one additional dependency for us (from yet another maintainer), which is not even pure python
- we only use bitstring for bolt11-parsing
- hence this PR rewrites the bolt11-parsing and removes `bitstring` as dependency
- note: I benchmarked lndecode using [1], and the new code performs better,
  taking around 80% time needed for old code (when using bitstring 3.1.9, pure python).
  Though the variance is quite large in both cases.

[0]: 95ee533ee4/release_notes.txt (L108)
[1]: d7597d96d0
2024-04-24 14:14:31 +00:00
ThomasV
777c2ffb23 create a trampoline onion when directly paying a trampoline node 2024-02-24 16:01:31 +01:00
ThomasV
120faa480e If trampoline is enabled, do not add non-trampoline nodes to invoices
Rationale: The sender should not assume that they share the same list of
hardcoded trampolines as the receiver.
2023-10-29 16:21:25 +01:00
SomberNight
6506abf583 lnworker: use PaymentFeeBudget
- introduce PaymentFeeBudget, which contains limits for fee budget and cltv budget
  - when splitting a payment,
    - the fee budget is linearly distributed between the parts
      - this resolves a FIXME in lnrouter ("FIXME in case of MPP")
    - the cltv budget is simply copied
  - we could also add other kinds of budgets later, e.g. for the num in-flight htlcs
- resolves TODO in lnworker ("todo: compare to the fee of the actual route we found")
2023-10-27 16:01:23 +00:00
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
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
ThomasV
e206d264c8 trampoline forwarding: use routing hints
unit tests:
 - remove 'drop_dave' flag, replace it by depleted channel
 - add test for trampoline forwarding using routing hints
 - lower attempts to 2
2023-09-26 10:07:41 +02:00
ThomasV
40c08d350f trampoline: fix two bugs preventing legacy payments to
Electrum clients that have non-trampoline channels.

 - if an invoice supports trampoline, but provides only
non-trampoline nodes in its routing hints, we must use
a legacy trampoline payment

 - when we create a trampoline onion for a legacy payment,
the invoice_features field is a u64, so we need to remove
high feature bits.
2023-08-27 11:48:29 +02:00
SomberNight
a3997f8b58 lnworker: don't create invoice with dupl t-hints, & filter when sending
- when creating an invoice, if we had multiple chans with the same trampoline,
  were putting duplicate t-hints into the invoice
- when paying an invoice that had duplicate t-hints, we would sometimes
  construct invalid paths (SRC>T1->T1->DST)
2023-08-17 20:04:02 +00:00
SomberNight
98bea49a3c lnworker.pay_to_node: make trampoline fee_level and failed_routes local
multiple instances of pay_to_node might run concurrently, esp for trampoline forwarding
2023-08-11 22:01:11 +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
ThomasV
d95f3e5622 Use different trampoline bits than Eclair. Fixes #8141 2023-01-13 12:48:13 +01:00
ThomasV
552300dc89 follow-up previous commit 2022-09-29 12:13:22 +02:00
ThomasV
4366055ada Remove old trampoline compatibility bits from invoices
bits 50/51 are now used on the network (as option_zeroconf)
2022-09-29 12:06:49 +02:00
ThomasV
68bf714ae6 Trampoline: Remember failed routes (fixes #7967).
Upon receiving UNKNOWN_NEXT_PEER, TEMPORARY_NODE_FAILURE
or TEMPORARY_CHANNEL_FAILURE, remember the trampoline route
that was used, and try other routes before raising the
trampoline fee.

Before this commit, we used to raise the trampoline fee
upon receiving any error message, in order to ensure
termination of the payment loop.

Note that we will still retry failing routes after we have
raised the trampoline fee. This choice is questionable, it
is unclear if doing so significantly increases the probability
of success.

Tests: add a test for trampoline handling of UNKNOWN_NEXT_PEER
2022-09-19 16:42:46 +02:00
ThomasV
082a50f2bd trampolines_by_id must return dict (follow-up previous commit) 2022-09-07 17:48:13 +02:00
ThomasV
99c4c75c9d hardcoded trampolines: do not mix testnet nodes and unitests.
(This was added in 3a7f5373ac. Not sure what the reason is, but
it triggers UNKNOWN_NEXT_PEER errors, that in turn affect routing
choices, e.g. fallback to single trampoline route)
2022-09-07 17:17:13 +02:00
ThomasV
92b21df843 Trampoline: if possible, do not add second trampoline for e2e payments.
This should fix #7967
2022-09-04 09:39:42 +02:00
ThomasV
c6f940d092 trampoline: less verbose, do not log routes that are not tried 2022-09-03 18:24:58 +02:00
ThomasV
7d9f20f8ab update trampoline feature bits. fixes #7801 2022-07-05 08:48:34 +02:00
bitromortac
a4f5cfc91a trampoline: refactor routes, enable e2e mpp
* Refactor `create_trampoline_route`.
* Enables end-to-end multi-trampoline multipart payments.
  Trampoline-to-legacy payments are still not enabled, as this is
  currently not supported by Eclair.
* Reverts to a global trampoline fee level, as trampoline failures
  are currently not handled properly, see (#7648), which doubles
  fee rates.
2022-02-18 10:14:51 +01:00
bitromortac
8ed0f58277 trampoline: add electrum testnet node 2022-02-18 10:14:51 +01:00
bitromortac
a3ec3f3228 trampoline: forwarding, use correct secret for legacy case 2021-12-20 16:45:15 +01:00
bitromortac
58dd8996fb trampoline: use trampoline policy for intermediate forwarders 2021-12-20 16:45:15 +01:00
ghost43
ce44a03c24 Merge pull request #7202 from bitromortac/2104-mpp-channel-splitting
MPP splitting algorithm: redesign and split within channels
2021-12-17 13:58:54 +00:00
wakiyamap
de596a6bfa Change lightning node(signet) 2021-08-12 17:13:28 +09:00
bitromortac
68bc9c2474 lnworker: improve route creation
- Separates the trampoline and local routing multi-part payment cases.
- Ask only for splits that don't send over a single channel (those have
  been tried already in the single-part case).
- Makes sure that create_routes_for_payment only yields partial routes
  that belong to a single split configuration.
- Tracks trampoline fee levels on a per node basis, previously, in the
  case of having two channels with a trampoline forwarder, the global
  fee level would have increased by two levels upon first try.
2021-07-16 11:27:36 +02:00
SomberNight
04bc7fd28f trampoline: fix "pay-to-legacy" workaround when using ACINQ node
It is the last Trampoline Forwarder that should be checked, not the
first one.

Consider route (of Trampolines only):
Alice-electrum -> T_ACINQ -> T_Hodlister -> Bob-electrum
Even if Bob has a transport open with ACINQ or even if Bob has a channel open with ACINQ,
Alice can safely use end-to-end trampoline for this route: ACINQ will not know who
the recipient is, so they will not try to do pay-to-open (and hold up the payment for minutes...).

related: https://github.com/ACINQ/lightning-kmp/pull/237
2021-07-02 19:42:58 +02:00
SomberNight
3a7f5373ac trampoline: improve payment success
- better error handling: previously we stopped all attempts on any of
  TRAMPOLINE_EXPIRY_TOO_SOON, UNKNOWN_NEXT_PEER, TEMPORARY_NODE_FAILURE.
  Instead we should retry (but see code comments).
- previously payments failed if ALL of the following criteria applied:
  - sender is paying via trampoline, but not via the ACINQ node (which is
    special cased)
  - receiver only has private channels and has put r_tags into invoice, along
    with setting the trampoline feature bit in the invoice, however the receiver
    is not connected to any trampoline forwarders directly
  The sender would then assume that the private routing hints in the invoice
  correspond to trampoline forwarders.
- also, previously if both the sender and the recipient used trampoline and
  they shared a trampoline forwarder (that they were both connected to), the
  private channels the recipient had (with nodes other than the shared TF)
  would never be attempted.
2021-07-02 18:44:39 +02:00
wakiyamap
639cd94dcb add signet support 2021-05-06 19:47:22 +09:00
ThomasV
03a95f36fc add trampoline.hodlister.co 2021-03-28 06:05:04 +02:00
ThomasV
bdd9c4823f hardcoded trampoline nodes: replace IPs with domain names 2021-03-26 15:49:10 +01:00
ThomasV
c3221f7bfe (temporary) disable e2e and dual trampoline if first trampoline is ACINQ 2021-03-22 16:23:01 +01:00
Benoit Verret
f731c38293 Minor style changes 2021-03-21 00:36:23 -04:00
ThomasV
196b4c00a3 Use new value of option_trampoline_routing flag, add it to our invoices.
Keep supporting old value for Eclair/Phoenix.
Do not add trampoline_routing_hints in invoices.
2021-03-08 19:16:48 +01:00
ThomasV
83993768e5 trampoline: do not add node in trampoline hints if it already is
the last trampoline of the route
2021-03-06 10:46:58 +01:00
ThomasV
16554afa1b follow-up previous commit (this was for testing) 2021-03-05 10:14:26 +01:00
ThomasV
2e4f45ec74 use two trampolines: fix blacklisting, use local variables for trampoline_fee_level and use_two_trampolines 2021-03-05 10:07:02 +01:00
ThomasV
738411e32b Trampoline forwarding:
- fix regression in create_routes:
   fwd_trampoline_onion was not added to the tuple
 - fix onion structure for e2e
 - maybe_fulfill_htlc:
   check the mpp_status of the outer onion,
   return trampoline_onion to be forwarded
2021-03-04 11:46:31 +01:00
ThomasV
ba4d6bc8b3 trampoline MPP: fix total_msat in trampoline onion, and bucketing 2021-03-04 10:05:09 +01:00
SomberNight
750d8cfab5 lnworker: run create_route_for_payment end-to-end, incl private edges
We pass the private edges to lnrouter, and let it find routes end-to-end.
Previously the edge_cost heuristics didn't apply to the private edges
and we were just randomly picking one of the route hints and use that.
So e.g. cheaper private edges were not preferred, but they are now.

PathEdge now stores both start_node and end_node; not just end_node.
2021-03-02 18:00:31 +01:00
ThomasV
259dacd56f Trampoline MPP aggregation:
- trampoline node is the final recipient of MPP
 - each trampoline receives a bucket of HTLCs
 - if a HTLC from a bucket fails, wait for the entire bucket to fail
 - move trampoline route and onion code into trampoline module
2021-03-02 14:28:15 +01:00