]> git.bitcoin.ninja Git - rust-lightning/log
rust-lightning
13 days agoMerge pull request #3395 from mhrheaume/mhr/process_events_docs
Matt Corallo [Thu, 7 Nov 2024 17:54:03 +0000 (17:54 +0000)]
Merge pull request #3395 from mhrheaume/mhr/process_events_docs

Updated docs on `PeerManager::process_events`.

2 weeks agoMerge pull request #3388 from TheBlueMatt/2024-10-counter-test
Elias Rohrer [Thu, 7 Nov 2024 10:07:32 +0000 (11:07 +0100)]
Merge pull request #3388 from TheBlueMatt/2024-10-counter-test

Add additional test coverage of `NetworkGraph` counters

2 weeks agoMerge pull request #3401 from tnull/2024-11-update-fuzz-readme
Jeffrey Czyz [Wed, 6 Nov 2024 16:07:53 +0000 (10:07 -0600)]
Merge pull request #3401 from tnull/2024-11-update-fuzz-readme

Update `fuzz` README to account for additional required `RUSTFLAGS`

2 weeks agoUpdate `fuzz` README to account for additional required `RUSTFLAGS`
Elias Rohrer [Wed, 6 Nov 2024 13:27:26 +0000 (14:27 +0100)]
Update `fuzz` README to account for additional required `RUSTFLAGS`

2 weeks agoUpdated docs on `PeerManager::process_events`.
Matthew Rheaume [Tue, 5 Nov 2024 00:11:37 +0000 (16:11 -0800)]
Updated docs on `PeerManager::process_events`.

Try to make it a bit more clear that there are downsides to solely
relying on `lightning-net-tokio`, and it's still recommended to
occasionally call this function in a separate loop.

2 weeks agoMerge pull request #3398 from vincenzopalazzo/macros/fixing-ci
Matt Corallo [Tue, 5 Nov 2024 17:49:27 +0000 (17:49 +0000)]
Merge pull request #3398 from vincenzopalazzo/macros/fixing-ci

ci: fixing the coverage report

2 weeks agoMerge pull request #3394 from tnull/2024-11-pin-idna-adapter
Matt Corallo [Tue, 5 Nov 2024 17:45:18 +0000 (17:45 +0000)]
Merge pull request #3394 from tnull/2024-11-pin-idna-adapter

Pin `idna_adapter` to fix MSRV

2 weeks agoMerge pull request #3237 from jkczyz/2024-08-offers-experimental-tlvs
Jeffrey Czyz [Tue, 5 Nov 2024 17:37:02 +0000 (11:37 -0600)]
Merge pull request #3237 from jkczyz/2024-08-offers-experimental-tlvs

Experimental offer TLVs

2 weeks agoci: fixing the coverage report
Vincenzo Palazzo [Tue, 5 Nov 2024 14:26:27 +0000 (15:26 +0100)]
ci: fixing the coverage report

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2 weeks agoRefactor tuple serialization into a macro
Jeffrey Czyz [Mon, 21 Oct 2024 19:43:12 +0000 (14:43 -0500)]
Refactor tuple serialization into a macro

2 weeks agoAdd parsing tests for experimental invoice TLVs
Jeffrey Czyz [Tue, 13 Aug 2024 22:32:28 +0000 (17:32 -0500)]
Add parsing tests for experimental invoice TLVs

2 weeks agoParse experimental invoice TLV records
Jeffrey Czyz [Mon, 12 Aug 2024 21:54:55 +0000 (16:54 -0500)]
Parse experimental invoice TLV records

The BOLT12 spec defines an experimental TLV range that is allowed in
offer and invoice_request messages. The remaining TLV-space is for
experimental use in invoice messages. Allow this range when parsing an
invoice and include it when signing one.

2 weeks agoAdd parsing tests for experimental refund TLVs
Jeffrey Czyz [Thu, 24 Oct 2024 20:35:25 +0000 (15:35 -0500)]
Add parsing tests for experimental refund TLVs

2 weeks agoAdd parsing tests for experimental invreq TLVs
Jeffrey Czyz [Fri, 9 Aug 2024 23:05:20 +0000 (18:05 -0500)]
Add parsing tests for experimental invreq TLVs

2 weeks agoTest verification with experimental invreq TLVs
Jeffrey Czyz [Thu, 8 Aug 2024 21:50:26 +0000 (16:50 -0500)]
Test verification with experimental invreq TLVs

