Commit graph

785 commits

Author SHA1 Message Date
shaavan
42c096c491 Allow create_blinded_paths functions to accept MessageContext as input field
- Enabled `create_blinded_paths` to accept `MessageContext` TLVs as
  an input field.
- `MessageContext` is intended to be sent along with the `reply_path`
   to the counterparty.
- Added `MessageContext` in the `create_blinded_paths` flow, optionally
  appending it within the `reply_path`.
- Updated tests to verify the new feature.
2024-07-09 17:27:11 +05:30
shaavan
fbe9dfa938 Update handle_message to accept OffersContext data as an input field
1. Handling Offers Data:
   - Updated `handle_message` to accept `OffersContext` data as an input field.
   - If it is present, it will be utilized by the handler to
     abandon outbound payments that have failed for any reason.

2. Consistency in Custom Message Handling:
   - Updated `handle_custom_message` to accept optional custom data.
     for consistency.
   - Note: `custom_data` will remain unused in this PR.
2024-07-09 17:27:08 +05:30
shaavan
7e2fde7054 Remove path_id from Responder, and OnionMessageResponse struct
1. The path_id will be removed from the codebase in the following
   commits.
2024-07-09 01:44:14 +05:30
Matt Corallo
8d240cfe3e
Merge pull request #3144 from TheBlueMatt/2024-06-message-flags
(Re-)add handling for `ChannelUpdate::message_flags`
2024-07-02 15:16:59 -07:00
Matt Corallo
162b81fbb1 Use test_msg_exact in channl_update fuzz testing
Gossip messages should always use `test_msg_exact` to ensure they
round-trip during signature validation.
2024-07-01 23:46:34 +00:00
Matt Corallo
dc3f826123 (Re-)add handling for ChannelUpdate::message_flags
When the `htlc_maximum_msat` field was made mandatory in
`ChannelUpdate` (in b0e8b739b7) we
started ignoring the `message_flags` field entirely and always
writing `1`. The comment updates indicated that the `message_flags`
field was deprecated, but this is not true - only the
`htlc_maximum_msat` indicator bit was deprecated, requiring it to
be 1.

If a node creates a `channel_update` with `message_flags` bits set
other than the low bit, this will cause us to spuriously reject
the message with an invalid signature error as we will check the
message against the wrong hash.

With today's current spec this is totally fine - the only other bit
defined for `message_flags` is the `dont_forward` bit, which when
set indicates we shouldn't accept the message into our gossip store
anyway (though this may lead to spurious `warning` messages being
sent to peers). However, in the future this may mean we start
rejecting valid `channel_update`s if new bits are defiend.
2024-07-01 23:46:34 +00:00
Jeffrey Czyz
3ccf064160
Merge pull request #3129 from optout21/splicing-msgs-update
Update splice messages according to new spec draft
2024-06-27 14:39:26 -05:00
Valentine Wallace
07b4cb6265
Onion message fuzzer: update held_htlc_available handling
Fuzzers should always do more, not less. Post-merge feedback on
e8f154dd3c.
2024-06-25 15:51:05 -04:00
valentinewallace
88e1b56d66
Merge pull request #3125 from valentinewallace/2024-06-async-payments-prefactor
Async payments message encoding and prefactor
2024-06-24 12:06:17 -04:00
optout
43a6ee34d7
Update splice messages according to new spec draft 2024-06-24 13:05:45 +02:00
Valentine Wallace
e8f154dd3c
AsyncPaymentsMessageHandler trait for OnionMessenger
Add a trait for handling async payments messages to OnionMessenger. This allows
users to either provide their own custom handling for async payments messages
or rely on a version provided by LDK.
2024-06-20 14:24:03 -04:00
Matt Corallo
38285167b1
Merge pull request #3127 from wvanlint/non_strict_forwarding
Implement non-strict forwarding
2024-06-20 07:26:43 -07:00
Willem Van Lint
05e6252b20 Implement non-strict forwarding
This change implements non-strict forwarding, allowing the node to
forward an HTLC along a channel other than the one specified
by short_channel_id in the onion message, so long as the receiver has
the same node public key intended by short_channel_id
([BOLT](57ce4b1e05/04-onion-routing.md (non-strict-forwarding))).
This can improve payment reliability when there are multiple channels
with the same peer e.g. when outbound liquidity is replenished by
opening a new channel.

