Commit graph

2006 commits

Author SHA1 Message Date
Matt Corallo
9115f66dbc Store the full event transaction in OnchainEvent structs
When we see a transaction which generates some `OnchainEvent`, its
useful to have the full transaction around for later analysis.
Specifically, it lets us check the list of outputs which were spent
in the transaction, allowing us to look up, e.g. which HTLC
outpoint was spent in a transaction.

This will be used in a few commits to do exactly that - figure out
which HTLC a given `OnchainEvent` corresponds with.
2022-08-15 23:17:22 +00:00
Matt Corallo
4005724ae6
Merge pull request #1663 from tnull/2022-08-drop-register-output-return
Drop return value from `Filter::register_output`
2022-08-15 23:10:32 +00:00
Elias Rohrer
c562f3338b Clarify 'should' vs 'will' in get_relevant_txids 2022-08-15 20:55:37 +02:00
Elias Rohrer
2f4457fd7e Drop return value from Filter::register_output
This commit removes the return value from `Filter::register_output` as
creating a suitable value almost always entails blocking operations
(e.g., lookups via network request), which however conflicts with the
requirement that user calls should avoid blocking calls at all cost.

Removing the return value also rendered quite a bit of test code for
dependent transaction handling superfluous, which is therefore also
removed with this commit.
2022-08-15 20:47:33 +02:00
valentinewallace
ca4e31d751
Merge pull request #1659 from valentinewallace/2022-08-fix-payload-decode
Fix payment onion payload decode
2022-08-15 14:32:47 -04:00
Valentine Wallace
dfbebbf4c3
Rename HighZeroBytesDroppedVarInt to HighZeroBytesDroppedBigSize
As observed by @wpaulino, this struct encodes its bytes as big-endian,
therefore it's a BigSize, not a VarInt.
2022-08-15 11:41:59 -04:00
Valentine Wallace
a23681fde1
Fix bug in onion payment payload decode
Prior to this change, we could have failed to decode a valid payload of size
>253. This is because we were decoding the length (a BigSize, big-endian) as a
VarInt (little-endian).