Payer metadata is generated from the invreq TLVs and should included
those in the experimental range. When verifying invoice messages, these
TLVs must be included. Modify the BOLT12 verification tests to cover
them.

2 weeks agoParse experimental invreq TLV records
Jeffrey Czyz [Thu, 8 Aug 2024 16:44:03 +0000 (11:44 -0500)]
Parse experimental invreq TLV records

The BOLT12 spec defines an experimental TLV range that are allowed in
invoice_request messages. Allow this range when parsing an invoice
request and include those bytes in any invoice. Also include those bytes
when verifying that a Bolt12Invoice is for a valid InvoiceRequest.

2 weeks agoAdd offer test vectors for experimental TLVs
Jeffrey Czyz [Wed, 7 Aug 2024 23:10:43 +0000 (18:10 -0500)]
Add offer test vectors for experimental TLVs

2 weeks agoAdd parsing tests for experimental offer TLVs
Jeffrey Czyz [Tue, 6 Aug 2024 16:22:19 +0000 (11:22 -0500)]
Add parsing tests for experimental offer TLVs

2 weeks agoTest verification with experimental offer TLVs
Jeffrey Czyz [Tue, 6 Aug 2024 21:21:32 +0000 (16:21 -0500)]
Test verification with experimental offer TLVs

Offer metadata is generated from the offer TLVs and should included
those in the experimental range. When verifying invoice request and
invoice messages, these TLVs must be included. Similarly, OfferId
construction should included these TLVs as well. Modify the BOLT12
verification tests to cover these TLVs.

2 weeks agoParse experimental offer TLV records
Jeffrey Czyz [Mon, 5 Aug 2024 23:51:32 +0000 (18:51 -0500)]
Parse experimental offer TLV records

The BOLT12 spec defines an experimental TLV range that are allowed in
offer messages. Allow this range when parsing an offer and include those
bytes in any invoice requests. Also include those bytes when computing
an OfferId and verifying that an InvoiceRequest is for a valid Offer.

2 weeks agoRemove unnecessary destructure
Jeffrey Czyz [Mon, 21 Oct 2024 17:15:24 +0000 (12:15 -0500)]
Remove unnecessary destructure

2 weeks agoInclude experimental TLV records when verifying
Jeffrey Czyz [Thu, 17 Oct 2024 22:51:54 +0000 (17:51 -0500)]
Include experimental TLV records when verifying

Upcoming commits will allow parsing BOLT12 messages that include TLV
records in the experimental range. Include these ranges when verifying
messages since they will be included in the message bytes.

2 weeks agoPass bytes instead of TlvStream to verify
Jeffrey Czyz [Mon, 16 Sep 2024 21:31:01 +0000 (16:31 -0500)]
Pass bytes instead of TlvStream to verify

Passing bytes directly to InvoiceContents::verify improves readability
as then a TlvStream for each TLV record range can be created from the
bytes instead of needing to clone the TlvStream upfront. In an upcoming
commit, the experimental TLV record range will utilize this.

2 weeks agoFunction for iterating over Offer TLV records
Jeffrey Czyz [Mon, 16 Sep 2024 21:07:54 +0000 (16:07 -0500)]
Function for iterating over Offer TLV records

Add a utility function for iterating over Offer TLV records contained in
any valid TLV stream bytes. Using a common function ensures that
experimental TLV records are included once they are supported.

2 weeks agoSeparate bytes for experimental TLVs
Jeffrey Czyz [Fri, 9 Aug 2024 23:36:24 +0000 (18:36 -0500)]
Separate bytes for experimental TLVs

When constructing UnsignedInvoiceRequest or UnsignedBolt12Invoice, use a
separate field for experimental TLV bytes. This allows for properly
inserting the signature TLVs before the experimental TLVs when signing.

2 weeks agof Move pin to right place
Elias Rohrer [Mon, 4 Nov 2024 17:10:20 +0000 (18:10 +0100)]
f Move pin to right place

2 weeks agoMerge pull request #3360 from TheBlueMatt/2024-10-rebroadcast-chan-announcements
valentinewallace [Mon, 4 Nov 2024 16:11:43 +0000 (11:11 -0500)]
Merge pull request #3360 from TheBlueMatt/2024-10-rebroadcast-chan-announcements

Re-broadcast `channel_announcement`s every six blocks for a week

