Commit Graph

853 Commits

Author SHA1 Message Date
Matt Corallo
a91bf02b24 Fix validation of payment success in chanmon_consistency fuzzer
Prior to bcaba29f92, the
`chanmon_consistency` fuzzer checked that payments sent either
succeeded or failed as expected by looking at the `APIError` which
we received as a result of calling the send method.

bcaba29f92 removed the legacy send
method during fuzzing so attempted to replicate the old logic by
checking for events which contained the legacy `APIError` value.
While this was plenty thorough, it was somewhat brittle in that it
made expectations about the event state of a `ChannelManager` which
turned out to not be true.

Instead, here, we validate the send correctness by examining the
`RecentPaymentDetails` list from a `ChannelManager` immediately
after sending.
2024-12-17 15:37:43 +00:00
Matt Corallo
177a6122e6 Correct route construction in chanmon_consistency fuzz
bcaba29f92 started returning
pre-built `Route`s from the router in the `chanmon_consistency`
fuzzer. In doing so, it didn't properly fill in the `route_parms`
field which is expected to match the requested parameters. This
causes a debug assertion when sending.

Here we fix this by setting the correct `route_params`.
2024-12-17 04:14:11 +00:00
Matt Corallo
351d414457 Fix deadlock in chanmon_consistency fuzzer
bcaba29f92 introduced a deadlock in
the `chanmon_consistency` fuzzer by holding a lock on the route
expectations before sending a payment, which ultimately tries to
lock the route expectations. Here we fix this deadlock.
2024-12-17 03:55:03 +00:00
Jeffrey Czyz
55c02fdee1
Include HMAC and Nonce in payment::ReceiveTlvs
In order to authenticate a PaymentContext, an HMAC and Nonce must be
included along with it in payment::ReceiveTlvs. Compute the HMAC when
constructing a BlindedPaymentPath and include it in the recipient's
BlindedPaymentTlvs. Authentication will be added in an upcoming commit.
2024-12-13 09:26:03 -06:00
Jeffrey Czyz
a29153025f
Remove KeyMaterial
Now that NodeSigner::get_inbound_payment_key returns an ExpandedKey
instead of KeyMaterial, the latter is no longer needed. Remove
KeyMaterial and replace its uses with [u8; 32].
2024-12-13 09:26:02 -06:00
Jeffrey Czyz
09bec6eee9
Return ExpandedKey from NodeSigner
NodeSinger::get_inbound_payment_key_material returns KeyMaterial, which
is used for constructing an ExpandedKey. Change the trait to return an
ExpandedKey directly instead. This allows for direct access to the
ExpandedKey when a NodeSigner referenced is available. Otherwise, it
would either need to be reconstructed or passed in separately.
2024-12-13 09:25:56 -06:00
Valentine Wallace
bcaba29f92
Remove deprecated send_payment_with_route usage from fuzzing
This allows us to make the PaymentSendFailure error type private, as well as
reduce the visibility of the vestigial send_payment_with_route method that was
already made test and fuzz-only in a previous commit.
2024-12-10 15:24:23 -05:00
Valentine Wallace
2286191239
Fix full_stack fuzz target
2e685ffb24 removed a field from UserConfig, which
broke this fuzz target. The hardcoded strings needed to be updated to remove
this field from them too.
2024-12-05 16:17:03 -05:00
Matt Corallo
70add1448b
Merge pull request #3264 from jkczyz/2024-08-remove-user-provided-payer-id
Disallow user-provided `payer_signing_pubkey`
2024-11-12 20:23:45 +00:00
Matt Corallo
8d8416b956 Store the source HumanReadableName in InvoiceRequestFields
When we receive a payment to an offer we issued resolved with a
human readable name, it may have been resolved using a wildcard
DNS entry which we want to map to a specific recipient account
locally. To do this, we need the human readable name from the
`InvoiceRequest` in the `PaymentClaim{able,ed}`, which we pipe
through here using `InvoiceRequestFields`.
2024-11-12 15:53:12 +00:00
Jeffrey Czyz
c331b67137
Remove NodeSigner::sign_bolt12_invoice_request
Now that invoice requests are signed using transient keys only, remove
the corresponding signing method from NodeSigner since it is never used.
2024-11-11 16:18:11 -06:00
Jeffrey Czyz
d596b4e635
Disallow user-provided payer_signing_pubkey
When creating an InvoiceRequests, users may choose to either use a
transient signing pubkey generated by LDK or provide a static one.
Disallow the latter as it allows users to reuse the same pubkey, which
results in poor sender privacy.
2024-11-11 16:18:11 -06:00
Elias Rohrer
d13c2bd829
Update fuzz README to account for additional required RUSTFLAGS 2024-11-06 14:27:26 +01:00
Matt Corallo
a130bd69de
Merge pull request #3207 from valentinewallace/2024-07-invreq-in-onion
Include invoice requests in async payment onions
2024-11-01 14:52:03 +00:00
Valentine Wallace
2ff6524da4
Prefix AsyncPaymentsMessageHandler methods with handle_*
"Release" is overloaded in the trait's release_pending_messages method, since
the latter releases pending async payments onion messages to the peer manager,
vs the release_held_htlc method handles the release_held_htlc onion message by
attempting to send an HTLC to the recipient.
2024-10-30 16:14:03 -04:00
Matt Corallo
6c203d803e Stop relying on ChannelMonitor persistence after manager read
When we discover we've only partially claimed an MPP HTLC during
`ChannelManager` reading, we need to add the payment preimage to
all other `ChannelMonitor`s that were a part of the payment.

