Commit Graph

8094 Commits

Author SHA1 Message Date
Vincenzo Palazzo
c2c670b2b5
rename pay_parameters for no amount invoice
This commit renames the function `pay_parameters_for_zero_amount_invoice`
to `pay_parameters_for_variable_amount_invoice`.

The term "variable amount" is used to align with
the naming convention in the LDK node, helping to avoid
confusion between similar packages.

Fixes: https://github.com/lightningdevkit/rust-lightning/issues/2879
Replaces: https://github.com/lightningdevkit/rust-lightning/pull/2979
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2024-11-06 11:08:25 +01:00
valentinewallace
76a93a334b
Merge pull request #3360 from TheBlueMatt/2024-10-rebroadcast-chan-announcements
Re-broadcast `channel_announcement`s every six blocks for a week
2024-11-04 11:11:43 -05: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
Jeffrey Czyz
ef0f35a7b1
Merge pull request #3393 from tnull/2024-11-drop-dead-code
Drop dead code from `provide_latest_counterparty_commitment_tx`
2024-11-01 09:48:23 -05:00
Elias Rohrer
468588f2ff
Drop dead code from provide_latest_counterparty_commitment_tx
We drop some dead code that unnecessarily allocates a `Vec` but does
nothing else.
2024-11-01 10:26:46 +01:00
Valentine Wallace
240dd0a960
Fix outdated comment on PendingOutboundPayment::StaticInvoiceReceived 2024-10-30 16:18:03 -04:00
Valentine Wallace
34e710edd1
Factor invoice requests into payment path length limiting
Async payments include the original invoice request in the payment onion.
Since invreqs may include blinded paths, it's important to factor them into our
max path length calculations since they may take up a significant portion of
the 1300-byte onion.
2024-10-30 16:17:59 -04:00
Valentine Wallace
d574de95f5
Include invreq in payment onion when retrying async payments
While in the last commit we began including invoice requests in async payment
onions on initial send, further work is needed to include them on retry. Here
we begin storing invreqs in our retry data, and pass them along for inclusion
in the onion on payment retry.

Per BOLTs PR 1149, when paying a static invoice we need to include our original
invoice request in the HTLC onion since the recipient wouldn't have received it
previously.
2024-10-30 16:17:57 -04:00
Valentine Wallace
925a0cb38b
Include invreq in payment onion when sending async payments
Past commits have set us up to include invoice requests in outbound async
payment onions. Here we actually pull the invoice request from where it's
stored in outbound_payments and pass it into the correct utility for inclusion
in the onion on initial send.

Per BOLTs PR 1149, when paying a static invoice we need to include our original
invoice request in the HTLC onion since the recipient wouldn't have received it
previously.
2024-10-30 16:17:55 -04:00
Valentine Wallace
520ae0b1f4
Store invreqs in StaticInvoiceReceived outbound payments
When transitioning outbound payments from AwaitingInvoice to
StaticInvoiceReceived, include the invreq in the new state's outbound payment
storage for future inclusion in an async payment onion.

Per BOLTs PR 1149, when paying a static invoice we need to include our original
invoice request in the HTLC onion since the recipient wouldn't have received it
previously.
2024-10-30 16:17:51 -04:00
Valentine Wallace
fead88faed
Support including invreqs when paying to a route
Add a new invoice request parameter to outbound_payments and channelmanager
send-to-route internal utils. As of this commit the invreq will always be
passed in as None, to be updated in future commits.

Per BOLTs PR 1149, when paying a static invoice we need to include our original
invoice request in the HTLC onion since the recipient wouldn't have received it
previously.
2024-10-30 16:17:41 -04:00
Valentine Wallace
6a424536ac
Support including invreqs when building payment onions
Add a new invoice request parameter to onion_utils::create_payment_onion. As of
this commit it will always be passed in as None, to be updated in future
commits.

