]> git.bitcoin.ninja Git - rust-lightning/log
rust-lightning
2 months agoHMAC Construction and Verification for PaymentHash
shaavan [Fri, 6 Sep 2024 12:01:08 +0000 (17:31 +0530)]
HMAC Construction and Verification for PaymentHash

When a InvoiceError is received for a sent BOLT12Invoice, the
corresponding PaymentHash is to be logged. Introduce hmac construction
and verification function for PaymentHash for this purpose.

2 months agoMerge pull request #3259 from vincenzopalazzo/macros/dummy-tx
Matt Corallo [Tue, 27 Aug 2024 19:16:57 +0000 (19:16 +0000)]
Merge pull request #3259 from vincenzopalazzo/macros/dummy-tx

[RFC] event: store the outpoint when is_manual_broadcast

2 months agoevent: store the outpoint when is_manual_broadcast
Vincenzo Palazzo [Tue, 27 Aug 2024 08:18:28 +0000 (10:18 +0200)]
event: store the outpoint when is_manual_broadcast

With [1], it's possible to specify `manual_broadcast` for
the channel funding transaction. When `is_manual_broadcast` is
set to true, the transaction in the `DiscardFunding` event is
replaced with a dummy empty transaction.

This commit checks if `is_manual_broadcast` is true and
stores the funding OutPoint in the DiscardFunding event instead.

[1] https://github.com/lightningdevkit/rust-lightning/pull/3024

Link: https://github.com/lightningdevkit/rust-lightning/issues/3164
Suggested-by: TheBlueMatt
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2 months agoMerge pull request #3273 from TheBlueMatt/2024-08-bindings-no-static
Matt Corallo [Tue, 27 Aug 2024 14:14:47 +0000 (14:14 +0000)]
Merge pull request #3273 from TheBlueMatt/2024-08-bindings-no-static

Return owned `String`s for onion message message types

2 months agoMerge pull request #3248 from jkczyz/2024-08-blinded-path-utils-refactor
dunxen [Tue, 27 Aug 2024 11:28:43 +0000 (13:28 +0200)]
Merge pull request #3248 from jkczyz/2024-08-blinded-path-utils-refactor

Refactor `BlindedPath` construction utils

2 months agoReturn owned `String`s for onion message message types 2024-08-bindings-no-static
Matt Corallo [Mon, 26 Aug 2024 19:25:46 +0000 (19:25 +0000)]
Return owned `String`s for onion message message types

Returning a reference from a trait method is relatively difficult
to map in bindings and is currently handled by storing the object
in the trait instance, returning a reference to the local field.

This is fine when the object we're returning only needs to live as
long as the trait, but when it needs to be `'static` (as is the
case for onion message `msg_type`s), there's not really a good way
to map them at all.

Instead, here, condition on `#[cfg(c_bindings)]` we return a fully
owned `String`. This is obviously relatively less effecient, but
the extra allocation and `memcpy` isn't the end of the world,
especially given it should be released relatively quickly.

Note that this breaks doctests in with `c_bindings`.

2 months agoMerge pull request #3272 from TheBlueMatt/2024-08-bindings-hidden
Matt Corallo [Mon, 26 Aug 2024 23:44:14 +0000 (23:44 +0000)]
Merge pull request #3272 from TheBlueMatt/2024-08-bindings-hidden

Mark new `types` `#[doc(hidden)]` methods as bindings no-export

2 months agoMark `io::Cursor` as no-export in bindings 2024-08-bindings-hidden
Matt Corallo [Mon, 26 Aug 2024 18:32:28 +0000 (18:32 +0000)]
Mark `io::Cursor` as no-export in bindings

2 months agoMark new `types` `#[doc(hidden)]` methods as bindings no-export
Matt Corallo [Mon, 26 Aug 2024 18:28:07 +0000 (18:28 +0000)]
Mark new `types` `#[doc(hidden)]` methods as bindings no-export

2 months agoMerge pull request #3153 from alecchendev/2024-07-async-closing-signed
Matt Corallo [Mon, 26 Aug 2024 17:45:05 +0000 (17:45 +0000)]
Merge pull request #3153 from alecchendev/2024-07-async-closing-signed

Allow sending closing tx signatures asynchronously

2 months agoMerge pull request #2992 from G8XSU/monitor-update-seq-doc
Matt Corallo [Mon, 26 Aug 2024 14:09:02 +0000 (14:09 +0000)]
Merge pull request #2992 from G8XSU/monitor-update-seq-doc

Doc Clarity: Handling gaps in persisted ChannelMonitorUpdates.

2 months agoMerge pull request #3269 from TheBlueMatt/2024-08-this-should-work-bindings
Matt Corallo [Fri, 23 Aug 2024 22:53:24 +0000 (22:53 +0000)]
Merge pull request #3269 from TheBlueMatt/2024-08-this-should-work-bindings

Use the actual type, not the associated type, in trait impls

2 months agoTest async sign_closing_transaction
Alec Chen [Tue, 2 Jul 2024 06:08:04 +0000 (23:08 -0700)]
Test async sign_closing_transaction