Found in #1652.
2022-08-15 11:41:56 -04:00
Matt Corallo
b414c0641b
Merge pull request #1658 from lightning-signer/2022-08-bitcoin-0-29
Update bitcoin crate to 0.29.0
2022-08-12 23:51:06 +00:00
Devrandom
11166aa836 Modify ecdh to take Scalar 2022-08-11 00:21:26 +02:00
Devrandom
7e05623bef Update bitcoin crate to 0.29.0 2022-08-11 00:21:26 +02:00
valentinewallace
d2191d9c6d
Merge pull request #1655 from valentinewallace/2022-08-fix-ci-doc-links-check
Fix CI to error on doc links to private items
2022-08-09 12:49:40 -04:00
Valentine Wallace
c242003dd3
Fix CI to error on doc links to private items
Somehow we weren't doing this.
2022-08-07 13:49:12 -04:00
Valentine Wallace
dcef41d17b
Minor msgs::OnionHopData cleanups 2022-08-05 22:34:36 -04:00
Matt Corallo
fc771d3b20 [C Bindings] Expose channel and nodes list in ReadOnlyNetworkGraph 2022-08-05 21:14:36 +00:00
Matt Corallo
b4521f52e2
Merge pull request #1638 from ViktorTigerstrom/2022-07-update-decode-update-add-htlc-onion-return-parameters
Don't return `channel_state` from `decode_update_add_htlc_onion`
2022-08-03 17:44:46 +00:00
Matt Corallo
736c0b9e7f
Merge pull request #1619 from G8XSU/main
Add config support for 'their_channel_reserve_proportional_millionths' [#1498]
2022-08-03 17:37:51 +00:00
Matt Corallo
28c9b56113
Merge pull request #1503 from valentinewallace/2022-05-onion-msgs
Onion messages v1
2022-08-03 04:39:56 +00:00
Valentine Wallace
17ec697f8f
Fix possible incomplete read bug on onion packet decode
Pre-existing to this PR, we were reading next packet bytes with io::Read::read,
which is not guaranteed to read all the bytes we need, only guaranteed to read
*some* bytes.

We fix this to be read_exact, which is guaranteed to read all the next hop
packet bytes.
2022-08-02 19:19:39 -04:00
Valentine Wallace
39397d4e14
Error when attempting to send an OM to a blinded route with 0 hops 2022-08-02 19:19:39 -04:00
Valentine Wallace
6500c99f29
Add SendError enum for onion messages and error on too-big packets 2022-08-02 19:19:39 -04:00
Valentine Wallace
eaff561e24
Add test utilities and integration tests for onion messages 2022-08-02 19:19:39 -04:00
Valentine Wallace
b26fb851cd
Significantly expand onion message documentation 2022-08-02 19:19:39 -04:00
Valentine Wallace
bf007ea763
Implement receiving and forwarding onion messages
This required adapting `onion_utils::decode_next_hop` to work for both payments
and onion messages.

Currently we just print out the path_id of any onion messages we receive. In
the future, these received onion messages will be redirected to their
respective handlers: i.e. an invoice_request will go to an InvoiceHandler,
custom onion messages will go to a custom handler, etc.
2022-08-02 19:19:37 -04:00
Valentine Wallace
9051c38ebe
Support sending onion messages
This adds several utilities in service of then adding
OnionMessenger::send_onion_message, which can send to either an unblinded
pubkey or a blinded route. Sending custom TLVs and sending an onion message
containing a reply path are not yet supported.

We also need to split the construct_keys_callback macro into two macros to
avoid an unused assignment warning.
2022-08-02 19:17:27 -04:00
Valentine Wallace
4c8dc2c2a0
Add baseline OnionMessenger and msgs::OnionMessage and its serialization
OnionMessenger will be hooked up to the PeerManager to send and receive OMs in
a follow-up PR.
2022-08-02 19:17:26 -04:00
Valentine Wallace
6017379b8e
KeysInterface: add new ecdh method
This method will help us avoid retrieving our node secret, something we want to
get rid of entirely.  It will be used in upcoming commits when decoding the
onion message packet, and in future PRs to help us get rid of
KeysInterface::get_node_secret usages across the codebase
2022-08-02 19:17:23 -04:00
Valentine Wallace
33ff2746ef
Add onion_message::Packet and adapt construct_onion_packet_with_init_noise for it
We need to add a new Packet struct because onion message packet hop_data fields
can be of variable length, whereas regular payment packets are always 1366
bytes.

Co-authored-by: Valentine Wallace <vwallace@protonmail.com>
Co-authored-by: Jeffrey Czyz <jkczyz@gmail.com>
2022-08-02 19:17:19 -04:00
Gursharan Singh
092d1c1f0d Add config support for 'their_channel_reserve_proportional_millionths' [#1498]
It is proportion of the channel value to configure as the
`their_channel_reserve_satoshis` for both outbound and inbound channels.
It decides the minimum balance that the other node has to maintain on their
side, at all times.
2022-08-02 14:33:01 -07:00
Viktor Tigerström
65e6fb7467 Don't return channel_state from decode_update_add_htlc_onion
Currently `decode_update_add_htlc_onion` returns the `channel_state`
lock to ensure that `internal_update_add_htlc` holds a single
`channel_state` lock in when the entire function execution. This is
unnecessary, and since we are moving the channel storage to the
`per_peer_state`, this no longer achieves the goal it was intended for.

We therefore avoid returning the `channel_state` from
`decode_update_add_htlc_onion`, and just retake the lock in
`internal_update_add_htlc` instead.
2022-08-02 23:16:17 +02:00
Valentine Wallace
4e5381a50f
Add onion messages module + enable the construction of blinded routes
Blinded routes can be provided as destinations for onion messages, when the
recipient prefers to remain anonymous.

We also add supporting utilities for constructing blinded path keys, and
control TLVs structs representing blinded payloads prior to being
encoded/encrypted. These utilities and struct will be re-used in upcoming
commits for sending and receiving/forwarding onion messages.

Finally, add utilities for reading the padding from an onion message's
encrypted TLVs without an intermediate Vec.
2022-08-02 12:11:11 -04:00
Matt Corallo
018a78328e
Merge pull request #1635 from TheBlueMatt/2022-07-accessor-pub
Expose `ChannelMonitor::get_counterparty_node_id`
2022-07-27 18:46:52 +00:00
Matt Corallo
6b1ec5c738
Merge pull request #1632 from TheBlueMatt/2022-07-warnings
Fix compilation warnings
2022-07-27 16:29:09 +00:00
Matt Corallo
75b111291f Expose ChannelMonitor::get_counterparty_node_id
This fixes an oversight in ac842ed9dd
namely that it left users unable to implement their own
`ChainMonitor` from outside of the `rust-lightning` crate.
2022-07-27 03:53:47 +00:00
Matt Corallo
e10dfe4fd0 Bump crate versions to 0.0.110/invoice 0.18 2022-07-26 22:01:09 +00:00
Matt Corallo
10aa4aa42f Fix new compilation warnings in debug_sync module 2022-07-26 20:29:36 +00:00
Duncan Dean
b2a2b1fb02
Specify why flags for channel_disabled error are zero
We can remove the TODO for this and specify why the flags are zero
as it's now fully specified in BOLT 4.

See https://github.com/lightning/bolts/blob/341ec84/04-onion-routing.md?plain=1#L1008
2022-07-26 10:29:12 +02:00
Jeffrey Czyz
f0b818952b
Merge pull request #1403 from jurvis/jurvis/add-paymentforwardingfailed-event
Add HTLCHandlingFailed event
2022-07-25 19:23:53 -05:00
Matt Corallo
61b0a904da
Merge pull request #1617 from TheBlueMatt/2022-07-base-ppm
Add a per-amount base penalty in the ProbabilisticScorer
2022-07-25 22:02:10 +00:00
Matt Corallo
79b55f0815
Merge pull request #1626 from TheBlueMatt/2022-07-fix-pm-docs
Remove scary disconenct warnings on PeerManager new connection fns
2022-07-25 21:56:40 +00:00
Matt Corallo
d8cca9806c
Merge pull request #1611 from TheBlueMatt/2022-07-lower-bounded-estimator-nit
Use a separate (non-trait) fee-estimation fn in LowerBoundedEstimator
2022-07-25 21:11:07 +00:00
Matt Corallo
1988cb22cc
Merge pull request #1519 from tnull/2022-06-require-htlc-max
Make `htlc_maximum_msat` a required field.
2022-07-25 21:04:54 +00:00
Matt Corallo
7f80972e1f Rename amount penalty to liquidity_penalty_amount_multiplier_msat
This makes our `ProbabilisticScorer` field names more consistent,
as we add more types of penalties, referring to a penalty as only
the "amount penalty" no longer makes sense - we not have several
amount multiplier penalties.
2022-07-25 19:22:24 +00:00
Matt Corallo
fe39a89ab3 Add a per-amount base penalty in the ProbabilisticScorer
There's not much reason to not have a per-hop-per-amount penalty in
the `ProbabilisticScorer` to go along with the per-hop penalty to
let it scale up to larger amounts, so we add one here.

Notably, we use a divisor of 2^30 instead of 2^20 (like the
equivalent liquidity penalty) as it allows for more flexibility,
and there's not really any reason to worry about us not being able
to create high enough penalties.

Closes #1616
2022-07-25 19:22:24 +00:00
Elias Rohrer
8b86ed7c52 Test serialization of ChannelInfo and NodeInfo 2022-07-25 20:39:06 +02:00
Elias Rohrer
8f4c951b1f Don't fail read NodeInfo for inv. NetAddress
Fixes a deserialization incompatibility introduced with #1553.
2022-07-25 20:38:18 +02:00
Elias Rohrer
b0e8b739b7 Make htlc_maximum_msat a required field. 2022-07-25 20:35:51 +02:00
Matt Corallo
af7e9b608d Change LowerBoundedFeeEstimator fn name to make it hard to swap
This change the method name on `LowerBoundedFeeEstimator` to
further differentiate it from the generic `FeeEstimator` trait.
2022-07-25 18:33:10 +00:00
Matt Corallo
a491200f96 Avoid blanket implementing FeeEstimator for Deref<FeeEstimator>
This simplifies things for bindings (and, to some extent,
downstream users) by exploiting the fact that we can always "clone"
a reference to a struct by dereferencing and then creating a new
reference.
2022-07-25 18:33:10 +00:00
Matt Corallo
ca9357147e Use a separate (non-trait) fee-estimation fn in LowerBoundedEstimator
This should make it somewhat more difficult to accidentally use a
straight fee estimator when we actually want a
LowerBoundedFeeEstimator by not having the types be exchangeable at
all.
2022-07-25 18:33:10 +00:00
jurvis
ac842ed9dd
Send failure event if we fail to handle a HTLC
In `ChannelManager::fail_htlc_backwards_internal`, we push a `HTLCHandlingFailed`
containing some information about the HTLC
2022-07-25 11:28:51 -07:00