Commit Graph

517 Commits

Author SHA1 Message Date
ThomasV
5663e59863 lnworker: fix amount_inflight.
(amount with routing fees were used on htlc failures)
2021-03-06 10:46:40 +01:00
ThomasV
31919d0425 lnworker: add assert amount_inflight <= amount_to_pay 2021-03-06 00:29:37 +01:00
ThomasV
5207c40cc3 fix trampoline forwarding: add_received_htlc must be indexed by payment_secret 2021-03-05 17:04: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
5a2a724cb9 Receive MPP: Use persisted payment status to decide whether to
fulfill HTLCs. Without this commit, we might timeout a part of
a payment if the client is shut down before all parts are
fulfilled.
2021-03-04 14:11:55 +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
ThomasV
253907fb60 lnworker: move buckets logic inside first branch of if statement (refactoring commit) 2021-03-04 08:50:22 +01:00
SomberNight
adbfb2dcc8 lnworker.pay_to_node: (fix) pass correct total_msat to pay_to_route 2021-03-03 20:35:48 +01:00
ThomasV
ca6ecd56f2 fix route for non-trampoline MPP 2021-03-03 12:30:29 +01:00
ThomasV
51f3c613a5 (minor) fix typos and indentation 2021-03-03 10:03:29 +01:00
SomberNight
9310e9023e test_lnpeer: add test: multihop payment that routes around failure
This would have caught the overpayment bug fixed in
693583edc5
2021-03-02 18:35:07 +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
ThomasV
693583edc5 lnworker: amount passed in HtlcLog must be without fees 2021-03-02 10:23:30 +01:00
SomberNight
06ea06f7d3 _calc_routing_hints_for_invoice: incl max 15 chans to avoid qr overflow
Prioritise channels that are likely to be able to receive the payment.
2021-03-01 21:55:41 +01:00
SomberNight
6f894b9f88 _calc_routing_hints_for_invoice: also incl chans < invoice amount
now that we can receive MPP
2021-03-01 21:51:17 +01:00
SomberNight
1139720b58 lnworker: fix handle_error_code_from_failed_htlc for private channels
if the last (private) edge of the route errors, we need to try other route hints (if any)
2021-03-01 21:26:05 +01:00
SomberNight
7d7dcf0795 qt/kivy ChannelsList: if node alias is unknown, display node id
instead of "unknown"
2021-03-01 16:41:54 +01:00
ThomasV
f32d49b8ca revert 'keep invoice INFLIGHT', check HTLCs before payment attempt 2021-02-28 09:01:31 +01:00
ThomasV
b6b13217b4 lnworker: keep invoice status INFLIGHT as long as HTLCs are inflight 2021-02-27 20:26:58 +01:00
ThomasV
7f61f22857 MPP receive: allow payer to retry after mpp timeout 2021-02-27 11:48:14 +01:00
SomberNight
16f0b30ced lnpeer: MPP recv: only fulfill htlc if amt sum exact-matches total_msat 2021-02-24 20:51:58 +01:00
SomberNight
691ebaf4f8 lnworker/lnpeer: add some type hints, force some kwargs 2021-02-24 20:03:12 +01:00
ThomasV
c9d6d11604 create_trampoline_route: check that we can pay the amount and the fees, and that the route is sane 2021-02-24 18:25:49 +01:00
ThomasV
bf1d516959 lnworker: add fees from private path to the amount passed to find_route.
(see #7050)
2021-02-24 16:32:08 +01:00
ThomasV
391dba7117 Refactor find_route_for_payment
- remove duplicated code
 - rename variable names to be consistent with the
'path', 'route' terminology
 - compute private route before route
2021-02-24 16:26:53 +01:00
SomberNight
0a5b714643 lnworker: add "endurance" ACINQ testnet node as hardcoded trampoline 2021-02-24 13:38:04 +01:00
SomberNight
4aab843f17 lnutil.LnFeatures: impl and use "supports" method for feature-bit-tests
Note that for a required feature, BOLT-09 allows setting either:
- only the REQ bit
- both the REQ bit and the OPT bit

Hence, when checking if a feature is supported by e.g. an invoice, both
bits should be checked.

Note that in lnpeer.py, in self.features specifically, REQ implies OPT,
as it is set by ln_compare_features.
2021-02-22 19:53:01 +01:00
ThomasV
0369829e5e MPP: can_send/can_receive is now the sum, no longer the max 2021-02-22 16:42:27 +01:00
ThomasV
827cd344d5 enable MPP with trampoline 2021-02-22 15:55:22 +01:00
ThomasV
64c9ddb88d MPP: refactor code 2021-02-22 14:24:23 +01:00
bitromortac
e9fe0ed22b lnworker: use suggest_splits for multiple routes 2021-02-22 11:25:01 +01:00
bitromortac
9f84fa9580 lnonion: add total_msat to onion payment data 2021-02-22 11:25:00 +01:00
bitromortac
3ddb83fad3 lnworker: move NoPathFound to lnutil 2021-02-19 09:27:49 +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
1323bd4f9c open_channel_coroutine: do not timeout on sign_transaction. fixes #7027 2021-02-15 16:47:42 +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
42c10c2fec Separate pay_to_node logic from pay_invoice:
- pay_to_node will be needed to forward trampoline onions.
 - pay_to_node either is successful or raises
 - pay_invoice handles invoice status
2021-02-07 13:03:18 +01:00
ThomasV
2c2d3f3b30 handle_error_from_failed_htlc: blacklist channel if cannot decode payload 2021-02-07 12:34:28 +01:00
ThomasV
4febbcdc2d encapsulate get_routing_info in lnaddr 2021-02-07 12:21:00 +01:00
ThomasV
0c93394513 rename lnworker._pay to pay_invoice, call it directly from GUIs 2021-02-07 12:09:37 +01:00
ThomasV
34734bd229 cleanup, follow-up f28a2aae73 2021-02-05 17:09:47 +01:00
ThomasV
f28a2aae73 Reorganize code so that we can send Multi Part Payments:
- LNWorker is notified about htlc events and creates payment events.
 - LNWorker._pay is a while loop that calls create_routes_from_invoice.
 - create_route_from_invoices should decide whether to split the payment,
   using graph knowledge and feedback from previous attempts (not in this commit)
 - data structures for payment logs are simplified into a single type, HtlcLog
2021-02-05 14:28:58 +01:00
ThomasV
ff8fc798f4 follow-up c0bf9b4509 2021-02-05 11:33:45 +01:00
ThomasV
ef5a265449 basic_mpp: receive multi-part payments 2021-02-04 16:31:17 +01:00
ThomasV
c0bf9b4509 LNWorker: do not save PR_INFLIGHT status, detect it on startup instead 2021-02-04 16:30:50 +01:00
SomberNight
337d4890a1 lnworker/swaps: add '_sat' suffix to arg names and force kwargs 2021-02-01 22:11:56 +01:00
ThomasV
e477a43385 PaymentInfo: use msat precision 2021-02-01 15:03:56 +01:00