2 months agoAllow sending closing tx signatures asynchronously
Alec Chen [Tue, 2 Jul 2024 06:07:45 +0000 (23:07 -0700)]
Allow sending closing tx signatures asynchronously

2 months agoUse the actual type, not the associated type, in trait impls 2024-08-this-should-work-bindings
Matt Corallo [Fri, 23 Aug 2024 15:33:22 +0000 (15:33 +0000)]
Use the actual type, not the associated type, in trait impls

This is equivalent and just easier for the bindings to deal with
(though, really, they should handle it).

2 months agoMerge pull request #3266 from optout21/bech32-tests
Matt Corallo [Fri, 23 Aug 2024 14:29:15 +0000 (14:29 +0000)]
Merge pull request #3266 from optout21/bech32-tests

Add invoice serialization tests [TestOnly][Minor]

2 months agoAdd invoice serialization tests
optout [Fri, 23 Aug 2024 13:46:22 +0000 (15:46 +0200)]
Add invoice serialization tests

2 months agoMerge pull request #3263 from TheBlueMatt/2024-08-bindings-om
Matt Corallo [Fri, 23 Aug 2024 03:04:19 +0000 (03:04 +0000)]
Merge pull request #3263 from TheBlueMatt/2024-08-bindings-om

Remove message type bound on `ResponseInstruction`

2 months agoAdd a `MessageSendInstructions::ForReply` 2024-08-bindings-om
Matt Corallo [Thu, 22 Aug 2024 01:31:07 +0000 (01:31 +0000)]
Add a `MessageSendInstructions::ForReply`

In order to allow onion message handlers to reply asynchronously
without introducing a circular dependency graph, the message
handlers need to be able to send replies described by
`MessageSendInstructions`. This allows them to send replies via the
normal message queuing (i.e. without making a function call to
`OnionMessenger`).

Here we enable that by adding a `MessageSendInstructions::ForReply`
variant which holds `ReplyInstruction`s.

Fixes #3178

2 months agoChange `send_onion_message` to take a `MessageSendInstructions`
Matt Corallo [Thu, 22 Aug 2024 01:47:37 +0000 (01:47 +0000)]
Change `send_onion_message` to take a `MessageSendInstructions`

This lets callers include a `reply_path` without doing the
path-finding at the callsite, utilizing the built-in path-finding
logic in `OnionMessenger`

2 months ago3/3 Use `MessageSendInstructions` instead of `PendingOnionMessage`
Matt Corallo [Wed, 21 Aug 2024 19:10:46 +0000 (19:10 +0000)]
3/3 Use `MessageSendInstructions` instead of `PendingOnionMessage`

Now that the `MessageRouter` can `create_blinded_paths` forcing
callers of the `OnionMessenger` to provide it with a reply path up
front is unnecessary complexity, doubly so in message handlers.

Here we take the next step towards untangling that, moving from
`PendingOnionMessage` to `MessageSendInstructions` for the outbound
message queue in `AsyncPaymentsMessageHandler`. Better, we can also
drop the `c_bindings`-specific message queue variant, unifying the
APIs.

Here we also drop `PendingOnionMessage` entirely.

2 months ago2/3 Use `MessageSendInstructions` instead of `PendingOnionMessage`
Matt Corallo [Thu, 22 Aug 2024 01:42:55 +0000 (01:42 +0000)]
2/3 Use `MessageSendInstructions` instead of `PendingOnionMessage`

Now that the `MessageRouter` can `create_blinded_paths` forcing
callers of the `OnionMessenger` to provide it with a reply path up
front is unnecessary complexity, doubly so in message handlers.

Here we take the next step towards untangling that, moving from
`PendingOnionMessage` to `MessageSendInstructions` for the outbound
message queue in `OffersMessageHandler`. Better, we can also drop
the `c_bindings`-specific message queue variant, unifying the APIs.

Because `ChannelManager` needs to actually control the reply path
set in individual messages, however, we have to halfway this patch,
adding a new `MessageSendInstructions` variant that allows
specifying the `reply_path` explicitly. Still, because other message
handlers are moving this way, its nice to be consistent.

2 months ago1/3 Use `MessageSendInstructions` instead of `PendingOnionMessage`
Matt Corallo [Thu, 22 Aug 2024 01:41:27 +0000 (01:41 +0000)]
1/3 Use `MessageSendInstructions` instead of `PendingOnionMessage`

Now that the `MessageRouter` can `create_blinded_paths` forcing
callers of the `OnionMessenger` to provide it with a reply path up
front is unnecessary complexity, doubly so in message handlers.

Here we take the first step towards untangling that, moving from
`PendingOnionMessage` to `MessageSendInstructions` for the outbound
message queue in `CustomMessageHandler`. Better, we can also drop
the `c_bindings`-specific message queue variant, unifying the APIs.

2 months agoGive `MessageSendInstructions` any `Destination`, not only Blinded
Matt Corallo [Thu, 22 Aug 2024 18:43:33 +0000 (18:43 +0000)]
Give `MessageSendInstructions` any `Destination`, not only Blinded

In the next commit we'll use `MessageSendInstructions` for all
messages, so it needs the ability to take any `Destination`, not
only a `Destination::Blinded`.

