]> git.bitcoin.ninja Git - rust-lightning/log
rust-lightning
6 days agoMerge pull request #3355 from TheBlueMatt/2024-10-mon-ids-after-close
Matt Corallo [Thu, 14 Nov 2024 21:53:52 +0000 (21:53 +0000)]
Merge pull request #3355 from TheBlueMatt/2024-10-mon-ids-after-close

6 days agoMerge pull request #3221 from tnull/2024-08-rustfmt-lightning-invoice
Matt Corallo [Thu, 14 Nov 2024 21:27:18 +0000 (21:27 +0000)]
Merge pull request #3221 from tnull/2024-08-rustfmt-lightning-invoice

`rustfmt`: Run on `lightning-invoice`

6 days agoAvoid startup `PeerState` entries for peers with unfunded channels 2024-10-mon-ids-after-close
Matt Corallo [Thu, 10 Oct 2024 19:42:16 +0000 (19:42 +0000)]
Avoid startup `PeerState` entries for peers with unfunded channels

If a peer creates a channel with us which never reaches the funding
stage (or never gets any commitment updates after creation), we'll
avoid inserting the `update_id` into
`closed_channel_monitor_update_ids` at runtime to avoid keeping a
`PeerState` entry around for no reason. However, on startup we
still create a `ChannelMonitorUpdate` with a `ChannelForceClosed`
update step to ensure the `ChannelMonitor` is locked and shut down.

This is pretty redundant, and results in a bunch of on-startup
`ChannelMonitorUpdate`s for any old but non-archived
`ChannelMonitor`s. Instead, here, we check if a `ChannelMonitor`
already saw a `ChannelForceClosed` update step before we generate
the on-startup `ChannelMonitorUpdate`.

This also allows us to skip the `closed_channel_monitor_update_ids`
insertion as we can be confident we'll never have a
`ChannelMonitorUpdate` for this channel at all.

7 days ago`rustfmt`: Remove remaining `lightning-invoice` files from exclusion list
Elias Rohrer [Tue, 5 Nov 2024 09:09:27 +0000 (10:09 +0100)]
`rustfmt`: Remove remaining `lightning-invoice` files from exclusion list

7 days ago`rustfmt`: Drop `lightning-invoice/tests/ser_de.rs` from exclusion list
Elias Rohrer [Thu, 14 Nov 2024 12:51:09 +0000 (13:51 +0100)]
`rustfmt`: Drop `lightning-invoice/tests/ser_de.rs` from exclusion list

7 days ago`rustfmt`: Run on `lightning-invoice/tests/ser_de.rs`
Elias Rohrer [Thu, 14 Nov 2024 12:51:09 +0000 (13:51 +0100)]
`rustfmt`: Run on `lightning-invoice/tests/ser_de.rs`

7 days ago`rustfmt`: Drop `lightning-invoice/src/lib.rs` from exclusion list
Elias Rohrer [Tue, 5 Nov 2024 09:09:05 +0000 (10:09 +0100)]
`rustfmt`: Drop `lightning-invoice/src/lib.rs` from exclusion list

7 days ago`rustfmt`: Run on `lightning-invoice/src/lib.rs`
Elias Rohrer [Tue, 5 Nov 2024 09:09:05 +0000 (10:09 +0100)]
`rustfmt`: Run on `lightning-invoice/src/lib.rs`

7 days ago`rustfmt`: Prepare `lightning-invoice/src/lib.rs`
Elias Rohrer [Thu, 14 Nov 2024 10:52:44 +0000 (11:52 +0100)]
`rustfmt`: Prepare `lightning-invoice/src/lib.rs`

7 days ago`rustfmt`: Drop `lightning-invoice/src/tb.rs` from exclusion list
Elias Rohrer [Tue, 5 Nov 2024 09:08:50 +0000 (10:08 +0100)]
`rustfmt`: Drop `lightning-invoice/src/tb.rs` from exclusion list

