Commit Graph

301 Commits

Author SHA1 Message Date
ThomasV
d3d476f44c lnpeer: fix error code in logs 2021-03-06 00:31:30 +01:00
ThomasV
5207c40cc3 fix trampoline forwarding: add_received_htlc must be indexed by payment_secret 2021-03-05 17:04:26 +01:00
SomberNight
762ebb12b2 lnpeer: increase max_accepted_htlcs (5->30)
Counter-intuitively, the motivation is to be able to *send* more htlcs,
for MPP trickery. We don't offer more htlcs than this limit, to be
conservative with what we send, and to interoperate with clightning.

defaults of other clients:
eclair: 30
clightning: 30
lnd: 483
2021-03-05 16:12:01 +01:00
ThomasV
eda9097e89 trampoline forwarding: return UNKNOWN_NEXT_PEER if we cannot find a route 2021-03-05 12:47:18 +01:00
ThomasV
6cc3480356 follow-up prev commit 2021-03-05 10:23:00 +01:00
SomberNight
ff485cee62 use functools.wraps() for some wrappers
to help debugging
2021-03-04 16:44:13 +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
SomberNight
44059ec116 lnpeer: more detailed logging in maybe_fulfill_htlc 2021-03-02 18:53:08 +01:00
SomberNight
4445cef033 lnutil: turn global forwarding fee params into Channel attributes
useful for unit testing, and it is the conceptually correct thing anyway
2021-03-02 14:54:47 +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
2da90add8f maybe_fulfill_htlc: add failure reason to logs 2021-03-02 14:26:16 +01:00
ThomasV
7f61f22857 MPP receive: allow payer to retry after mpp timeout 2021-02-27 11:48:14 +01:00
SomberNight
254f57bce5 lnpeer.maybe_fulfill_htlc: fix error case FINAL_INCORRECT_HTLC_AMOUNT
follow-up ef5a265449
2021-02-25 12:49:06 +01:00
SomberNight
31bdb5c344 lnpeer.maybe_fulfill_htlc: follow BOLTs re some errors
related: https://github.com/lightningnetwork/lightning-rfc/pull/608
2021-02-25 12:12:44 +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
9024419fdc lnpeer: MPP receive: require payment_secret for each htlc
BOLT-04 says:
The final node:
  if it supports basic_mpp:
    MUST require payment_secret for all HTLCs in the set

90468030d5/04-onion-routing.md (basic-multi-part-payments)
2021-02-24 20:34:34 +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
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
9ea2c275ce Merge pull request #7050 from bitromortac/mpp-send
Complete multipart payment sending support
2021-02-22 13:51:59 +01:00
bitromortac
9f84fa9580 lnonion: add total_msat to onion payment data 2021-02-22 11:25:00 +01:00
ThomasV
3a40d48a6e lnpeer: remove recursve call in maybe_fulfill_htlc 2021-02-20 14:20:55 +01:00
ThomasV
bab22c8c53 minor: fix exception 2021-02-17 18:18:36 +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
bitromortac
2bffc9d3eb lnpeer: fix timed out mpp 2021-02-05 21:52:13 +01:00
ThomasV
ef5a265449 basic_mpp: receive multi-part payments 2021-02-04 16:31:17 +01:00
ThomasV
e477a43385 PaymentInfo: use msat precision 2021-02-01 15:03:56 +01:00
SomberNight
2b0f156ce8 lnpeer.htlc_switch: (bugfix) don't fulfill htlc until add is irrevocable
This makes the test added in prev commit pass.
2021-01-28 20:03:30 +01:00
SomberNight
e8a2fa5596 tests: lnpeer.htlc_switch: don't fulfill htlc until add is irrevocable
This adds a failing test, where the HTLC switch fulfills an HTLC too soon,
before the corresponding 'update_add_htlc' is irrevocably committed.
2021-01-28 20:00:48 +01:00
ThomasV
521376f87f rm unused parameter in maybe_fulfill_htlc 2021-01-28 13:10:43 +01:00
ThomasV
fe1b2149cb lnpeer: fix flen in INIT 2021-01-28 11:14:53 +01:00
ThomasV
23ece8b33b lnpeer: initialize new channel storage with lnworker db 2021-01-16 19:04:58 +01:00
bitromortac
bd178fbed5 lnpeer: remove unused imports, code cleanup 2021-01-11 11:37:14 +01:00
bitromortac
6b90a2d36c lnpeer: implement upfront shutdown script logic
Upfront shutdown script is a script provided on channel opening,
which will be used by the peer to enforce us closing to this script
on collaborative channel close.
2021-01-11 11:37:14 +01:00
bitromortac
863fe031f0 lnpeer: await on_message handlers to raise exceptions 2021-01-11 11:36:38 +01:00
ThomasV
177766ac37 lnpeer: fix a comment 2021-01-04 12:39:24 +01:00
ThomasV
eb6eac9254 fix reserve_sat in local_config. see #6896 2020-12-31 08:44:26 +01:00
ThomasV
b29cdc02da Require gossip_queries in LNWallet (follow-up f83d2d9fee)
- workaround lnd bug https://github.com/lightningnetwork/lnd/issues/3651
 - also reduces bandwidth usage
2020-12-28 15:41:42 +01:00
ThomasV
f83d2d9fee Move the part of process_gossip that requires access to channel_db into in LNGossip. 2020-12-21 13:33:34 +01:00
ThomasV
dfcdcb8d64 fix typo 2020-11-20 08:51:01 +01:00
SomberNight
82c8c4280f lnworker: add request_remote_force_close which can be used without state
see #6656
2020-10-17 03:59:50 +02:00
SomberNight
35f1f2905b lnpeer: forbid creating Peer with ourselves (self-connect)
related: #6583
2020-09-15 18:35:16 +02:00
SomberNight
ea3e3ddbb8 lnpeer: handle cooperative close edge-case
fix #6317
2020-09-13 16:55:37 +02:00
SomberNight
aba2e0f55a lnhtlc: add all_htlcs_ever, get_htlc_by_id, was_htlc_failed and use them
towards encapsulation of hm.log
2020-09-04 19:29:14 +02:00
ThomasV
0b16f8ec3a lnpeer: only process INIT if we are a backup. fixes #6241 2020-06-23 13:12:11 +02:00
SomberNight
1321b0e47a qt channel details: maybe fix #5728 2020-06-21 05:16:27 +02:00
ThomasV
aacddf008c trigger_force_close: set my_current_per_commitment_point to a valid point
We could as well derive the point from our channel_seed and ctn=0,
but that seems unnecessary. Related: #6241
2020-06-19 12:04:04 +02:00