2 months agoMake `ResponseInstruction` `Clone`able
Matt Corallo [Wed, 21 Aug 2024 16:54:31 +0000 (16:54 +0000)]
Make `ResponseInstruction` `Clone`able

2 months agoPull the guts of `ResponseInstruction` into a new enum
Matt Corallo [Thu, 22 Aug 2024 01:35:18 +0000 (01:35 +0000)]
Pull the guts of `ResponseInstruction` into a new enum

In the coming commits we'll use the `ResponseInstruction` enum's
contents for all messages, allowing message senders to rely on the
in-`OnionMessegner` reply path selection logic.

In order to do so and avoid users confusing the new
`MessageSendInstructions` for `ResponseInstruction`, we leave
`ResponseInstruction` as a now-unconstructible struct which wraps a
`MessageSendInstructions`.

2 months agoRemove message type bound on `ResponseInstruction`
Matt Corallo [Wed, 21 Aug 2024 15:32:14 +0000 (15:32 +0000)]
Remove message type bound on `ResponseInstruction`

Our onion message handlers generally have one or more methods which
return a `ResponseInstruction` parameterized with the expected
message type (enum) of the message handler.

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

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

In order to support bindings for the onion message handlers, we
are thus forced into std types bound by expected message types,
which we do here by making `ResponseInstruction` contain only the
instructions and generally using it as a two-tuple of
`(message, ResponseInstruction)`.

3 months agoMerge pull request #3193 from tnull/2024-07-2995-followups
Elias Rohrer [Thu, 22 Aug 2024 07:55:17 +0000 (09:55 +0200)]
Merge pull request #3193 from tnull/2024-07-2995-followups

#2995 followups

3 months agoMerge pull request #3265 from TheBlueMatt/2024-08-globally-unique-names
Matt Corallo [Wed, 21 Aug 2024 21:41:28 +0000 (21:41 +0000)]
Merge pull request #3265 from TheBlueMatt/2024-08-globally-unique-names

Disambiguate blinded path `ForwardNode`s between payment + message

3 months agoMerge pull request #3250 from TheBlueMatt/2024-08-feature-cleanup
Matt Corallo [Wed, 21 Aug 2024 20:51:21 +0000 (20:51 +0000)]
Merge pull request #3250 from TheBlueMatt/2024-08-feature-cleanup

3 months agoCorrect `ConnectionNeeded` docs
Elias Rohrer [Fri, 19 Jul 2024 09:21:17 +0000 (11:21 +0200)]
Correct `ConnectionNeeded` docs

3 months agoAvoid allocating `Vec` for a single result
Elias Rohrer [Fri, 19 Jul 2024 08:57:42 +0000 (10:57 +0200)]
Avoid allocating `Vec` for a single result

3 months agoFix permissive test
Elias Rohrer [Fri, 19 Jul 2024 08:33:05 +0000 (10:33 +0200)]
Fix permissive test

3 months agoMerge pull request #3260 from TheBlueMatt/2024-08-more-deref
Matt Corallo [Wed, 21 Aug 2024 19:55:44 +0000 (19:55 +0000)]
Merge pull request #3260 from TheBlueMatt/2024-08-more-deref

Bound `Persister`'s `WriteableScore` by `Deref`

3 months agoDisambiguate blinded path `ForwardNode`s between payment + message 2024-08-globally-unique-names
Matt Corallo [Wed, 21 Aug 2024 16:46:24 +0000 (16:46 +0000)]
Disambiguate blinded path `ForwardNode`s between payment + message

We currently have two structs with identical names in our public
API - `blinded_path::message::ForwardNode` and
`blinded_path::payment::ForwardNode`. This makes the API somewhat
awkward to use - users have to try (and fail) to import
`ForwardNode` twice only to then have to change their imports.

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

Thus, here, we rename both to give them context.

3 months agoRemove uneccessary `std` bounds on many tests 2024-08-feature-cleanup
Matt Corallo [Sat, 17 Aug 2024 21:23:16 +0000 (21:23 +0000)]
Remove uneccessary `std` bounds on many tests

We never actually build with `#![no_std]` in tests as Rust does
not support it. Thus, many tests have spurious `std` feature gates
when they run just fine without them. Here we remove those gates,
though note that tests that depend on behavior elsewhere in the
codebase which is `std`-gated obviously need to retain their
feature gates.

3 months agoReduce `feature = std` flags in `gossip.rs` somewhat
Matt Corallo [Sat, 17 Aug 2024 19:43:51 +0000 (19:43 +0000)]
Reduce `feature = std` flags in `gossip.rs` somewhat

Fewer feature flags makes for more readable code, so we opt for
that over very marginally more effecient code here.

3 months agoDrop `std::Error` impl for `PeerHandleError`
Matt Corallo [Sat, 17 Aug 2024 15:59:34 +0000 (15:59 +0000)]
Drop `std::Error` impl for `PeerHandleError`

Not sure why we ever really had this, no one really ever bounds
anything on `std::Error` and its kinda a dead type, so there's no
need for us to `impl` it for our types.