7 days ago`rustfmt`: Run on `lightning-invoice/src/tb.rs`
Elias Rohrer [Tue, 5 Nov 2024 09:08:49 +0000 (10:08 +0100)]
`rustfmt`: Run on `lightning-invoice/src/tb.rs`

7 days ago`rustfmt`: Drop `lightning-invoice/src/ser.rs` from exclusion list
Elias Rohrer [Tue, 5 Nov 2024 09:08:47 +0000 (10:08 +0100)]
`rustfmt`: Drop `lightning-invoice/src/ser.rs` from exclusion list

7 days ago`rustfmt`: Run on `lightning-invoice/src/ser.rs`
Elias Rohrer [Tue, 5 Nov 2024 09:08:46 +0000 (10:08 +0100)]
`rustfmt`: Run on `lightning-invoice/src/ser.rs`

7 days ago`rustfmt`: Drop `lightning-invoice/src/de.rs` from exclusion list
Elias Rohrer [Tue, 5 Nov 2024 09:08:41 +0000 (10:08 +0100)]
`rustfmt`: Drop `lightning-invoice/src/de.rs` from exclusion list

7 days ago`rustfmt`: Run on `lightning-invoice/src/de.rs`
Elias Rohrer [Tue, 5 Nov 2024 09:08:41 +0000 (10:08 +0100)]
`rustfmt`: Run on `lightning-invoice/src/de.rs`

7 days ago`rustfmt`: Prepare `lightning-invoice/src/de.rs`
Elias Rohrer [Thu, 14 Nov 2024 10:45:45 +0000 (11:45 +0100)]
`rustfmt`: Prepare `lightning-invoice/src/de.rs`

8 days agoMerge pull request #3368 from TheBlueMatt/2024-10-decayed-non-null
Gursharan Singh [Wed, 13 Nov 2024 02:50:46 +0000 (18:50 -0800)]
Merge pull request #3368 from TheBlueMatt/2024-10-decayed-non-null

Don't interpret decayed data as we've failed to send tiny values

8 days agoStop using a constant for monitor `update_id`s after closure
Matt Corallo [Sun, 6 Oct 2024 19:58:29 +0000 (19:58 +0000)]
Stop using a constant for monitor `update_id`s after closure

Because `ChannelManager` doesn't have a corresponding `Channel`
after the channels are closed, we'd always used an `update_id` of
`u64::MAX` for any `ChannelMonitorUpdate`s we need to build after
the channel is closed.

This completely breaks the abstraction of `update_id`s and leaks
into persistence logic - because we might have more than one
`ChannelMonitorUpdate` with the same (`u64::MAX`) value, suddenly
instead of being able to safely use `update_id` as IDs, the
`MonitorUpdatingPersister` has to have special logic to handle
this.

Worse, because we don't have a unique ID with which to refer to
post-close `ChannelMonitorUpdate`s we cannot track when they
complete async persistence. This means we cannot properly support
async persist for forwarded payments where the inbound edge has hit
the chain prior to the preimage coming to us.

Here we rectify this by using consistent `update_id`s even after a
channel has closed. In order to do so we have to keep some state
for all channels for which the `ChannelMonitor` has not been
archived (after which point we can be confident we will not need to
update them). While this violates our long-standing policy of
having no state at all in `ChannelManager`s for closed channels,
its only a `(ChannelId, u64)` pair per channel, so shouldn't be
problematic for any of our users (as they already store a whole
honkin `ChannelMonitor` for these channels anyway).

While limited changes are made to the connection-count-limiting
logic, reviewers should carefully analyze the interactions the new
map created here has with that logic.

8 days agoPrefer to use `MonitorUpdateRegeneratedOnStartup` where possible
Matt Corallo [Sun, 6 Oct 2024 19:54:32 +0000 (19:54 +0000)]
Prefer to use `MonitorUpdateRegeneratedOnStartup` where possible