2 weeks agoPin `idna_adapter` to fix MSRV
Elias Rohrer [Mon, 4 Nov 2024 15:06:41 +0000 (16:06 +0100)]
Pin `idna_adapter` to fix MSRV

2 weeks agoMerge pull request #3207 from valentinewallace/2024-07-invreq-in-onion
Matt Corallo [Fri, 1 Nov 2024 14:52:03 +0000 (14:52 +0000)]
Merge pull request #3207 from valentinewallace/2024-07-invreq-in-onion

Include invoice requests in async payment onions

2 weeks agoMerge pull request #3393 from tnull/2024-11-drop-dead-code
Jeffrey Czyz [Fri, 1 Nov 2024 14:48:23 +0000 (09:48 -0500)]
Merge pull request #3393 from tnull/2024-11-drop-dead-code

Drop dead code from `provide_latest_counterparty_commitment_tx`

2 weeks agoDrop dead code from `provide_latest_counterparty_commitment_tx`
Elias Rohrer [Fri, 1 Nov 2024 09:26:46 +0000 (10:26 +0100)]
Drop dead code from `provide_latest_counterparty_commitment_tx`

We drop some dead code that unnecessarily allocates a `Vec` but does
nothing else.

3 weeks agoFix outdated comment on PendingOutboundPayment::StaticInvoiceReceived
Valentine Wallace [Wed, 30 Oct 2024 16:36:46 +0000 (12:36 -0400)]
Fix outdated comment on PendingOutboundPayment::StaticInvoiceReceived

3 weeks agoFactor invoice requests into payment path length limiting
Valentine Wallace [Wed, 18 Sep 2024 15:27:09 +0000 (11:27 -0400)]
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.

3 weeks agoInclude invreq in payment onion when retrying async payments
Valentine Wallace [Wed, 18 Sep 2024 15:21:26 +0000 (11:21 -0400)]
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.

3 weeks agoInclude invreq in payment onion when sending async payments
Valentine Wallace [Wed, 18 Sep 2024 15:17:49 +0000 (11:17 -0400)]
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.

3 weeks agoStore invreqs in StaticInvoiceReceived outbound payments
Valentine Wallace [Fri, 28 Jun 2024 18:03:46 +0000 (14:03 -0400)]
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.

3 weeks agoSupport including invreqs when paying to a route
Valentine Wallace [Fri, 28 Jun 2024 17:57:15 +0000 (13:57 -0400)]
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.

3 weeks agoSupport including invreqs when building payment onions
Valentine Wallace [Fri, 28 Jun 2024 17:45:28 +0000 (13:45 -0400)]
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.

3 weeks agoSupport including invreqs when building onion payloads
Valentine Wallace [Fri, 28 Jun 2024 16:11:01 +0000 (12:11 -0400)]
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.

3 weeks agoSupport encoding invreqs in outbound onion payloads
Valentine Wallace [Fri, 28 Jun 2024 15:40:53 +0000 (11:40 -0400)]
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.

3 weeks agoStop taking &self in outbound_payments' create_inbound_payment
Valentine Wallace [Wed, 30 Oct 2024 15:39:52 +0000 (11:39 -0400)]
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.

3 weeks agoPrefix AsyncPaymentsMessageHandler methods with handle_*
Valentine Wallace [Wed, 18 Sep 2024 00:32:14 +0000 (20:32 -0400)]
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.

3 weeks agoUpdate docs for PaymentFailureReason::RouteNotFound
Valentine Wallace [Wed, 11 Sep 2024 17:57:19 +0000 (13:57 -0400)]
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.

3 weeks agoAdd new PaymentFailureReason::BlindedPathCreationFailed
Valentine Wallace [Wed, 11 Sep 2024 17:53:39 +0000 (13:53 -0400)]
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..

3 weeks agoRemove unneeded Eq and PartialEq derives
Jeffrey Czyz [Mon, 16 Sep 2024 19:42:06 +0000 (14:42 -0500)]
Remove unneeded Eq and PartialEq derives

TlvRecord has a few fields, but comparing only the record_bytes is
sufficient for equality since the other fields are initialized from it.
Remove the Eq and PartialEq derives as they compare these other fields.

3 weeks agoAdd optional lifetime to tlv_stream macro
Jeffrey Czyz [Fri, 2 Aug 2024 16:54:42 +0000 (11:54 -0500)]
Add optional lifetime to tlv_stream macro

