Commit graph

3894 commits

Author SHA1 Message Date
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
Matt Corallo
4ebc8e5284
Merge pull request #1637 from tnull/2022-07-contrib-remove-slack
Remove Slack and update `CONTRIBUTING`
2022-08-02 19:19:12 +00:00
Elias Rohrer
afdad4921c Remove Slack and update CONTRIBUTING 2022-08-02 19:51:06 +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
4905df8894
Merge pull request #1628 from tnull/2022-07-readme-remove-slack
Remove Slack link and other updates to `README`
2022-07-27 19:10:04 +00: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
valentinewallace
a6b03033db
Merge pull request #1633 from TheBlueMatt/2022-07-110
Set release date on 0.0.110 release
2022-07-27 14:03:44 -04:00
Matt Corallo
6b1ec5c738
Merge pull request #1632 from TheBlueMatt/2022-07-warnings
Fix compilation warnings
2022-07-27 16:29:09 +00:00
Elias Rohrer
cf7655a1a4 Remove 'slack' (and other things) 2022-07-27 09:00:47 +02: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
7812215a1e Set release date on 0.0.110 release 2022-07-26 23:43:58 +00:00
Matt Corallo
36bffb56e8
Merge pull request #1629 from TheBlueMatt/2022-07-110
Cut 0.0.110
2022-07-26 23:40:45 +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
a22ba39916 Add CHANGELOG entry for 0.0.110 2022-07-26 22:01:09 +00:00
Matt Corallo
4da6f23cff Drop unused test code in lightning-invoice::payment 2022-07-26 20:31:17 +00:00
Matt Corallo
10aa4aa42f Fix new compilation warnings in debug_sync module 2022-07-26 20:29:36 +00:00
Matt Corallo
b84b53a14c
Merge pull request #1631 from dunxen/2022-07-disabledflags
Specify why flags for `channel_disabled` error are zero
2022-07-26 15:53:34 +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
Matt Corallo
19b5a48dde Remove scary disconenct warnings on PeerManager new connection fns
In 4703d4e725 we changed
PeerManager::socket_disconnected to no longer require that sockets
which the PeerManager decided to disconnect not be disconnected.
However, we forgot to remove the scary warnings on the
`new_{inbound,outbound}_connection` functions which warned of the
old behavior.

We do so here.
2022-07-25 18:21:00 +00:00
jurvis
5bccd2eee2
Add utils to handle HTLC handling failure reason
We add `HTLCHandlingFailedConditions` to express the failure parameters,
that will be enforced by a new macro, `expect_pending_htlcs_forwardable_conditions`.
2022-07-25 10:26:38 -07:00
jurvis
17e6c374c5
Add HTLCHandlingFailed event
Adds a HTLCHandlingFailed that expresses failure by our node to process
a specific HTLC. A HTLCDestination enum is defined to express the
possible cases that causes the handling to fail.
2022-07-25 10:22:43 -07:00
Matt Corallo
f26e8541a5
Merge pull request #1627 from dunxen/2022-07-reusevalidatepowblockhash
Reuse `BlockHash` from `validate_pow()`
2022-07-22 15:36:25 +00:00
Duncan Dean
e256b3498e
Reuse BlockHash from validate_pow()
The `validate_pow()` method now returns the BlockHash since rust-bitcoin
v0.26.2 thanks to jkczyz's PR (rust-bitcoin/rust-bitcoin/pull/572).
2022-07-22 11:45:06 +02:00
Matt Corallo
834fe6357d
Merge pull request #1420 from TheBlueMatt/2022-04-moar-lockorder
Expand lockorder testing to look at mutexes, not specific instances
2022-07-21 02:29:16 +00:00
Matt Corallo
ff20203724 Swap HashSets with custom Hash in debug_sync for HashMaps 2022-07-20 22:08:59 +00:00
Matt Corallo
6f2c008751 Expand lockorder testing to look at mutexes, not specific instances
Our existing lockorder inversion checks look at specific instances
of mutexes rather than the general mutex itself. This changes that
behavior to look at the instruction pointer at which a mutex was
created and treat all mutexes which were created at the same
location as equivalent.

This allows us to detect lockorder inversions which occur across
tests, though it does substantially reduce parallelism during test
runs.
2022-07-20 22:08:59 +00:00
Matt Corallo
625cda108c Construct all ChannelMonitor mutexes in the same function
When we add lockorder detection based on mutex construction site
rather than mutex instance in the next commit, ChannelMonitor's
PartialEq implementation causes spurious failures. This is caused
by the lockorder detection logic considering the ChannelMonitor
inner mutex to be two distinct mutexes - one when monitors are
deserialized and one when monitors are created fresh. Instead, we
attempt to tell the lockorder detection logic that they are the
same by ensuring they're constructed in the same place - in this
case a util method.
2022-07-20 22:08:59 +00:00
Matt Corallo
661b7343e8
Merge pull request #1624 from tnull/2022-07-fix-doc
Fix 'not a hyperlink' doc warning
2022-07-20 17:38:42 +00:00
valentinewallace
507d7595ca
Merge pull request #1623 from lexe-tech/custom-smart-pointers
lightning-net-tokio: Allow custom smart pointers
2022-07-20 13:07:20 -04:00
Elias Rohrer
97e6682d58 Fix 'not a hyperlink' doc warning 2022-07-20 14:57:31 +02:00
Max Fang
5019b31b28 lightning-net-tokio: Allow custom smart pointers 2022-07-19 21:57:12 -07:00
Matt Corallo
5023ff05a8
Merge pull request #1610 from TheBlueMatt/2022-07-no-rand-path-selection 2022-07-19 16:56:36 +00:00