Per BOLTs PR 1149, when paying a static invoice we need to include our original
invoice request in the HTLC onion since the recipient wouldn't have received it
previously.
2024-10-30 16:17:32 -04:00
Valentine Wallace
9b3e30707e
Support including invreqs when building onion payloads
Add a new invoice request parameter to onion_utils::build_onion_payloads.
As of this commit it will always be passed in as None, to be updated in future
commits.

Per BOLTs PR 1149, when paying a static invoice we need to include our original
invoice request in the HTLC onion since the recipient wouldn't have received it
previously.
2024-10-30 16:17:20 -04:00
Valentine Wallace
a80af56af7
Support encoding invreqs in outbound onion payloads
Per BOLTs PR 1149, when paying a static invoice we need to include our original
invoice request in the HTLC onion since the recipient wouldn't have received it
previously.

We use an experimental TLV type for this new onion payload field, since the
spec is still not merged in the BOLTs.
2024-10-30 16:17:12 -04:00
Valentine Wallace
639446ad63
Stop taking &self in outbound_payments' create_inbound_payment
The method doesn't actually use its &self parameter, and this makes it more
obvious that we aren't going to deadlock by calling the method if the
outbound_payments lock is already acquired.
2024-10-30 16:14:03 -04: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
Valentine Wallace
88d689a323
Update docs for PaymentFailureReason::RouteNotFound
Since we started using this error in send_payment_for_bolt12_invoice, this
error type is no longer only used on retry but also on initial send.
2024-10-30 16:13:59 -04:00
Valentine Wallace
3945bf86f9
Add new PaymentFailureReason::BlindedPathCreationFailed
RouteNotFound did not fit here because that error is reserved for failing to
find a route for a payment, whereas here we are failing to create a blinded
path back to ourselves..
2024-10-30 16:13:56 -04:00
Matt Corallo
948f1794a2 Re-broadcast channel_announcements every six blocks for a week
When we first get a public channel confirmed at six blocks, we
broadcast a `channel_announcement` once and then move on. As long
as it makes it into our local network graph that should be okay, as
we should send peers our network graph contents as they seek to
sync, however its possible an ill-timed shutdown could cause this
to fail, and relying on peers to do a full historical sync from us
may delay `channel_announcement` propagation.

Instead, here, we re-broadcast our `channel_announcement`s every
six blocks for a week, which should be way more than robust enough
to get them properly across the P2P network.

Fixes #2418
2024-10-29 17:53:11 +00:00
Matt Corallo
299b7bd714
Merge pull request #3367 from TheBlueMatt/2024-10-dense-counters
Don't bump the `next_node_counter` when using a removed counter
2024-10-29 17:48:57 +00:00
Matt Corallo
9e1853f9c8
Merge pull request #3380 from optout21/channel-funding-tx-simple
[Splicing] Preserve funding_transaction for the later lifecycle of the channel, simple solution
2024-10-29 14:57:17 +00:00
optout
5577a88ac0
Preserve funding_transaction for the later lifecycle of the channel, simple solution 2024-10-28 22:29:47 +01:00
Matt Corallo
bba3071cea
Merge pull request #3385 from arik-so/gossip-filter-event-send-logging
Log enqueueing of gossip messages
2024-10-28 14:10:18 +00:00
Matt Corallo
5c975f701a
Merge pull request #3322 from TheBlueMatt/2024-06-mpp-claim-without-man
Stop relying on ChannelMonitor persistence after manager read
2024-10-28 14:08:32 +00:00
Arik Sosman
0a8c05f8ba
Log enqueueing of gossip messages 2024-10-25 16:57:27 -07:00
Matt Corallo
ba264323f8 Doc the on-upgrade ChannelMonitor startup persistence semantics
Because the new startup `ChannelMonitor` persistence semantics rely
on new information stored in `ChannelMonitor` only for claims made
in the upgraded code, users upgrading from previous version of LDK
must apply the old `ChannelMonitor` persistence semantics at least
once (as the old code will be used to handle partial claims).
2024-10-24 17:44:33 +00: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
Matt Corallo
4896e20086 Replay MPP claims via background events using new CM metadata
When we claim an MPP payment, then crash before persisting all the
relevant `ChannelMonitor`s, we rely on the payment data being
available in the `ChannelManager` on restart to re-claim any parts
that haven't yet been claimed. This is fine as long as the
`ChannelManager` was persisted before the `PaymentClaimable` event
was processed, which is generally the case in our
`lightning-background-processor`, but may not be in other cases or
in a somewhat rare race.