Using the tlv_stream macro without a type needing a reference results in
a compilation error because of an unused lifetime parameter. To avoid
this, add an optional lifetime parameter to the macro. This allows for
experimental TLVs, which will be empty initially, and TLVs of entirely
primitive types.

3 weeks agoAdd parsing tests for unknown BOLT12 TLVs
Jeffrey Czyz [Fri, 9 Aug 2024 00:11:27 +0000 (19:11 -0500)]
Add parsing tests for unknown BOLT12 TLVs

3 weeks agoAdd additional test coverage of `NetworkGraph` counters 2024-10-counter-test
Matt Corallo [Tue, 29 Oct 2024 18:08:47 +0000 (18:08 +0000)]
Add additional test coverage of `NetworkGraph` counters

This would have caught the bug fixed in 0c0cb6fccbb426924f21915053b
in our tests.

Suggested by @valentinewallace.

3 weeks agoRe-broadcast `channel_announcement`s every six blocks for a week 2024-10-rebroadcast-chan-announcements
Matt Corallo [Sun, 13 Oct 2024 17:14:23 +0000 (17:14 +0000)]
Re-broadcast `channel_announcement`s 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

3 weeks agoMerge pull request #3367 from TheBlueMatt/2024-10-dense-counters
Matt Corallo [Tue, 29 Oct 2024 17:48:57 +0000 (17:48 +0000)]
Merge pull request #3367 from TheBlueMatt/2024-10-dense-counters

Don't bump the `next_node_counter` when using a removed counter

3 weeks agoMerge pull request #3380 from optout21/channel-funding-tx-simple
Matt Corallo [Tue, 29 Oct 2024 14:57:17 +0000 (14:57 +0000)]
Merge pull request #3380 from optout21/channel-funding-tx-simple

[Splicing] Preserve funding_transaction for the later lifecycle of the channel, simple solution

3 weeks agoPreserve funding_transaction for the later lifecycle of the channel, simple solution
optout [Mon, 28 Oct 2024 21:29:47 +0000 (22:29 +0100)]
Preserve funding_transaction for the later lifecycle of the channel, simple solution

3 weeks agoMerge pull request #3385 from arik-so/gossip-filter-event-send-logging
Matt Corallo [Mon, 28 Oct 2024 14:10:18 +0000 (14:10 +0000)]
Merge pull request #3385 from arik-so/gossip-filter-event-send-logging

Log enqueueing of gossip messages

3 weeks agoMerge pull request #3322 from TheBlueMatt/2024-06-mpp-claim-without-man
Matt Corallo [Mon, 28 Oct 2024 14:08:32 +0000 (14:08 +0000)]
Merge pull request #3322 from TheBlueMatt/2024-06-mpp-claim-without-man

Stop relying on ChannelMonitor persistence after manager read

3 weeks agoLog enqueueing of gossip messages
Arik Sosman [Fri, 25 Oct 2024 23:57:27 +0000 (16:57 -0700)]
Log enqueueing of gossip messages

3 weeks agoDoc the on-upgrade `ChannelMonitor` startup persistence semantics 2024-06-mpp-claim-without-man
Matt Corallo [Sun, 15 Sep 2024 17:24:19 +0000 (17:24 +0000)]
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).

3 weeks agoStop relying on `ChannelMonitor` persistence after manager read
Matt Corallo [Thu, 20 Jun 2024 15:17:10 +0000 (15:17 +0000)]
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.

3 weeks agoReplay MPP claims via background events using new CM metadata
Matt Corallo [Mon, 30 Sep 2024 20:09:01 +0000 (20:09 +0000)]
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.

3 weeks agoHandle duplicate payment claims during initialization
Matt Corallo [Sun, 15 Sep 2024 23:27:35 +0000 (23:27 +0000)]
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.

3 weeks agoMove payment claim initialization to an fn on `ClaimablePayments`
Matt Corallo [Mon, 16 Sep 2024 00:16:51 +0000 (00:16 +0000)]
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.

3 weeks agoMove `ChannelManager`-read preimage relay to after struct build
Matt Corallo [Mon, 30 Sep 2024 19:42:51 +0000 (19:42 +0000)]
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.

3 weeks agoStore info about claimed payments, incl HTLCs in `ChannelMonitor`s
Matt Corallo [Mon, 16 Sep 2024 00:07:48 +0000 (00:07 +0000)]
Store info about claimed payments, incl HTLCs in `ChannelMonitor`s

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.