3 months agoSimplify `Instant` mocking in outbound payments
Matt Corallo [Fri, 16 Aug 2024 22:36:30 +0000 (22:36 +0000)]
Simplify `Instant` mocking in outbound payments

To handle `std` and `no-std` concepts of time in scoring, we'd
originally written a generic `Time` trait which we could use to
fetch the current time, observe real (not wall-clock) elapsed time,
and serialize the time.

Eventually, scoring stopped using this `Time` trait but outbound
payment retry expiry started using it instead to mock time in
tests.

Since scoring no longer uses the full features which required the
`Time` trait, we can substantially simplify by just having the
mocking option.

3 months agoRemove note about `std`/`no-std` scorer serialization compat
Matt Corallo [Fri, 16 Aug 2024 20:46:37 +0000 (20:46 +0000)]
Remove note about `std`/`no-std` scorer serialization compat

In 81389dee306d960a8030bec5ffa304004148ce85 we removed a note about
mixing the `std` and `no-std` feature when de/serializing
`ProbabilisticScorer`s but forgot to note that there was a second
copy of that note in the module documentation.

This removes that note.

3 months agoBound `Persister`'s `WriteableScore` by `Deref` 2024-08-more-deref
Matt Corallo [Tue, 20 Aug 2024 20:39:41 +0000 (20:39 +0000)]
Bound `Persister`'s `WriteableScore` by `Deref`

This makes the trait marginally more flexible, but more importantly
matches our normal structure which makes the bindings generator a
bit happier.

3 months agoRename construct_keys_callback functions
Jeffrey Czyz [Fri, 16 Aug 2024 15:19:07 +0000 (10:19 -0500)]
Rename construct_keys_callback functions

3 months agoRequire Destination in construct_keys_callback
Jeffrey Czyz [Fri, 16 Aug 2024 15:12:24 +0000 (10:12 -0500)]
Require Destination in construct_keys_callback

3 months agoUse a single iterator to construct a BlindedPath
Jeffrey Czyz [Fri, 16 Aug 2024 02:37:03 +0000 (21:37 -0500)]
Use a single iterator to construct a BlindedPath

Instead of using separate iterators for pubkeys and TLVs, use an
iterator that yields a tuple of them. This allows for holding a mutable
reference to the TLVs such that they can be padded. With two iterators,
the pubkey iterator would have a reference to the ForwardNode slice when
constructing a payment path. However, this would prevent holding mutable
references in the TLVs iterator.

3 months agoGeneralize build_keys_helper
Jeffrey Czyz [Fri, 16 Aug 2024 01:05:33 +0000 (20:05 -0500)]
Generalize build_keys_helper

When constructing a blinded path, two iterators are used: one for the
pubkeys and another for Writeable TLVs. The first iterator is used in
the build_keys_helper utility function while the second is used inside
of a callback. Update this utility to work on any type that can be
borrowed as a PublicKey. This allows for using a single iterator of
tuples, which is necessary for padding the hops without additional
allocations and clones.

3 months agoAdd a construct_keys_callback for blinded paths
Jeffrey Czyz [Thu, 15 Aug 2024 23:06:46 +0000 (18:06 -0500)]
Add a construct_keys_callback for blinded paths

When constructing a BlindedPath, an Option<Destination> parameter to
construct_keys_callback is never passed. Make a separate utility
function that doesn't take this parameter. This allows for using the
build_keys_helper macro with a Iterator yielding items other than
PublicKey.

3 months agoUse PublicKey values in construct_keys_callback
Jeffrey Czyz [Thu, 15 Aug 2024 22:56:17 +0000 (17:56 -0500)]
Use PublicKey values in construct_keys_callback

Instead of accepting iterators yielding PublicKey by reference in
utils::construct_keys_callback, take iterators yielding values since
these implement Copy and need to be copied anyway. This will help avoid
a situation when padding where both a reference and mutable reference
are needed.

3 months agoRefactor helper macro from construct_keys_callback
Jeffrey Czyz [Thu, 15 Aug 2024 22:36:55 +0000 (17:36 -0500)]
Refactor helper macro from construct_keys_callback

When constructing a BlindedPath, utils::construct_blinded_hops uses two
iterators. However, this makes it difficult to pad blinded hops to equal
sizes without allocating a vector or cloning data. Refactor the
construct_keys_callback utility function so that is can be used with an
Iterator with different Item types. This allows using a single Iterator
of tuples while still supporting its use only with pubkeys.

3 months agoMerge pull request #3247 from dunxen/2024-08-deprecate-balancemsat
Matt Corallo [Tue, 20 Aug 2024 20:52:10 +0000 (20:52 +0000)]
Merge pull request #3247 from dunxen/2024-08-deprecate-balancemsat

Deprecate AvailableBalances::balance_msat

3 months agoMerge pull request #3258 from TheBlueMatt/2024-08-default-for-bindings
Matt Corallo [Tue, 20 Aug 2024 20:46:27 +0000 (20:46 +0000)]
Merge pull request #3258 from TheBlueMatt/2024-08-default-for-bindings

Consistently pass `DefaultRouter::new` `Default` scoring parameters