In order to fix this, we need to track where all the MPP parts of
a payment are in the `ChannelMonitor`, allowing us to re-claim any
missing pieces without reference to any `ChannelManager` data.

Further, in order to properly generate a `PaymentClaimed` event
against the re-started claim, we have to store various payment
metadata with the HTLC list as well.

Here we finally implement claiming using the new MPP part list and
metadata stored in `ChannelMonitor`s. In doing so, we use much more
of the existing HTLC-claiming pipeline in `ChannelManager`,
utilizing the on-startup background events flow as well as properly
re-applying the RAA-blockers to ensure preimages cannot be lost.
2024-10-24 17:44:33 +00:00
Matt Corallo
254b78fd35 Handle duplicate payment claims during initialization
In the next commit we'll start using (much of) the normal HTLC
claim pipeline to replay payment claims on startup. In order to do
so, however, we have to properly handle cases where we get a
`DuplicateClaim` back from the channel for an inbound-payment HTLC.

Here we do so, handling the `MonitorUpdateCompletionAction` and
allowing an already-completed RAA blocker.
2024-10-24 17:44:33 +00:00
Matt Corallo
17cf179e75 Move payment claim initialization to an fn on ClaimablePayments
Here we wrap the logic which moves claimable payments from
`claimable_payments` to `pending_claiming_payments` to a new
utility function on `ClaimablePayments`. This will allow us to call
this new logic during `ChannelManager` deserialization in a few
commits.
2024-10-24 17:44:33 +00:00
Matt Corallo
a26033f0cb Move ChannelManager-read preimage relay to after struct build
In a coming commit we'll use the existing `ChannelManager` claim
flow to claim HTLCs which we found partially claimed on startup,
necessitating having a full `ChannelManager` when we go to do so.

Here we move the re-claim logic down in the `ChannelManager`-read
logic so that we have that.
2024-10-24 17:44:33 +00:00
Matt Corallo
7790e30880 Store info about claimed payments, incl HTLCs in ChannelMonitors
When we claim an MPP payment, then crash before persisting all the
relevant `ChannelMonitor`s, we rely on the payment data being
available in the `ChannelManager` on restart to re-claim any parts
that haven't yet been claimed. This is fine as long as the
`ChannelManager` was persisted before the `PaymentClaimable` event
was processed, which is generally the case in our
`lightning-background-processor`, but may not be in other cases or
in a somewhat rare race.

In order to fix this, we need to track where all the MPP parts of
a payment are in the `ChannelMonitor`, allowing us to re-claim any
missing pieces without reference to any `ChannelManager` data.

Further, in order to properly generate a `PaymentClaimed` event
against the re-started claim, we have to store various payment
metadata with the HTLC list as well.

Here we store the required MPP parts and metadata in
`ChannelMonitor`s and make them available to `ChannelManager` on
load.
2024-10-24 17:44:33 +00:00
Matt Corallo
b8661ef6cf Pass info about claimed payments, incl HTLCs to ChannelMonitors
When we claim an MPP payment, then crash before persisting all the
relevant `ChannelMonitor`s, we rely on the payment data being
available in the `ChannelManager` on restart to re-claim any parts
that haven't yet been claimed. This is fine as long as the
`ChannelManager` was persisted before the `PaymentClaimable` event
was processed, which is generally the case in our
`lightning-background-processor`, but may not be in other cases or
in a somewhat rare race.