3 weeks agoPass info about claimed payments, incl HTLCs to `ChannelMonitor`s
Matt Corallo [Sun, 15 Sep 2024 23:50:31 +0000 (23:50 +0000)]
Pass info about claimed payments, incl HTLCs to `ChannelMonitor`s

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.

3 weeks agoUse a struct to track MPP parts pending claiming
Matt Corallo [Fri, 14 Jun 2024 14:10:38 +0000 (14:10 +0000)]
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.

3 weeks agoFix unused warning in fuzz.
Valentine Wallace [Wed, 18 Sep 2024 00:22:20 +0000 (20:22 -0400)]
Fix unused warning in fuzz.

4 weeks agoMerge pull request #3007 from arik-so/arik/trampoline/2024-04-trampoline-blinded...
Matt Corallo [Wed, 23 Oct 2024 21:52:10 +0000 (21:52 +0000)]
Merge pull request #3007 from arik-so/arik/trampoline/2024-04-trampoline-blinded-hop-serialization

Serialize blinded Trampoline hops

4 weeks agoTest non-legacy blinded Trampoline payloads.
Arik Sosman [Sun, 22 Sep 2024 14:06:24 +0000 (23:06 +0900)]
Test non-legacy blinded Trampoline payloads.

4 weeks agoAdd non-legacy blinded Trampoline payloads.
Arik Sosman [Sun, 22 Sep 2024 14:06:05 +0000 (23:06 +0900)]
Add non-legacy blinded Trampoline payloads.

4 weeks agoTest blinded Trampoline payload serialization.
Arik Sosman [Thu, 27 Jun 2024 14:30:21 +0000 (10:30 -0400)]
Test blinded Trampoline payload serialization.

4 weeks agoSerialize blinded path forwards in Trampoline onions.
Arik Sosman [Thu, 18 Apr 2024 21:52:29 +0000 (14:52 -0700)]
Serialize blinded path forwards in Trampoline onions.

4 weeks agoAdd missing `inbound_payment_id_secret` write in `ChannelManager`
Matt Corallo [Mon, 30 Sep 2024 21:02:53 +0000 (21:02 +0000)]
Add missing `inbound_payment_id_secret` write in `ChannelManager`

In aa09c33a1719944769ba98624bfe18ea33083f44 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.

4 weeks agoAllow `clippy::unwrap-or-default` because its usually wrong
Matt Corallo [Wed, 23 Oct 2024 15:59:23 +0000 (15:59 +0000)]
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).

4 weeks agoMerge pull request #3379 from arik-so/exclude-windows-msrv
Matt Corallo [Wed, 23 Oct 2024 13:53:18 +0000 (13:53 +0000)]
Merge pull request #3379 from arik-so/exclude-windows-msrv

Skip MSRV on Windows in CI

4 weeks agoMerge pull request #3142 from TheBlueMatt/2024-06-robust-updates
Matt Corallo [Wed, 23 Oct 2024 00:12:03 +0000 (00:12 +0000)]
Merge pull request #3142 from TheBlueMatt/2024-06-robust-updates

Reliably deliver gossip messages from our `ChannelMessageHandler`

4 weeks agoSkip MSRV on Windows in CI
Arik Sosman [Tue, 22 Oct 2024 20:09:24 +0000 (13:09 -0700)]
Skip MSRV on Windows in CI

4 weeks agoMerge pull request #3376 from yellowred/yellowred/monitor_update_name_pub
Matt Corallo [Tue, 22 Oct 2024 17:13:05 +0000 (17:13 +0000)]
Merge pull request #3376 from yellowred/yellowred/monitor_update_name_pub

Make monitor update name public

4 weeks agoMake monitor update name public
olegkubrakov [Thu, 17 Oct 2024 21:28:12 +0000 (14:28 -0700)]
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.

4 weeks agoMerge pull request #3377 from G8XSU/hex-impls
Matt Corallo [Tue, 22 Oct 2024 13:55:34 +0000 (13:55 +0000)]
Merge pull request #3377 from G8XSU/hex-impls

Implement to_lower_hex() Display/Debug for PaymentId & OfferId