In the next commit we'll drop the magic `u64::MAX`
`ChannelMonitorUpdate::update_id` value used when we don't know the
`ChannelMonitor`'s `latest_update_id` (i.e. when the channel is
closed). In order to do so, we will store further information about
`ChannelMonitor`s in the per-peer structure, keyed by the
counterparty's node ID, which will be used when applying
`ChannelMonitorUpdate`s to closed channels.

By taking advantage of the change in the previous commit, that
information is now reliably available when we generate the
`ChannelMonitorUpdate` (when claiming HTLCs), but in order to
ensure it is available when applying the `ChannelMonitorUpdate` we
need to use `BackgroundEvent::MonitorUpdateRegeneratedOnStartup`
instead of
`BackgroundEvent::ClosedMonitorUpdateRegeneratedOnStartup` where
possible.

Here we do this, leaving `ClosedMonitorUpdateRegeneratedOnStartup`
only used to ensure very old channels (created in 0.0.118 or
earlier) which are not in the `ChannelManager` are force-closed on
startup.

8 days agoReq the counterparty node id when claiming against a closed chan
Matt Corallo [Wed, 9 Oct 2024 19:05:18 +0000 (19:05 +0000)]
Req the counterparty node id when claiming against a closed chan

Currently we store in-flight `ChannelMonitorUpdate`s in the
per-peer structure in `ChannelManager`. This is nice and simple as
we're generally updating it when we're updating other per-peer
data, so we already have the relevant lock(s) and map entries.

Sadly, when we're claiming an HTLC against a closed channel, we
didn't have the `counterparty_node_id` available until it was
added in 0.0.124 (and now we only have it for HTLCs which were
forwarded in 0.0.124). This means we can't look up the per-peer
structure when claiming old HTLCs, making it difficult to track the
new `ChannelMonitorUpdate` as in-flight.

While we could transition the in-flight `ChannelMonitorUpdate`
tracking to a new global map indexed by `OutPoint`, doing so would
result in a major lock which would be highly contended across
channels with different peers.

Instead, as we move towards tracking in-flight
`ChannelMonitorUpdate`s for closed channels we'll keep our existing
storage, leaving only the `counterparty_node_id` issue to contend
with.

Here we simply accept the issue, requiring that
`counterparty_node_id` be available when claiming HTLCs against a
closed channel. On startup, we explicitly check for any forwarded
HTLCs which came from a closed channel where the forward happened
prior to 0.0.124, failing to deserialize, or logging an warning if
the channel is still open (implying things may work out, but panics
may occur if the channel closes prior to HTLC resolution).

While this is a somewhat dissapointing resolution, LDK nodes which
forward HTLCs are generally fairly well-upgraded, so it is not
anticipated to be an issue in practice.

8 days agoMerge pull request #3264 from jkczyz/2024-08-remove-user-provided-payer-id
Matt Corallo [Tue, 12 Nov 2024 20:23:45 +0000 (20:23 +0000)]
Merge pull request #3264 from jkczyz/2024-08-remove-user-provided-payer-id

Disallow user-provided `payer_signing_pubkey`

8 days agoMerge pull request #3283 from TheBlueMatt/2024-07-human-readable-names-resolution
Elias Rohrer [Tue, 12 Nov 2024 17:30:01 +0000 (18:30 +0100)]
Merge pull request #3283 from TheBlueMatt/2024-07-human-readable-names-resolution

Support paying directly to Human Readable Names using bLIP 32

9 days agoSet the `dns_resolution` feature in `OMDomainResolver` 2024-07-human-readable-names-resolution
Matt Corallo [Wed, 2 Oct 2024 18:23:31 +0000 (18:23 +0000)]
Set the `dns_resolution` feature in `OMDomainResolver`

`OMDomainResolver` actually does support building DNSSECProofs, so
should be setting the `dns_resolution` `NodeFeature` flag.

9 days agoAdd a `lightning-dns-resolver` crate which answers bLIP 32 queries
Matt Corallo [Sun, 14 Jul 2024 13:08:04 +0000 (13:08 +0000)]
Add a `lightning-dns-resolver` crate which answers bLIP 32 queries