The implemented forwarding strategy now chooses the channel with the
lowest outbound liquidity that can forward an HTLC to maximize the
probability of being able to successfully forward a subsequent HTLC.

Fixes #1278.
2024-06-19 21:24:21 -07:00
Alec Chen
e8939e26bc Allow toggling specific signing methods in test channel signer 2024-06-17 16:32:06 -07:00
Matt Corallo
07f33800a1
Merge pull request #3102 from tnull/2024-06-rustfmt-fuzz
`rustfmt`: Reformat the `fuzz` dir
2024-06-13 06:56:33 -07:00
Elias Rohrer
3ec0dcdac1
Merge pull request #3078 from jkczyz/2024-05-invoice-event
Asynchronous `Bolt12Invoice` payment
2024-06-13 08:25:59 +02:00
Jeffrey Czyz
a9dcfaf952
Add UserConfig::manually_handle_bolt12_invoices
BOLT12 invoices are automatically paid once they have been verified.
Users may want to manually pay them by first performing additional
checks. Add a manually_handle_bolt12_invoices configuration option that
when set generates an Event::InvoiceReceived instead of paying the
invoice.
2024-06-12 19:38:16 -05:00
Elias Rohrer
4e9ce52c72
rustfmt: fuzz/src/full_stack.rs 2024-06-12 21:53:32 +02:00
Elias Rohrer
945cb77247
Prepare fuzz/src/full_stack.rs for rustfmt 2024-06-12 21:53:32 +02:00
Elias Rohrer
0583f643b9
rustfmt: fuzz/src/chanmon_consistency.rs 2024-06-12 21:53:30 +02:00
Elias Rohrer
7b3e9a82f8
Introduce noret wrappers 2024-06-12 21:53:00 +02:00
Elias Rohrer
f0ec37ec16
Prepare chanmon_consistency.rs for rustfmt 2024-06-12 19:26:59 +02:00
Elias Rohrer
5e3056e988
Merge pull request #3113 from TheBlueMatt/2024-04-async-monitor-fuzz
Fuzz reloading with a stale monitor in chanmon_consistency
2024-06-12 19:20:28 +02:00
Matt Corallo
d5019fc4d8 Fuzz reloading with a stale monitor in chanmon_consistency
Now that we are gearing up to support fully async monitor storage,
we really need to fuzz monitor updates not completing before a
reload, which we do here in the `chanmon_consistency` fuzzer.

While there are more parts to async monitor updating that we need
to fuzz, this at least gets us started by having basic async
restart cases handled. In the future, we should extend this to make
sure some basic properties (eg claim/balance consistency) remain
true through `chanmon_consistency` runs.
2024-06-12 15:32:33 +00:00
Matt Corallo
5a1cc288b7 Force-close channels if their feerate gets stale without any update
For quite some time, LDK has force-closed channels if the peer
sends us a feerate update which is below our `FeeEstimator`'s
concept of a channel lower-bound. This is intended to ensure that
channel feerates are always sufficient to get our commitment
transaction confirmed on-chain if we do need to force-close.

However, we've never checked our channel feerate regularly - if a
peer is offline (or just uninterested in updating the channel
feerate) and the prevailing feerates on-chain go up, we'll simply
ignore it and allow our commitment transaction to sit around with a
feerate too low to get confirmed.

Here we rectify this oversight by force-closing channels with stale
feerates, checking after each block. However, because fee
estimators are often buggy and force-closures piss off users, we
only do so rather conservatively. Specifically, we only force-close
if a channel's feerate is below the minimum `FeeEstimator`-provided
minimum across the last day.

Further, because fee estimators are often especially buggy on
startup (and because peers haven't had a chance to update the
channel feerates yet), we don't force-close channels until we have
a full day of feerate lower-bound history.

This should reduce the incidence of force-closures substantially,
but it is expected this will still increase force-closures somewhat
substantially depending on the users' `FeeEstimator`.