4 weeks agoMerge pull request #3267 from arik-so/rgs_metrics_2024-08
Gursharan Singh [Mon, 21 Oct 2024 23:15:43 +0000 (16:15 -0700)]
Merge pull request #3267 from arik-so/rgs_metrics_2024-08

Update RGS stats for August 2024.

4 weeks agoImplement to_lower_hex() Display/Debug for OfferId.
G8XSU [Mon, 21 Oct 2024 22:36:11 +0000 (15:36 -0700)]
Implement to_lower_hex() Display/Debug for OfferId.

4 weeks agoImplement to_lower_hex() Display/Debug for PaymentId.
G8XSU [Mon, 21 Oct 2024 22:32:30 +0000 (15:32 -0700)]
Implement to_lower_hex() Display/Debug for PaymentId.

4 weeks agoUpdate processing times for iPhone.
Arik Sosman [Wed, 11 Sep 2024 19:01:34 +0000 (12:01 -0700)]
Update processing times for iPhone.

4 weeks agoUpdate RGS stats for August 2024.
Arik Sosman [Thu, 22 Aug 2024 16:55:20 +0000 (09:55 -0700)]
Update RGS stats for August 2024.

4 weeks agoMerge pull request #3370 from dunxen/2024-10-dry-funding-created-signed
Matt Corallo [Mon, 21 Oct 2024 19:25:18 +0000 (19:25 +0000)]
Merge pull request #3370 from dunxen/2024-10-dry-funding-created-signed

DRY `funding_created()` and `funding_signed()` for V1 channels

4 weeks agoDRY `funding_created()` and `funding_signed()` for V1 channels
Duncan Dean [Fri, 4 Oct 2024 14:35:43 +0000 (16:35 +0200)]
DRY `funding_created()` and `funding_signed()` for V1 channels

There is a decent amount of shared code in these two methods so we make
an attempt to share that code here by introducing the
`InitialRemoteCommitmentReceiver` trait. This trait will also come in
handy when we need similar commitment_signed handling behaviour for
dual-funded channels.

4 weeks agoMerge pull request #3356 from jkczyz/2024-10-inflight-scoring
Matt Corallo [Sat, 19 Oct 2024 13:41:11 +0000 (13:41 +0000)]
Merge pull request #3356 from jkczyz/2024-10-inflight-scoring

Don't over-penalize channels with inflight HTLCs

4 weeks agoUse total_inflight_amount_msat for probability fns
Jeffrey Czyz [Fri, 18 Oct 2024 22:42:18 +0000 (17:42 -0500)]
Use total_inflight_amount_msat for probability fns

Rename parameters used when calculating success probability to make it
clear that the total mount in-flight should be used rather than the
payment amount.

4 weeks agoCorrect comments in avoids_saturating_channels
Jeffrey Czyz [Wed, 16 Oct 2024 20:18:17 +0000 (15:18 -0500)]
Correct comments in avoids_saturating_channels

4 weeks agoCorrect base_penalty_amount_multiplier_msat docs
Jeffrey Czyz [Thu, 10 Oct 2024 23:20:25 +0000 (18:20 -0500)]
Correct base_penalty_amount_multiplier_msat docs

Commit df52da7b31494c7ec77a705cca4c44bc840f8a95 modified
ProbabilisticScorer to apply some penalty amount multipliers to the
total amount flowing over the channel. However, the commit updated the
docs for base_penalty_amount_multiplier_msat even though that behavior
didn't change. This commit reverts those docs.

4 weeks agoDon't over-penalize channels with inflight HTLCs
Jeffrey Czyz [Thu, 10 Oct 2024 23:01:23 +0000 (18:01 -0500)]
Don't over-penalize channels with inflight HTLCs

Commit df52da7b31494c7ec77a705cca4c44bc840f8a95 modified
ProbabilisticScorer to apply some penalty amount multipliers (e.g.,
liquidity_penalty_amount_multiplier_msat) to the total amount flowing
over the channel (i.e., including inflight HTLCs), not just the payment
in question. This led to over-penalizing in-use channels. Instead, only
apply the total amount when calculating success probability.

4 weeks agoMerge pull request #3359 from TheBlueMatt/2024-10-less-types-re-export
Gursharan Singh [Fri, 18 Oct 2024 21:35:49 +0000 (14:35 -0700)]
Merge pull request #3359 from TheBlueMatt/2024-10-less-types-re-export

Remove deprecated re-exports

