Commit Graph

144 Commits

Author SHA1 Message Date
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
SomberNight
e42120cac5 lnutil.LnFeatures: update LN_FEATURES_IMPLEMENTED 2021-02-22 20:04:47 +01:00
SomberNight
baad8ab3ff lnutil.LnFeatures: update context for "option_support_large_channel"
this was changed in https://github.com/lightningnetwork/lightning-rfc/pull/773
2021-02-22 20:01:45 +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
bitromortac
3ddb83fad3 lnworker: move NoPathFound to lnutil 2021-02-19 09:27:49 +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
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
SomberNight
337d4890a1 lnworker/swaps: add '_sat' suffix to arg names and force kwargs 2021-02-01 22:11:56 +01:00
ThomasV
ad91257729 pass blacklist to lnrouter.find_route, so that lnrouter is stateless (see #6778) 2021-01-11 15:19:50 +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
SomberNight
2ec548dda3 ChannelDB: avoid duplicate (host,port) entries in ChannelDB._addresses
before:
node_id -> set of (host, port, ts)
after:
node_id -> NetAddress -> timestamp

Look at e.g. add_recent_peer; we only want to store
the last connection time, not all of them.
2021-01-09 19:56:05 +01:00
ThomasV
dfcdcb8d64 fix typo 2020-11-20 08:51:01 +01:00
SomberNight
c872c3194f qt "open channel" dialog: detect invalid remote node id sooner
and avoid the "please wait" text to be interpreted as a node id

related #6705
2020-11-13 19:21:37 +01:00
SomberNight
4c7a92f39c bitcoin: implement construct_script and use it 2020-10-24 07:49:06 +02:00
SomberNight
89bd520185 bitcoin: move construct_witness from transaction.py to bitcoin.py 2020-10-24 05:18:16 +02:00
SomberNight
261ad804ca invoices: always validate that LNInvoice.invoice can be decoded
related: #6559

The LNInvoice.from_json() method previously did not validate, which is
used by e.g. wallet.import_invoices.
2020-09-11 19:57:42 +02:00
SomberNight
9fa666f179 fix channel backups with old "cryptography" module
closes #6314
2020-07-02 11:07:10 +02:00
SomberNight
89ddc1345d lnutil.PaymentAttemptLog: fix error formatting
fixes #6249
2020-06-22 03:40:04 +02:00
SomberNight
ea329063bf channel open: allow REMOTE to set htlc_minimum_msat to 0
non-positive values do not make sense... but some nodes set it to 0
and if we enforce >= 1 then we can't open channels with those...
lnchannel._assert_can_add_htlc enforces positive values for HTLCs in any case.
2020-06-19 18:15:09 +02:00
SomberNight
3665f5d3fd fix channel backups for "not initiator" channels
bool(b'\x00') is True
2020-06-19 06:53:45 +02:00
SomberNight
e1a2299f0c channel backup versions: trivial clean-up 2020-06-18 15:03:16 +02:00
ThomasV
6922d81a1e channel backups: add another version number, for the backup itself 2020-06-18 15:03:16 +02:00
SomberNight
996799d79e lnchannel: update_fee: improve "can afford" check 2020-06-15 16:10:12 +02:00
SomberNight
817411b889 ChannelConfig: add some clarifications 2020-06-15 14:39:42 +02:00
SomberNight
5b4d46299a ChannelConfig.validate_params: fix sat/msat unit mismatch
follow-up fc39295d20
2020-06-09 20:23:52 +02:00
SomberNight
3509343447 ln: make 'to_self_delay' CSV configurable
needed for tests
2020-06-09 18:36:34 +02:00
SomberNight
fc39295d20 lnpeer: review safety check re channel open flow, and tweak params 2020-06-08 21:17:23 +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
ThomasV
abe1bece2c remove UnknownPaymentHash (exception used as value) 2020-05-02 22:37:28 +02:00
SomberNight
f5eb91900a use correct feerate when sweeping htlcs
fixes #6131
2020-04-30 19:37:06 +02:00
SomberNight
54e1520ee4 ln: check if chain tip is stale when receiving HTLC
if so, don't release preimage / don't forward HTLC
2020-04-13 17:04:27 +02:00
SomberNight
8e8ab775eb lnchannel: make AbstractChannel inherit ABC
and add some type annotations, clean up method signatures
2020-04-13 15:57:53 +02:00
ThomasV
8f41aeb783 Replace wallet backup with channel backups
- channels can be backed up individually
 - backups are added to lnwatcher
 - AbstractChannel ancestor class
2020-04-10 14:45:23 +02:00
ThomasV
f3995350e8 localconfig: rename seed to channel_seed 2020-04-06 16:53:48 +02:00
SomberNight
08bc8617ad change derivation of ln channel keys: use hardened paths 2020-04-06 12:53:57 +02:00
ThomasV
0ea21c59d2 Save channel seed in localconfig 2020-04-04 13:28:19 +02:00
ThomasV
aa32e31a3d follow-up previous commit 2020-04-03 18:54:02 +02:00
SomberNight
71635216df ln feature bits: validate transitive feature deps everywhere 2020-04-01 21:49:19 +02:00
SomberNight
1be0a710c3 ln: implement option payment_secret 2020-04-01 21:49:12 +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
6ba08cc8d4 ln feature bits: flatten namespaces, and impl feature deps and ctxs
This implements:
- flat feature bits https://github.com/lightningnetwork/lightning-rfc/pull/666
- feature bit dependencies https://github.com/lightningnetwork/lightning-rfc/pull/719
2020-04-01 21:41:24 +02:00
SomberNight
79d57784c1 lnchannel: add more type hints 2020-03-30 03:49:50 +02:00
SomberNight
8ad6d5ddda lnchannel: clean-up docstrings a bit
Removed lnd copyright as by now everything covered in this file
has been rewritten.
2020-03-30 02:46:21 +02:00
SomberNight
acb0d7ebac lnchannel: better checks for "update_add_htlc"
I believe this now implements all the checks listed in BOLT-02 for
update_add_htlc, however, the BOLT is sometimes ambiguous,
and actually the checks listed there IMO are insufficient.
There are still some TODOs, in part because of the above.
2020-03-30 02:46:18 +02:00
SomberNight
90f3b667aa small clean-up re max CLTV delta for LN 2020-03-30 02:46:14 +02:00
SomberNight
5b7ce98ab2 lnchannel: fix included_htlcs 2020-03-27 19:06:30 +01:00
SomberNight
01207316aa storage upgrade: move "htlc_minimum_msat" to base channel config 2020-03-26 09:05:04 +01:00
SomberNight
53c6fc8cf1 lnchannel: test for max htlc value (needs to be below protocol maximum) 2020-03-26 09:05:00 +01:00