We previously did this with a direct call on the `ChannelMonitor`,
requiring users write the full `ChannelMonitor` to disk to ensure
that updated information made it.

This adds quite a bit of delay during initial startup - fully
resilvering each `ChannelMonitor` just to handle this one case is
incredibly excessive.

Over the past few commits we dropped the need to pass HTLCs
directly to the `ChannelMonitor`s using the background events to
provide `ChannelMonitorUpdate`s insetad.

Thus, here we finally drop the requirement to resilver
`ChannelMonitor`s on startup.
2024-10-24 17:44:33 +00:00
Valentine Wallace
cdc0c3b581
Fix unused warning in fuzz. 2024-10-24 10:37:26 -07:00
Matt Corallo
50b5a6efa7 Drop the Payment{Hash,Preimage,Secret} re-exports in lightning
These re-exports were deprecated in 0.0.124 in favor of the
`lightning::types::payment::*` paths, which we use here.
2024-10-15 14:33:03 +00:00
Matt Corallo
64c12431b7 Drop lightning::ln::features::* type aliases
These were deprecated in 0.0.124, and we drop them here in favor of
`lightning::types::features::*`.
2024-10-13 13:52:56 +00:00
Matt Corallo
bc1931bd0b
Merge pull request #3270 from optout21/bech32-iterser
Upgrade bech32 dependency (iterative)
2024-10-03 17:02:55 +00:00
optout
aa2f6b47df
Upgrade bech32 dependency, bech32 serialization improvements 2024-10-02 21:21:07 +02:00
Matt Corallo
ebde296abd Parse and handle DNSResolverMessages in OnionMessenger
This adds the requisite message parsing and handling code for the
new DNSSEC messages to `OnionMessenger`.
2024-09-30 16:19:33 +00:00
Elias Rohrer
a0d0f02ed0
Merge pull request #3303 from TheBlueMatt/2024-09-inbound-payment-id
Add a `PaymentId` for inbound payments
2024-09-24 13:38:16 +09:00
Jeffrey Czyz
04c51b380d
Parameterize ChannelManager with MessageRouter
ChannelManager is parameterized by a Router, which must also implement
MessageRouter. Instead, add a MessageRouter parameter such that the
Router and MessageRouter traits can be de-coupled. This simplifies using
something other than DefaultMessageRouter, which DefaultRouter currently
delegates to.
2024-09-23 12:21:35 +09:00
Matt Corallo
aa09c33a17 Add an inbound_payment_id_secret to ChannelManager
In the next commit we'll start generating `PaymentId`s for inbound
payments randomly by HMAC'ing the HTLC set of the payment. Here we
start by defining the HMAC secret for these HMACs.