When a lightning node wishes to send payments to a BIP 353 human
readable name (using BOLT 12), it first has to resolve that name to
a DNS TXT record. bLIP 32 defines a way to do so over onion
messages, and this completes our implementation thereof by adding
the server side.

It operates by simply accepting new messages and spawning tokio
tasks to do DNS lookups using the `dnsse_prover` crate. It also
contains full end-to-end tests of the BIP 353 -> BOLT 12 -> payment
logic using the new server code to do the resolution.

Note that because we now have a workspace crate which sets the
"lightning/dnssec" feature in its `dev-dependencies`, a naive
`cargo test` will test the "dnssec" feature.

9 days agoUse `ChannelManager` as `DNSResolverMessageHandler` by default
Matt Corallo [Sun, 14 Jul 2024 01:17:03 +0000 (01:17 +0000)]
Use `ChannelManager` as `DNSResolverMessageHandler` by default

Now that `ChannelManager` supports using bLIP 32 to resolve BIP 353
Human Readable Names we should encourage users to use that feature
by making the "default" (in various type aliases) to use
`ChannelManager` as the `DNSResolverMessageHandler`.

9 days agoSupport paying Human Readable Names directly from `ChannelManager`
Matt Corallo [Thu, 7 Nov 2024 15:05:26 +0000 (15:05 +0000)]
Support paying Human Readable Names directly from `ChannelManager`

Now that we have the ability to resolve BIP 353 Human Readable
Names directly and have tracking for outbound payments waiting on
an offer resolution, we can implement full BIP 353 support in
`ChannelManager`.

Users will need one or more known nodes which offer DNS resolution
service over onion messages using bLIP 32, which they pass to
`ChannelManager::pay_for_offer_from_human_readable_name`, as well
as the `HumanReadableName` itself.

From there, `ChannelManager` asks the DNS resolver to provide a
DNSSEC proof, which it verifies, parses into an `Offer`, and then
pays.

For those who wish to support on-chain fallbacks, sadly, this will
not work, and they'll still have to use `OMNameResolver` directly
in order to use their existing `bitcoin:` URI parsing.