In order to fix this, we need to track where all the MPP parts of
a payment are in the `ChannelMonitor`, allowing us to re-claim any
missing pieces without reference to any `ChannelManager` data.

Further, in order to properly generate a `PaymentClaimed` event
against the re-started claim, we have to store various payment
metadata with the HTLC list as well.

Here we take the first step, building a list of MPP parts and
metadata in `ChannelManager` and passing it through to
`ChannelMonitor` in the `ChannelMonitorUpdate`s.
2024-10-24 17:44:33 +00:00
Matt Corallo
d9175f454b Use a struct to track MPP parts pending claiming
When we started tracking which channels had MPP parts claimed
durably on-disk in their `ChannelMonitor`, we did so with a tuple.
This was fine in that it was only ever accessed in two places, but
as we will start tracking it through to the `ChannelMonitor`s
themselves in the coming commit(s), it is useful to have it in a
struct instead.
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
206ab82c02
Merge pull request #3007 from arik-so/arik/trampoline/2024-04-trampoline-blinded-hop-serialization
Serialize blinded Trampoline hops
2024-10-23 21:52:10 +00:00
Arik Sosman
d111981e13
Test non-legacy blinded Trampoline payloads. 2024-10-23 13:06:35 -07:00
Arik Sosman
9c9a31cd35
Add non-legacy blinded Trampoline payloads. 2024-10-23 13:06:35 -07:00
Arik Sosman
f6b3004659
Test blinded Trampoline payload serialization. 2024-10-23 13:06:35 -07:00
Arik Sosman
477216e7b1
Serialize blinded path forwards in Trampoline onions. 2024-10-23 13:06:35 -07:00
Matt Corallo
a65d37b48b Add missing inbound_payment_id_secret write in ChannelManager
In aa09c33a17 we added a new secret
in `ChannelManager` with which to derive inbound `PaymentId`s. We
added read support for the new field, but forgot to add writing
support for it. Here we fix this oversight.
2024-10-23 16:15:01 +00:00
Matt Corallo
4741653f76 Allow clippy::unwrap-or-default because its usually wrong
`or_default` is generally less readable than writing out the thing
we're writing, as `Default` is opaque but explicit constructors
generally are not. Thus, we ignore the clippy lint (ideally we
could invert it and ban the use of `Default` in the crate entirely
but alas).
2024-10-23 16:15:00 +00:00
Matt Corallo
e0838be5e4
Merge pull request #3379 from arik-so/exclude-windows-msrv
Skip MSRV on Windows in CI
2024-10-23 13:53:18 +00:00
Matt Corallo
3c868dd311
Merge pull request #3142 from TheBlueMatt/2024-06-robust-updates
Reliably deliver gossip messages from our `ChannelMessageHandler`
2024-10-23 00:12:03 +00:00
Arik Sosman
3d50b1d83b
Skip MSRV on Windows in CI 2024-10-22 13:09:24 -07:00
Matt Corallo
b2bcfca30e
Merge pull request #3376 from yellowred/yellowred/monitor_update_name_pub
Make monitor update name public
2024-10-22 17:13:05 +00:00
olegkubrakov
01529dcba6 Make monitor update name public
These structs are meant for MonitoringUpdatingPersister implementation, but some
external implementations may still reuse them, so going to make them public.
2024-10-22 10:03:51 -07:00
Matt Corallo
6104eb0c6e
Merge pull request #3377 from G8XSU/hex-impls
Implement to_lower_hex() Display/Debug for PaymentId & OfferId
2024-10-22 13:55:34 +00:00
Gursharan Singh
66e445811b
Merge pull request #3267 from arik-so/rgs_metrics_2024-08
Update RGS stats for August 2024.
2024-10-21 16:15:43 -07:00
G8XSU
2e118415e0
Implement to_lower_hex() Display/Debug for OfferId. 2024-10-21 15:41:42 -07:00