3 months agoDoc Clarity: Handling gaps in persisted ChannelMonitorUpdates
G8XSU [Tue, 20 Aug 2024 17:23:18 +0000 (10:23 -0700)]
Doc Clarity: Handling gaps in persisted ChannelMonitorUpdates

If there are any gaps in the persisted [`ChannelMonitorUpdate`]s,
implementer can safely ignore [`ChannelMonitorUpdate`]s after the gap and load without them.
Since, acc. to channel-manager, we have only made progress if all contiguos
ChannelMonitorUpdates have been persisted.

3 months agoTest ChannelDetails serialization to catch mutants
Duncan Dean [Tue, 20 Aug 2024 07:38:35 +0000 (09:38 +0200)]
Test ChannelDetails serialization to catch mutants

3 months agoMerge pull request #3254 from TheBlueMatt/2024-08-flaky-test
valentinewallace [Tue, 20 Aug 2024 15:13:25 +0000 (11:13 -0400)]
Merge pull request #3254 from TheBlueMatt/2024-08-flaky-test

Correct `peer_handler::test_process_events_multithreaded`

3 months agoDeprecate AvailableBalances::balance_msat
Duncan Dean [Fri, 16 Aug 2024 09:34:55 +0000 (11:34 +0200)]
Deprecate AvailableBalances::balance_msat

The ChannelMonitor::get_claimable_balances method provides a more
straightforward approach to the balance of a channel, which satisfies
most use cases. The computation of AvailableBalances::balance_msat is
complex and originally had a different purpose that is not applicable
anymore. We deprecate AvailableBalances::balance_msat now and will remove
it in a following release.

Co-authored-by: Willem Van Lint <noreply@wvanlint.dev>
3 months agoConsistently pass `DefaultRouter::new` `Default` scoring parameters 2024-08-default-for-bindings
Matt Corallo [Mon, 12 Aug 2024 18:29:59 +0000 (18:29 +0000)]
Consistently pass `DefaultRouter::new` `Default` scoring parameters

In 26c1639ab69d6780c97a118f09e42cb42304088a (and later in
50c55dcf32466e3ccf17acea50697fc664950deb and
fb693ecbf81be0146a81cc7fd95342c403eacaa9) we switched to using
`Default::default()` to initialize `()` for scoring parameters in
tests. One `()`s slipped back in recently, which we replace here.

3 months agoMerge pull request #3255 from TheBlueMatt/2024-08-124-beta v0.0.124-beta
Matt Corallo [Tue, 20 Aug 2024 13:26:35 +0000 (13:26 +0000)]
Merge pull request #3255 from TheBlueMatt/2024-08-124-beta

Bump version numbers to 0.0.124-beta/invoice 0.32-beta

3 months agoMerge pull request #3253 from TheBlueMatt/2024-08-new-types-export
Elias Rohrer [Tue, 20 Aug 2024 06:56:15 +0000 (08:56 +0200)]
Merge pull request #3253 from TheBlueMatt/2024-08-new-types-export

Re-export `lightning_types` in top-level `lightning` modules

3 months agoBump version numbers to 0.0.124-beta/invoice 0.32-beta 2024-08-124-beta
Matt Corallo [Tue, 20 Aug 2024 00:29:12 +0000 (00:29 +0000)]
Bump version numbers to 0.0.124-beta/invoice 0.32-beta

3 months agoMerge pull request #3245 from valentinewallace/2024-07-blinded-pay-path-refactor
Matt Corallo [Mon, 19 Aug 2024 23:24:15 +0000 (23:24 +0000)]
Merge pull request #3245 from valentinewallace/2024-07-blinded-pay-path-refactor

Move `BlindedPayInfo` into `BlindedPaymentPath`

3 months agoCorrect `peer_handler::test_process_events_multithreaded` 2024-08-flaky-test
Matt Corallo [Mon, 19 Aug 2024 18:59:08 +0000 (18:59 +0000)]
Correct `peer_handler::test_process_events_multithreaded`

This test was added some time ago in
0c034e9a82e4339fb32af9da63832ac2a64abb0b, but never made any sense.
`PeerManager::process_events` will go around its loop as many times
is required to ensure we've always processed all events which were
pending prior to a `process_events` call, so having a test that
checks that we never go around more than twice is obviously broken.

And, indeed, in CI this tests fails with some regularity.

Instead, the test here is changed to ensure that we detectably go
around the loop again at least once.

Fixes #2385

3 months agoTest blinded PaymentParameter round trip serialization.
Valentine Wallace [Mon, 19 Aug 2024 20:09:54 +0000 (16:09 -0400)]
Test blinded PaymentParameter round trip serialization.

3 months agoMove BlindedPayInfo into blinded_path::payment module.
Valentine Wallace [Mon, 19 Aug 2024 19:08:20 +0000 (15:08 -0400)]
Move BlindedPayInfo into blinded_path::payment module.

3 months agoMove BlindedPayInfo into BlindedPaymentPath.
Valentine Wallace [Mon, 19 Aug 2024 15:25:05 +0000 (11:25 -0400)]
Move BlindedPayInfo into BlindedPaymentPath.