4 weeks agoMerge pull request #3297 from TheBlueMatt/2024-09-cleanup-package
Matt Corallo [Fri, 18 Oct 2024 17:44:29 +0000 (17:44 +0000)]
Merge pull request #3297 from TheBlueMatt/2024-09-cleanup-package

Cleanup `PackageTemplate`a bit

4 weeks agoAdd a test for the fee-bump rate of timeout HTLC claims on cp txn 2024-09-cleanup-package
Matt Corallo [Fri, 18 Oct 2024 15:57:25 +0000 (15:57 +0000)]
Add a test for the fee-bump rate of timeout HTLC claims on cp txn

In a previous commit we updated the fee-bump-rate of claims against
HTLC timeouts on counterparty commitment transactions so that
instead of immediately attempting to bump every block we consider
the fact that we actually have at least `MIN_CLTV_EXPIRY_DELTA`
blocks to do so, and bumping at the appropriate rate given that.

Here we test that by adding an extra check to an existing test
that we do not bump in the very next block after the HTLC timeout
claim was initially broadcasted.

4 weeks agoSet correct `counterparty_spendable_height` for outb local HTLCs
Matt Corallo [Wed, 18 Sep 2024 18:20:46 +0000 (18:20 +0000)]
Set correct `counterparty_spendable_height` for outb local HTLCs

For outbound HTLCs, the counterparty can spend the output
immediately. This fixes the `counterparty_spendable_height` in the
`PackageTemplate` claiming outbound HTLCs on local commitment
transactions, which was previously spuriously set to the HTLC
timeout (at which point *we* can claim the HTLC).

4 weeks agoStop exporting `lightning::ln::features` 2024-10-less-types-re-export
Matt Corallo [Thu, 17 Oct 2024 19:38:19 +0000 (19:38 +0000)]
Stop exporting `lightning::ln::features`

Now that the module only contains some implementations of
serialization for the `lightning_types::features` structs, there's
no reason for it to be public.

4 weeks agoAdd a test of gossip message buffer limiting in `PeerManager` 2024-06-robust-updates
Matt Corallo [Tue, 20 Aug 2024 02:22:22 +0000 (02:22 +0000)]
Add a test of gossip message buffer limiting in `PeerManager`

This adds a simple test that the gossip message buffer in
`PeerManager` is limited, including the new behavior of bypassing
the limit when the broadcast comes from the
`ChannelMessageHandler`.

4 weeks agoAdd a constructor for the test `SocketDescriptor` and `hang_writes`
Matt Corallo [Tue, 20 Aug 2024 01:57:06 +0000 (01:57 +0000)]
Add a constructor for the test `SocketDescriptor` and `hang_writes`

In testing, its useful to be able to tell the `SocketDescriptor` to
pretend the system network buffer is full, which we add here by
creating a new `hang_writes` flag. In order to simplify
constructing, we also add a new constructor which existing tests
are moved to.

4 weeks agoFix the `establish_connection` utility method for a 2nd connection
Matt Corallo [Tue, 20 Aug 2024 02:13:55 +0000 (02:13 +0000)]
Fix the `establish_connection` utility method for a 2nd connection

The `establish_connection` method should work for more than one
connection per `PeerManager`, which we fix here.

4 weeks agoReliably deliver gossip messages from our `ChannelMessageHandler`
Matt Corallo [Mon, 24 Jun 2024 20:24:36 +0000 (20:24 +0000)]
Reliably deliver gossip messages from our `ChannelMessageHandler`

When our `ChannelMessageHandler` creates gossip broadcast
`MessageSendEvent`s, we generally want these to be reliably
delivered to all our peers, even if there's not much buffer space
available.

Here we do this by passing an extra flag to `forward_broadcast_msg`
which indicates where the message came from, then ignoring the
buffer-full criteria when the flag is set.

4 weeks agoRename `soonest_conf_deadline` to `counterparty_spendable_height`
Matt Corallo [Wed, 18 Sep 2024 16:48:24 +0000 (16:48 +0000)]
Rename `soonest_conf_deadline` to `counterparty_spendable_height`

This renames the field in `PackageTemplate` which describes the
height at which a counterparty can make a claim to an output to
match its actual use.

Previously it had been set based on when a counterparty can claim
an output but also used for other purposes. In the previous commit
we cleaned up its use for fee-bumping-rate, so here we can rename
it as it is now only used as the `counteraprty_spendable_height`.