Fixes #993
2024-06-10 15:17:58 +00:00
Matt Corallo
66e6ee563b Skip fee reads in full_stack_target when connecting many blocks
When we connect 100 blocks in a row, requiring the fuzz input to
contain 100 fee estimator results is uneccessary, so add a bool
that lets us skip those reads.
2024-06-10 15:12:50 +00:00
Elias Rohrer
5d0fb36477
rustfmt: src/utils/* 2024-06-07 20:42:36 +02:00
Elias Rohrer
0e7fe0c9aa
rustfmt: fuzz/src/router.rs 2024-06-07 20:42:36 +02:00
Elias Rohrer
64843ae633
rustfmt: fuzz/src/refund_deser.rs 2024-06-07 20:42:36 +02:00
Elias Rohrer
73ebb1bd1b
rustfmt: fuzz/src/process_network_graph.rs 2024-06-07 20:42:36 +02:00
Elias Rohrer
8e1a98183d
rustfmt: fuzz/src/peer_crypt.rs 2024-06-07 20:42:36 +02:00
Elias Rohrer
da99d521b9
rustfmt: fuzz/src/offer_deser.rs 2024-06-07 20:42:27 +02:00
Elias Rohrer
4741731dd3
rustfmt: fuzz/src/offer_deser.rs 2024-06-07 20:41:50 +02:00
Elias Rohrer
b9c52f6941
rustfmt: fuzz/src/msg_targets/* 2024-06-07 20:37:10 +02:00
Elias Rohrer
9db52b69bb
rustfmt: fuzz/src/lib.rs 2024-06-07 20:37:10 +02:00
Elias Rohrer
f1ac0a3d97
rustfmt: fuzz/src/invoice*.rs 2024-06-07 20:37:10 +02:00
Elias Rohrer
9164e835e5
rustfmt: fuzz/src/indexedmap.rs 2024-06-07 20:37:10 +02:00
Elias Rohrer
997e46bde2
rustfmt: fuzz/src/fromstr_to_netaddress.rs 2024-06-07 20:37:09 +02:00
Elias Rohrer
39cc28bfaa
rustfmt: fuzz/src/chanmon_deser.rs 2024-06-07 20:37:09 +02:00
Elias Rohrer
2bcdad779a
rustfmt: fuzz/src/bin/* 2024-06-07 20:37:09 +02:00
Elias Rohrer
c2abfbf5f5
rustfmt: fuzz/src/base32.rs 2024-06-07 20:37:09 +02:00
Elias Rohrer
b1a9410508
Add rustfmt::skip to the target template 2024-06-07 20:37:09 +02:00
Elias Rohrer
fde0d9e718
Add rustfmt::skip to the msg_target template 2024-06-07 20:37:08 +02:00
Jeffrey Czyz
5326171885
Refactor MessageRouter::create_blinded_paths
Using compact blinded paths isn't always necessary or desirable. For
instance, reply paths are communicated via onion messages where space
isn't a premium unlike in QR codes. Additionally, long-lived paths could
become invalid if the channel associated with the SCID is closed.
Refactor MessageRouter::create_blinded_paths into two methods: one for
compact blinded paths and one for normal blinded paths.
2024-06-05 17:52:30 -05:00
Elias Rohrer
15c709d747
Merge pull request #3089 from TheBlueMatt/2024-06-channel_state-module
Move the public channel state API into a new module
2024-06-04 16:28:39 +02:00
Matt Corallo
2d6d5cc86f Move the public path for channel_state types to their new path 2024-06-04 14:21:08 +00:00
Arik
993cd1e525
Merge pull request #2889 from Sharmalm/2840
Allow for user-specified error message during force close channel
2024-06-03 14:48:52 -07:00
Jiri Jakes
a8bd4c097f
Upgrade rust-bitcoin to 0.31 2024-05-30 18:35:29 +08:00
Jeffrey Czyz
e553a71b6f
Pass ForwardNode when creating BlindedPath
Instead of passing Vec<PublicKey> to MessageRouter::crate_blinded_path,
pass Vec<ForwardNode>. This way callers can include a short_channel_id
for a more compact BlindedPath encoding.
2024-05-28 16:35:55 -05:00
Jeffrey Czyz
d792afb08c
Support NextHop::ShortChannelId in BlindedPath
When sending an onion message to a blinded path, the short channel id
between hops isn't need in each hop's encrypted_payload since it is not
a payment. However, using the short channel id instead of the node id
gives a more compact representation. Update BlindedPath::new_for_message
to allow for this.
2024-05-28 16:35:41 -05:00