Also removes the implementation of Writeable for BlindedPaymentPath, to ensure
callsites are explicit about what they're writing.

3 months agoMerge pull request #3204 from valentinewallace/2024-07-rb-test-vectors
Matt Corallo [Mon, 19 Aug 2024 19:57:04 +0000 (19:57 +0000)]
Merge pull request #3204 from valentinewallace/2024-07-rb-test-vectors

Implement route blinding test vectors

3 months agoMerge pull request #3188 from TheBlueMatt/2023-12-cache-scoring-points
Matt Corallo [Mon, 19 Aug 2024 19:02:05 +0000 (19:02 +0000)]
Merge pull request #3188 from TheBlueMatt/2023-12-cache-scoring-points

Better Encapsulate Scoring and Cache Point Count

3 months agoMerge pull request #3249 from TheBlueMatt/2024-08-feature-cleanup-1
Matt Corallo [Mon, 19 Aug 2024 18:50:52 +0000 (18:50 +0000)]
Merge pull request #3249 from TheBlueMatt/2024-08-feature-cleanup-1

bitcoin 0.32 upgrade followups

3 months agoConsolidate sign_closing_transaction callsites to get_closing_signed_msg
Alec Chen [Tue, 2 Jul 2024 05:24:16 +0000 (22:24 -0700)]
Consolidate sign_closing_transaction callsites to get_closing_signed_msg

3 months agoMerge pull request #3222 from tnull/2024-08-rustfmt-lightning-persister
Matt Corallo [Mon, 19 Aug 2024 17:18:04 +0000 (17:18 +0000)]
Merge pull request #3222 from tnull/2024-08-rustfmt-lightning-persister

`rustfmt`: Run on `lightning-persister`

3 months agoAvoid && in public API for onion peeling/decoding.
Valentine Wallace [Wed, 24 Jul 2024 18:56:31 +0000 (14:56 -0400)]
Avoid && in public API for onion peeling/decoding.

No reason to take a reference to a Deref.

3 months agoImplement route blinding spec test vectors.
Valentine Wallace [Wed, 24 Jul 2024 18:10:31 +0000 (14:10 -0400)]
Implement route blinding spec test vectors.

3 months agoFix blinded hop feature serialization.
Valentine Wallace [Wed, 24 Jul 2024 18:09:10 +0000 (14:09 -0400)]
Fix blinded hop feature serialization.

We were writing a length redundantly...

3 months agoSupport next_blinding_override in blinded payment paths.
Valentine Wallace [Mon, 22 Jul 2024 19:22:54 +0000 (15:22 -0400)]
Support next_blinding_override in blinded payment paths.

This allow us to forward blinded payments where the blinded path that we are
forwarding within was concatenated to another blinded path that starts at the
next hop.

Also allows constructing blinded paths using this override.

3 months agoRemove the `std` feature implications from the `lightning` crate 2024-08-feature-cleanup-1
Matt Corallo [Sat, 17 Aug 2024 21:13:08 +0000 (21:13 +0000)]
Remove the `std` feature implications from the `lightning` crate

Now that we don't have to have everything in our entire ecosystem
use the same `std`/`no-std` feature combinations we should start by
untangling our own features a bit.

This takes one last step, removing the implications of the `std`
feature from the `lightning` crate.

3 months agoDrop the `_test_vectors` feature in favor of a `cfg` flag
Matt Corallo [Sat, 17 Aug 2024 21:06:52 +0000 (21:06 +0000)]
Drop the `_test_vectors` feature in favor of a `cfg` flag

This exists just for tests, so there's no reason for it to be
publicly visible.

3 months agoSomewhat clean up `ci-tests.sh` and sort by `RUSTFLAGS`
Matt Corallo [Sat, 17 Aug 2024 20:18:31 +0000 (20:18 +0000)]
Somewhat clean up `ci-tests.sh` and sort by `RUSTFLAGS`

3 months agoDrop the `no-std` feature from `lightning-rapid-gossip-sync`
Matt Corallo [Fri, 16 Aug 2024 20:32:58 +0000 (20:32 +0000)]
Drop the `no-std` feature from `lightning-rapid-gossip-sync`

Now that we don't have to have everything in our entire ecosystem
use the same `std`/`no-std` feature combinations we should start by
untangling our own features a bit.

This takes another step by removing the `no-std` feature entirely
from the `lightning-rapid-gossip-sync` crate and removing all
feature implications on dependencies from the remaining `std`
feature.

3 months agoDrop the `no-std` feature from `lightning-invoice`
Matt Corallo [Fri, 16 Aug 2024 19:17:42 +0000 (19:17 +0000)]
Drop the `no-std` feature from `lightning-invoice`

Now that we don't have to have everything in our entire ecosystem
use the same `std`/`no-std` feature combinations we should start by
untangling our own features a bit.

This takes another step by removing the `no-std` feature entirely
from the `lightning-invoice` crate and removing all feature
implications on dependencies from the remaining `std` feature.

3 months agoDrop the `no-std` feature from BP and drop feature implications
Matt Corallo [Fri, 16 Aug 2024 19:07:05 +0000 (19:07 +0000)]
Drop the `no-std` feature from BP and drop feature implications