This requires one small test adaptation and a full_stack_target
fuzz change because it changes the RNG consumption.
2024-09-23 01:24:28 +00:00
Matt Corallo
cdd1298a38
Merge pull request #3289 from tnull/2024-09-fix-rgs-bp-builds
Fix builds of `lightning-rapid-gossip-sync` and `lightning-background-processor` crates
2024-09-18 14:31:18 +00:00
Elias Rohrer
545b037827
Drop no-std feature
We drop the `lightning/no-std` feature and just take
`hashbrown`,`possiblyrandom` and `libm` as required dependencies.
2024-09-18 09:07:58 +02:00
Jeffrey Czyz
dd8f744257
Rename InvoiceRequest::payer_id
For consistency with Offer::issuer_signing_pubkey, rename
InvoiceRequest::payer_id to use "signing_pubkey" instead of "id".
2024-09-16 13:56:46 -05:00
Matt Corallo
22146a98df
Merge pull request #3140 from valentinewallace/2024-06-pay-static-invoice
Support paying static invoices
2024-09-15 16:58:46 +00:00
Valentine Wallace
6e27aecb40
Remove payment_release_secret from async payments messages.
This field isn't necessary because we already authenticate the messages via the
blinded reply paths payment_id, nonce and HMAC.
2024-09-13 10:40:06 -04:00
Matt Corallo
f7cc40e2e4
Merge pull request #3243 from dunxen/2024-08-reremove-balancemsat
Remove AvailableBalances::balance_msat
2024-09-13 14:09:17 +00:00
Valentine Wallace
e162278bc8
Pass context into held_htlc_available message handling.
Useful for using the payment_id within to look up the corresponding outbound
async payment so we know we can safely release the HTLCs to the now-onlinen
recipient.
2024-09-12 11:16:03 -04:00
Elias Rohrer
b172942a75
Refactor: Take their_node_id by value across all handler interfaces
In order to maintain interface consistency, we refactor all message
handler interfaces to take `PublicKey` rather than `&PublicKey`, as the
difference in efficiency should be negigible and the former is easier to
handle in binding languages.

Over time, we also want to move (no pun intended) towards all messaging
interfaces using move semantics, so dropping the reference for
`PublicKey` is the first step in this direction.
2024-09-11 19:19:38 +02:00
Duncan Dean
59f16896d6
Remove AvailableBalances::balance_msat
The ChannelMonitor::get_claimable_balances and ChainMonitor::get_claimable_balances
methods provide a more straightforward approach to the balance of a channel, which
satisfies most use cases. The computation of AvailableBalances::balance_msat is
complex and originally had a different purpose that is not applicable
anymore.

Co-authored-by: Willem Van Lint <noreply@wvanlint.dev>
2024-09-09 19:37:03 +02:00
Matt Corallo
caf0daa2dd
Merge pull request #3257 from tnull/2024-08-fix-is-public
Rename instances of `is_public` to `is_announced`
2024-08-29 19:39:30 +00:00
Elias Rohrer
5928063789
Rename announced_channel to is_announced_for_forwarding
.. we rename the flag configuring whether we announce a channel or not.
2024-08-29 21:22:22 +02:00
Matt Corallo
b7064808ac
Merge pull request #3268 from TheBlueMatt/2024-08-moar-feerate-categories
Split up `ConfirmationTarget` even more
2024-08-28 13:15:13 +00:00
Matt Corallo
14720190b0 Split ConfirmationTarget::OnChainSweep into urgent and non-urgent
When we force-close a channel, occasionally its due to feerate
disagreements or other non-HTLC-related issues. In those cases,
there's no reason to use a very urgent feerate estimate - we don't
have any timers expiring soon.

Instead, we should give users the information they need to be more
economical on fees in this case, which we do here by splitting
`OnChainSweep` into `UrgentOnChainSweep` and
`NonUrgentOnChainSweep` `ConfirmationTarget`s.
2024-08-27 16:42:03 +00:00
Matt Corallo
f0de37ae1f Add a new ConfirmationTarget::MaximumFeeEstimate
When we broke `ConfirmationTarget` out into task-specific names, we
left `MaxDustHTLCExposure::FeeRateMultiplier` as using the "when we
broadcast feerate" as we were mostly concerned about the dust
thresholds on outbound channels where we pick the fee and drive our
own funds to dust.

In 51bf78d604, that changed to
include transaction fees on both inbound and outbound channels in
our dust exposure amount, but we continued to use
`ConfirmationTarget::OnChainSweep` for the fee estimator threshold.

While the `MaxDustHTLCExposure::FeeRateMultiplier` value is quite
conservative and shouldn't lead to force-closures unless feerate
estimates disagree by something like 500 sat/vB (with only one HTLC
active in a channel), this happened on Aug 22 when feerates spiked
from 4 sat/vB to over 1000 sat/vB in one block.