9 days agoStore the source `HumanReadableName` in `InvoiceRequestFields`
Matt Corallo [Mon, 30 Sep 2024 18:18:38 +0000 (18:18 +0000)]
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`.

9 days agoAdd support for storing a source HRN in BOLT 12 `invoice_request`s
Matt Corallo [Sat, 13 Jul 2024 14:04:39 +0000 (14:04 +0000)]
Add support for storing a source HRN in BOLT 12 `invoice_request`s

When we resolve a Human Readable Name to a BOLT 12 `offer`, we may
end up resolving to a wildcard DNS name covering all possible
`user` parts. In that case, if we just blindly pay the `offer`, the
recipient would have no way to tell which `user` we paid.

Instead, BOLT 12 defines a field to include the HRN resolved in the
`invoice_request`, which we implement here.

We also take this opportunity to remove constant parameters from
the `outbound_payment.rs` interface to `channelmanager.rs`

9 days agoAdd a new `AwaitingOffer` outbound payment state for BIP 353
Matt Corallo [Fri, 12 Jul 2024 23:37:54 +0000 (23:37 +0000)]
Add a new `AwaitingOffer` outbound payment state for BIP 353

9 days agoSkip the implicit trailing `.` in `HumanReadableName`'s domain
Matt Corallo [Tue, 1 Oct 2024 18:06:19 +0000 (18:06 +0000)]
Skip the implicit trailing `.` in `HumanReadableName`'s domain

Domain names implicitly have a trailing `.`, which we require in
bLIP 32 but generally shouldn't be exposing to the user in
`HumanReadableName`s (after all, they're human-readable). Here we
make sure the trailing `.` is dropped in `HumanReadableName`s
before we re-add them when building the bLIP 32 messages.

9 days agoMerge pull request #3383 from valentinewallace/2024-09-blinded-keysend-verify
Matt Corallo [Tue, 12 Nov 2024 15:00:46 +0000 (15:00 +0000)]
Merge pull request #3383 from valentinewallace/2024-09-blinded-keysend-verify

Verify blinded keysend payments

9 days agoRemove NodeSigner::sign_bolt12_invoice_request
Jeffrey Czyz [Thu, 22 Aug 2024 20:41:16 +0000 (15:41 -0500)]
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.

9 days agoRemove PayerSigningPubkeyStrategy
Jeffrey Czyz [Tue, 20 Aug 2024 22:49:18 +0000 (17:49 -0500)]
Remove PayerSigningPubkeyStrategy

Now that InvoiceRequest::payer_signing_pubkey is always a derived
pubkey, there is no longer a need for PayerSigningPubkeyStrategy.

9 days agoDisallow user-provided payer_signing_pubkey
Jeffrey Czyz [Tue, 20 Aug 2024 20:52:17 +0000 (15:52 -0500)]
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.

9 days agoReplace spaces with tabs
Jeffrey Czyz [Tue, 20 Aug 2024 18:26:13 +0000 (13:26 -0500)]
Replace spaces with tabs

10 days agoMerge pull request #3389 from jkczyz/2024-10-bolt11-invoice-utils
Matt Corallo [Mon, 11 Nov 2024 14:35:08 +0000 (14:35 +0000)]
Merge pull request #3389 from jkczyz/2024-10-bolt11-invoice-utils

Add `ChannelManager::create_bolt11_invoice`

12 days agoVerify blinded keysend payment secrets
Valentine Wallace [Tue, 22 Oct 2024 20:51:51 +0000 (16:51 -0400)]
Verify blinded keysend payment secrets

If we're receiving a keysend to a blinded path, then we created the payment
secret within. Using our inbound_payment_key, we can decrypt the payment secret
bytes to get the payment's min_cltv_expiry_delta and min amount, to verify the
payment is valid. However, if we're receiving an MPP keysend *not* to a blinded
path, then we did not create the payment secret and shouldn't verify it since
it's only used to correlate MPP parts.

Therefore, store whether the payment secret is recipient-generated in our pending
inbound payment data so we know whether to verify it or not.

12 days agoUpdate BOLT11 docs in ChannelManager
Jeffrey Czyz [Wed, 6 Nov 2024 17:18:21 +0000 (11:18 -0600)]
Update BOLT11 docs in ChannelManager

Update ChannelManager docs to use create_bolt11_invoice and correct
references to modules in the lightning-invoice crate that no longer
exist.

12 days agoTest new behavior in create_bolt11_invoice
Jeffrey Czyz [Tue, 29 Oct 2024 14:58:37 +0000 (09:58 -0500)]
Test new behavior in create_bolt11_invoice

Bolt11InvoiceParameters allows for setting currency and
duration_since_epoch. If currency is not set, test that the one
corresponding to ChannelManager's chain hash is usd. If
duration_since_epoch, is not set then highest seen timestamp is used in
non-std compilations.

12 days agoDeprecate functions in invoice_utils module
Jeffrey Czyz [Wed, 6 Nov 2024 22:53:07 +0000 (16:53 -0600)]
Deprecate functions in invoice_utils module

ChannelManager::create_bolt11_invoice is a simpler and more flexible way
of creating a BOLT11 invoice, so deprecate the corresponding functions
in the invoice_utils module.

12 days agoUse ChannelManager::create_bolt11_invoice in tests
Jeffrey Czyz [Wed, 6 Nov 2024 22:49:02 +0000 (16:49 -0600)]
Use ChannelManager::create_bolt11_invoice in tests

The utility methods in in invoice_utils will be removed or deprecated in
an upcoming commit.

12 days agoAdd a BOLT11 invoice utility to ChannelManager
Jeffrey Czyz [Mon, 28 Oct 2024 22:28:10 +0000 (17:28 -0500)]
Add a BOLT11 invoice utility to ChannelManager

Now that the lightning crate depends on the lightning_invoice crate, the
utility functions previously living in the latter can be implemented on
ChannelManager. Additionally, the parameters are now moved to a struct
in order to remove the increasingly combinatorial blow-up of methods.

The new Bolt11InvoiceParameters is used to determine what values to set
in the invoice. Using None for any given parameter results in a
reasonable the default or a behavior determined by the ChannelManager as
detailed in the documentation.

12 days agoRemove currency support from invoice_utils
Jeffrey Czyz [Fri, 8 Nov 2024 17:44:00 +0000 (11:44 -0600)]
Remove currency support from invoice_utils

When creating an invoice using a ChannelManager, payments for a specific
ChainHash / Network are only valid. Use the one from the ChannelManager
instead of allowing arbitrary ones in the form of a Currency.

13 days agoSupport verifying payment_secrets for inbound static invoice payments
Valentine Wallace [Fri, 30 Aug 2024 22:41:36 +0000 (18:41 -0400)]
Support verifying payment_secrets for inbound static invoice payments

Add a new payment type for this, because normally the payment hash is factored
into the payment secrets we create for invoices, but static invoices don't have
a payment hash since they are paid via keysend.

13 days agoAdd new inbound payment key for spontaneous payments
Valentine Wallace [Wed, 6 Nov 2024 19:58:04 +0000 (14:58 -0500)]
Add new inbound payment key for spontaneous payments

This key will be used in upcoming commits for encrypting metadata bytes for
spontaneous payments' payment secrets, to be included in the blinded paths of
static invoices for async payments. We need a new type of payment secret for
these payments because they don't have an a prior known payment hash, see the
next commit.

13 days agoRemove pending_inbound_payments map from ChannelManager
Valentine Wallace [Fri, 27 Sep 2024 06:53:17 +0000 (15:53 +0900)]
Remove pending_inbound_payments map from ChannelManager

LDK versions prior to 0.0.104 had stateful inbound payments written in this
map. In 0.0.104, we added support for stateless inbound payments with
deterministically generated payment secrets, and maintained deprecated support
for stateful inbound payments until 0.0.116. After 0.0.116, no further inbound
payments could have been written into this map.

13 days agoRemove no-std support from invoice_utils functions
Jeffrey Czyz [Thu, 7 Nov 2024 00:53:18 +0000 (18:53 -0600)]
Remove no-std support from invoice_utils functions

The upcoming ChannelManager::create_bolt11_invoice will not support
setting a specific creation time, so remove that functionality from the
invoice_utils functions. This will avoid duplicate code when
deprecating.

13 days agoMerge pull request #3397 from vincenzopalazzo/macros/amount-less-refactoring
Matt Corallo [Thu, 7 Nov 2024 22:13:57 +0000 (22:13 +0000)]
Merge pull request #3397 from vincenzopalazzo/macros/amount-less-refactoring

[RFC] rename pay_parameters for no amount invoice

13 days agoMerge pull request #3402 from tnull/2024-11-pin-indexmap
Matt Corallo [Thu, 7 Nov 2024 22:12:19 +0000 (22:12 +0000)]
Merge pull request #3402 from tnull/2024-11-pin-indexmap

Pin `indexmap` back to account for `hashbrown` MSRV bump

13 days agoMerge pull request #3399 from TheBlueMatt/2024-11-fuzz-assert
Matt Corallo [Thu, 7 Nov 2024 21:43:12 +0000 (21:43 +0000)]
Merge pull request #3399 from TheBlueMatt/2024-11-fuzz-assert

Drop broken debug assertion on peer buffer lengths

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 agoPin `indexmap` back to account for `hashbrown` MSRV bump
Elias Rohrer [Thu, 7 Nov 2024 13:29:09 +0000 (14:29 +0100)]
Pin `indexmap` back to account for `hashbrown` MSRV bump

`indexmap` 2.6.0 upgraded to `hashbrown` 0.15, which unfortunately
bumped their MSRV to rustc 1.65 with the 0.15.1 release. So we pin
`indexmap` to 2.5.0 to fix our MSRV CI.

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 agoCombine import statements
Jeffrey Czyz [Mon, 28 Oct 2024 20:54:01 +0000 (15:54 -0500)]
Combine import statements

2 weeks agoAdd Description::empty constructor
Jeffrey Czyz [Wed, 6 Nov 2024 17:11:11 +0000 (11:11 -0600)]
Add Description::empty constructor

When creating a default Bolt11InvoiceParameters, having an infallible
constructor avoids an unwrap.

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 agorename pay_parameters for no amount invoice
Vincenzo Palazzo [Tue, 5 Nov 2024 11:45:01 +0000 (12:45 +0100)]
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>
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 agoBuild `per_peer_state` immediately in `ChannelManager` deser
Matt Corallo [Fri, 4 Oct 2024 17:54:00 +0000 (17:54 +0000)]
Build `per_peer_state` immediately in `ChannelManager` deser

Instead of first building a map from peers to a list of channels
then pulling out of that to build the `per_peer_state`, we build
`per_peer_state` immediately and store channels in it immediately.

This avoids an unnecessary map indirection but also gives us
access to the new fields in `per_peer_state` when reading
`Channel`s which we'll need in a coming commit.

2 weeks agoAvoid a `short_to_chan_info` read lock in `claim_funds_from_hop`
Matt Corallo [Sat, 21 Sep 2024 04:23:09 +0000 (04:23 +0000)]
Avoid a `short_to_chan_info` read lock in `claim_funds_from_hop`

In 453ed11f80b40f28b6e95a74b1f7ed2cd7f012ad we started tracking the
counterparty's `node_id` in `HTLCPreviousHopData`, however we were
still trying to look it up using `prev_short_channel_id` in
`claim_funds_from_hop`.

Because we now usually have the counterparty's `node_id` directly
accessible, we should skip the `prev_short_channel_id` lookup.

This will also be more important in the next commit where we need
to look up state for our counterparty to generate
`ChannelMonitorUpdate`s whether we have a live channel or not.

2 weeks agoAdd missing `update_maps_on_chan_removal` call in signer restore
Matt Corallo [Sun, 29 Sep 2024 19:30:48 +0000 (19:30 +0000)]
Add missing `update_maps_on_chan_removal` call in signer restore

When a channel is closed, we have to call
`update_maps_on_chan_removal` in the same per-peer-state lock as
the removal of the `ChannelPhase` object. We forgot to do so in
`ChannelManager::signer_unblocked` leaving dangling references to
the channel.

We also take this opportunity to include more context in the
channel-closure log in `ChannelManager::signer_unblocked` and add
documentation to `update_maps_on_chan_removal` and
`finish_close_channel` to hopefully avoid this issue in the future.

2 weeks agoPass the `peer_state` lock through to `update_maps_on_chan_removal`
Matt Corallo [Sun, 29 Sep 2024 15:22:29 +0000 (15:22 +0000)]
Pass the `peer_state` lock through to `update_maps_on_chan_removal`

`update_maps_on_chan_removal` is used to perform `ChannelManager`
state updates when a channel is being removed, prior to dropping
the `peer_state` lock. In a future commit we'll use it to update
fields in the `per_peer_state`, but in order to do so we'll need to
have access to that state in the macro.

Here we get set up for this by passing the per-peer state to
`update_maps_on_chan_removal`, which is sadly a fairly large patch.

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 agoDrop broken debug assertion on peer buffer lengths 2024-11-fuzz-assert
Matt Corallo [Tue, 5 Nov 2024 16:04:08 +0000 (16:04 +0000)]
Drop broken debug assertion on peer buffer lengths

1b711ed15f426ce40f1aa6be83d930a01ab530ba changed it so that we can
enqueue broadcast gossip messages to peers even though their buffer
is full as long as its our `ChannelMessageHandler` doing it. This
broke a debug assertion that the buffer isn't too large when
appending the broadcast message which is simply dropped here.

Found by the `full_stack_target` fuzzer.

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.