Now that we don't have to have everything in our entire ecosystem
use the same `std`/`no-std` feature combinations we should start by
untangling our own features a bit.

This takes the first step by removing the `no-std` feature entirely
from the `lightning-background-processor` crate and removing most
feature implications on dependencies from the remaining `std`
feature.

It also addresses a CI oversight where we were not testing
`lightning-background-processor` without the `std` feature in CI at
all.

3 months agoEnsure we always pass a `path` for in-workspace dependencies
Matt Corallo [Fri, 16 Aug 2024 20:13:18 +0000 (20:13 +0000)]
Ensure we always pass a `path` for in-workspace dependencies

In order to ensure our crates depend on the workspace copies of
each other in test builds we need to override the crates.io
dependency with a local `path`.

We can do this in one of two ways - either specify the `path` in
the dependency listing in each crate's `Cargo.toml` or use the
workspace `Cargo.toml` to `patch` all dependencies. The first is
tedious while the second lets us have it all in one place. However,
the second option does break `cargo *` in individual crate
directories (forcing the use of `cargo -p crate *` instead) and
makes it rather difficult to depend on local versions of workspace
crates.

Thus, here we drop the `patch.crates-io` from our top-level
`Cargo.toml` entirely.

Still, we do update the `ci/ci-tests.sh` script here to use
`cargo -p crate` instead of switching to each crate's directory as
it allows `cargo` to use a shared `target` and may speed up tests.

3 months agoOptimize `BufReader` somewhat for the only used case
Matt Corallo [Fri, 16 Aug 2024 18:47:38 +0000 (18:47 +0000)]
Optimize `BufReader` somewhat for the only used case

`rust-bitcoin` doesn't ever actually *use* its `BufRead`
requirement when deserializing objects, and forcing it is somewhat
inefficient, so we optimize the only (actual) case here by passing
reads straight through to the backing stream.

3 months agoFix bug in `BufReader::fill_buf` when reaching EOF
Matt Corallo [Fri, 16 Aug 2024 18:46:24 +0000 (18:46 +0000)]
Fix bug in `BufReader::fill_buf` when reaching EOF

When we reach EOF we may return a full buffer when we should return
an empty one.

3 months agoMerge pull request #3240 from tnull/2024-08-add-ci-flag-for-bitcoind
Matt Corallo [Mon, 19 Aug 2024 14:53:36 +0000 (14:53 +0000)]
Merge pull request #3240 from tnull/2024-08-add-ci-flag-for-bitcoind

Disallow skipping tx-sync tests in CI

3 months agoRe-export `lightning_types` in top-level `lightning` modules 2024-08-new-types-export
Matt Corallo [Mon, 19 Aug 2024 14:37:03 +0000 (14:37 +0000)]
Re-export `lightning_types` in top-level `lightning` modules

Since we now have many types in one place, it makes sense to export
them in that place. Further, doing so finally somewhat starts to
reduce our `lightning::ln` module size, which historically is the
dumping ground for everything when most things really should be
top-level modules in `lightning`.

Here we take a step in the right direction by exporting
`lightning_types` as `lightning::types` and encouraging users to
use those paths directly rather than the ones in `lightning::ln`.

3 months agoTweak alignment and memory order in the `ProbabilisticScorer` 2023-12-cache-scoring-points
Matt Corallo [Mon, 11 Dec 2023 02:10:51 +0000 (02:10 +0000)]
Tweak alignment and memory order in the `ProbabilisticScorer`

During routing, the majority of our time is spent in the scorer.
Given the scorer isn't actually doing all that much computation,
this means we're quite sensitive to memory latency. Thus, the cache
lines our data sits on is incredibly important.

Here, we manually lay out the `ChannelLiquidity` and
`HistoricalLiquidityTracker` structs to ensure that we can do the
non-historical scoring and skip historical scoring for channels
with insufficient data by just looking at the same cache line the
channel's SCID is on.

Sadly, to do the full historical scoring we need to load a second
128-byte cache line pair, but we have some time to get there. We
might consider issuing a preload instruction in the future.

This improves performance a few percent.

3 months agoCache the total points tracked in our historical liquidity data
Matt Corallo [Sat, 9 Dec 2023 04:18:46 +0000 (04:18 +0000)]
Cache the total points tracked in our historical liquidity data

When we go to score a channel using the historical liquidity data,
the first thing we do is step through all the valid bucket
combinations, multiply the min and max bucket, and then add them
together to calculate the total number of points tracked. This
isn't a free operation, and for scorers without much data it
represents a large part of the total time spent scoring during
routefinding.

Thus, here we cache this value, updating it every time the buckets
are updated.

3 months agoChange the directed history tracker's storage of its direction
Matt Corallo [Sat, 9 Dec 2023 04:30:08 +0000 (04:30 +0000)]
Change the directed history tracker's storage of its direction

Rather than storing the two direction's buckets in
`HistoricalMinMaxBuckets` (renamed
`DirectedHistoricalLiquidityTracker`), we store a single reference
to the `HistoricalLiquidityTracker` as well as the direction bool.

This will allow us in the next commit to reference fields in the
`HistoricalLiquidityTracker` aside from the two directions.