To avoid simple feerate estimate horizons causing this in the
future, here we add a new
`ConfirmationTarget::MaximumFeeEstimate` which is used for dust
calculations. This allows users to split out the estimates they use
for checking counterparty feerates from the estimates used for
actual broadcasting.
2024-08-27 16:36:54 +00:00
Matt Corallo
49dfa5a496
Merge pull request #3263 from TheBlueMatt/2024-08-bindings-om
Remove message type bound on `ResponseInstruction`
2024-08-23 03:04:19 +00:00
Matt Corallo
90361c18bf 1/3 Use MessageSendInstructions instead of PendingOnionMessage
Now that the `MessageRouter` can `create_blinded_paths` forcing
callers of the `OnionMessenger` to provide it with a reply path up
front is unnecessary complexity, doubly so in message handlers.

Here we take the first step towards untangling that, moving from
`PendingOnionMessage` to `MessageSendInstructions` for the outbound
message queue in `CustomMessageHandler`. Better, we can also drop
the `c_bindings`-specific message queue variant, unifying the APIs.
2024-08-22 22:27:44 +00:00
Matt Corallo
cd93a41bd6 Remove message type bound on ResponseInstruction
Our onion message handlers generally have one or more methods which
return a `ResponseInstruction` parameterized with the expected
message type (enum) of the message handler.

Sadly, that restriction is impossible to represent in our bindings -
our bindings concretize all LDK structs, enums, and traits into a
single concrete instance with generics set to our concrete trait
instances (which hold a jump table). This prevents us from having
multiple instances of `ResponseInstruction` structs for different
message types.

Our bindings do, however, support different parameterizations of
standard enums, including `Option`s and tuples.

In order to support bindings for the onion message handlers, we
are thus forced into std types bound by expected message types,
which we do here by making `ResponseInstruction` contain only the
instructions and generally using it as a two-tuple of
`(message, ResponseInstruction)`.
2024-08-22 22:17:54 +00:00
Matt Corallo
2ce2fe9392 Disambiguate blinded path ForwardNodes between payment + message
We currently have two structs with identical names in our public
API - `blinded_path::message::ForwardNode` and
`blinded_path::payment::ForwardNode`. This makes the API somewhat
awkward to use - users have to try (and fail) to import
`ForwardNode` twice only to then have to change their imports.

More importantly, however, this makes the API very hard to use in
some bindings languages where rename-imports or module imports
aren't available.

Thus, here, we rename both to give them context.
2024-08-21 19:48:34 +00:00
Elias Rohrer
b3abb192cc
Rename ChannelDetails::is_public to is_announced
Referring to announced/unannounced channels as 'public'/'private'
regularly leads to confusion on what they are and when which should be
used. To avoid perpetuating this confusion, we should avoid referring to
announced channels as 'public' in our API.

Here we rename `ChannelDetails::is_public` (which breaks
previously-released API) to align it with the changes in
`OpenChannelRequest`.
2024-08-21 12:40:21 +02:00
Valentine Wallace
db94d930f0
Move BlindedPayInfo into blinded_path::payment module. 2024-08-19 16:42:22 -04:00
Valentine Wallace
7038906890
Move BlindedPayInfo into BlindedPaymentPath.
Also removes the implementation of Writeable for BlindedPaymentPath, to ensure
callsites are explicit about what they're writing.
2024-08-19 16:28:30 -04:00
Matt Corallo
fb4403f8ae
Merge pull request #3204 from valentinewallace/2024-07-rb-test-vectors
Implement route blinding test vectors
2024-08-19 19:57:04 +00:00
Valentine Wallace
6f6115f177
Avoid && in public API for onion peeling/decoding.
No reason to take a reference to a Deref.
2024-08-19 12:47:42 -04:00
Valentine Wallace
f68b1249a9
Support next_blinding_override in blinded payment paths.
This allow us to forward blinded payments where the blinded path that we are
forwarding within was concatenated to another blinded path that starts at the
next hop.

Also allows constructing blinded paths using this override.
2024-08-19 12:47:40 -04:00
Matt Corallo
43dcf2f3d8
Merge pull request #3239 from arik-so/bitcoin-0.32.2-upgrade
Bitcoin 0.32.2 upgrade
2024-08-16 20:13:26 +00:00