3 months agoMake the historical bucket data private to `bucketed_history`
Matt Corallo [Sat, 9 Dec 2023 04:29:12 +0000 (04:29 +0000)]
Make the historical bucket data private to `bucketed_history`

In a comming commit we'll cache some additional data in the
historical bucket tracker. In order to do so, here we isolate the
buckets themselves into the `bucketed_history` module, reducing
the possibility of accidentally updating them directly without
updating caches.

3 months agoStore both min and max historical buckets in one, new, struct
Matt Corallo [Sat, 9 Dec 2023 03:32:40 +0000 (03:32 +0000)]
Store both min and max historical buckets in one, new, struct

In the coming commits we'll isolate historical bucket logic slightly
further, allowing us to cache some state. This is the first step
towards that, storing the historical liquidity information in a new
`HistoricalLiquidityTracker` rather than in the general
`ChannelLiquidity`.

3 months agoFormat `log_approx.rs` per rustfmt
Matt Corallo [Wed, 17 Jul 2024 20:00:58 +0000 (20:00 +0000)]
Format `log_approx.rs` per rustfmt

3 months agoMove log approximation from `scoring.rs` to its own file
Matt Corallo [Sat, 9 Dec 2023 00:36:47 +0000 (00:36 +0000)]
Move log approximation from `scoring.rs` to its own file

3 months agoMerge pull request #3242 from jkczyz/2024-08-payment-id-auth-api
valentinewallace [Mon, 19 Aug 2024 14:14:37 +0000 (10:14 -0400)]
Merge pull request #3242 from jkczyz/2024-08-payment-id-auth-api

Add `PaymentId` authentication to public API

3 months ago`rustfmt`: Drop `lightning-persister` from exclusion list
Elias Rohrer [Fri, 2 Aug 2024 21:33:58 +0000 (16:33 -0500)]
`rustfmt`: Drop `lightning-persister` from exclusion list

3 months ago`rustfmt`: Run on `lightning-persister`
Elias Rohrer [Fri, 2 Aug 2024 21:31:13 +0000 (16:31 -0500)]
`rustfmt`: Run on `lightning-persister`

3 months agoAdd PaymentId authentication to public API
Jeffrey Czyz [Wed, 14 Aug 2024 22:39:13 +0000 (17:39 -0500)]
Add PaymentId authentication to public API

When receiving an InvoiceError message, it should be authenticated
before using it to abandon the payment. Add methods to PaymentId's
public API for constructing and verifying an HMAC for use in
OffersContext::OutboundPayment. This allows other implementations of
OffersMessageHandler to construct the HMAC and authenticate the message.

3 months agoMerge pull request #3239 from arik-so/bitcoin-0.32.2-upgrade
Matt Corallo [Fri, 16 Aug 2024 20:13:26 +0000 (20:13 +0000)]
Merge pull request #3239 from arik-so/bitcoin-0.32.2-upgrade

Bitcoin 0.32.2 upgrade

3 months agoFix fuzz warnings.
Arik Sosman [Thu, 15 Aug 2024 06:57:14 +0000 (23:57 -0700)]
Fix fuzz warnings.

Version 0.32.2 of `rust-bitcoin` deprecates a number of methods that
are commonly used in this project, most visibly `txid()`, which is
now called `compute_txid()`. This resulted in a lot of warnings, and
this commit is part of a series that seeks to address that.

3 months agoFix lightning-transaction sync warnings.
Arik Sosman [Thu, 15 Aug 2024 02:52:01 +0000 (19:52 -0700)]
Fix lightning-transaction sync warnings.

Version 0.32.2 of `rust-bitcoin` deprecates a number of methods that
are commonly used in this project, most visibly `txid()`, which is
now called `compute_txid()`. This resulted in a lot of warnings, and
this commit is part of a series that seeks to address that.

3 months agoFix lightning-block-sync warnings.
Arik Sosman [Wed, 14 Aug 2024 20:31:40 +0000 (13:31 -0700)]
Fix lightning-block-sync warnings.

Version 0.32.2 of `rust-bitcoin` deprecates a number of methods that
are commonly used in this project, most visibly `txid()`, which is
now called `compute_txid()`. This resulted in a lot of warnings, and
this commit is part of a series that seeks to address that.

3 months agoFix lightning-background-processor warnings.
Arik Sosman [Wed, 14 Aug 2024 20:41:55 +0000 (13:41 -0700)]
Fix lightning-background-processor warnings.

Version 0.32.2 of `rust-bitcoin` deprecates a number of methods that
are commonly used in this project, most visibly `txid()`, which is
now called `compute_txid()`. This resulted in a lot of warnings, and
this commit is part of a series that seeks to address that.

3 months agoFix lightning warnings.
Arik Sosman [Fri, 16 Aug 2024 15:45:27 +0000 (08:45 -0700)]
Fix lightning warnings.

Version 0.32.2 of `rust-bitcoin` deprecates a number of methods that
are commonly used in this project, most visibly `txid()`, which is
now called `compute_txid()`. This resulted in a lot of warnings, and
this commit is part of a series that seeks to address that.