]> git.bitcoin.ninja Git - rust-lightning/log
rust-lightning
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 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 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.

3 months agoSuppress Taproot warnings.
Arik Sosman [Wed, 14 Aug 2024 18:50:40 +0000 (11:50 -0700)]
Suppress Taproot warnings.

Taproot is not yet being actively used, and this commit suppresses
the noisy warning generation.

3 months agoRemove secp256k1 dependency.
Arik Sosman [Wed, 14 Aug 2024 20:07:24 +0000 (13:07 -0700)]
Remove secp256k1 dependency.

3 months agoUpgrade rust-bitcoin to 0.32.2.
Arik Sosman [Fri, 16 Aug 2024 15:02:50 +0000 (08:02 -0700)]
Upgrade rust-bitcoin to 0.32.2.

3 months agoMerge pull request #3182 from valentinewallace/2024-07-expose-advance-bp
Matt Corallo [Fri, 16 Aug 2024 17:11:21 +0000 (17:11 +0000)]
Merge pull request #3182 from valentinewallace/2024-07-expose-advance-bp

Expose blinded paths' `advance_path_by_one`

3 months agoReturn a Result from verify_payment_id
Jeffrey Czyz [Fri, 16 Aug 2024 16:26:44 +0000 (11:26 -0500)]
Return a Result from verify_payment_id

3 months agoReimplement io::Cursor.
Arik Sosman [Thu, 15 Aug 2024 01:51:39 +0000 (18:51 -0700)]
Reimplement io::Cursor.

The `bitcoin::io` Cursor will miss a bunch of functionality that we were
using that we will reimplement here, most critically `set_position`.

3 months agoIntroduce io module.
Arik Sosman [Thu, 15 Aug 2024 01:49:22 +0000 (18:49 -0700)]
Introduce io module.

The rust-bitcoin upgrade will introduce `bitcoin::io` module, which
will be missing a necessary subset of traits.

To accommodate those traits' future implementations, we move the
`lightning::io` module to its own file, where we will be able to
implement the missing trait subset in the next commit.

3 months agoDrop Seek and SeekFrom usage.
Arik Sosman [Thu, 15 Aug 2024 19:22:59 +0000 (12:22 -0700)]
Drop Seek and SeekFrom usage.

In lieu of using `Seek` and `SeekFrom`, we will instead rely
exclusively on the `io::Cursor` type.

3 months agoSimplify Readable mutability.
Arik Sosman [Wed, 14 Aug 2024 21:25:56 +0000 (14:25 -0700)]
Simplify Readable mutability.

In anticipation of the rust-bitcoin upgrade, which incorporates its
own `io::Read` implementation, we need to make our usage compatible
with dropping `std::io` and `core2::io`.

Notably, in version 0.32.2, `bitcoin::io`'s `Read` is no longer
implemented for `&mut R where R: Read + ?Sized`, which results in
errors anytime `&mut &mut Readable` is passed instead of
`&mut Readable`.

This commit fixes those instances.

3 months agoDisallow skipping tx-sync tests in CI
Elias Rohrer [Wed, 14 Aug 2024 07:22:13 +0000 (09:22 +0200)]
Disallow skipping tx-sync tests in CI

Previously, we'd always skip tx-sync tests if the
`BITCOIND_EXE`/`ELECTRS_EXE` environment variables would be unset. While
this is especially fine for local testing, we still want to enforce
tests failing if somehow the `bitcoind`/`electrs` downloading or caching
in CI stops working. Here, we therefore add a `CI_ENV` variable that
indicates we're indeed running in CI, and only skip if it's unset.

3 months agoMake advance_path_by_one an associated method.
Valentine Wallace [Thu, 15 Aug 2024 22:18:51 +0000 (18:18 -0400)]
Make advance_path_by_one an associated method.

3 months agoTweak phrasing in Blinded{Message,Payment}Path::advance_path_by_one docs.
Valentine Wallace [Thu, 15 Aug 2024 21:57:51 +0000 (17:57 -0400)]
Tweak phrasing in Blinded{Message,Payment}Path::advance_path_by_one docs.

3 months agoMove NextMessageHop into blinded_path::message
Valentine Wallace [Fri, 9 Aug 2024 19:19:12 +0000 (12:19 -0700)]
Move NextMessageHop into blinded_path::message

It's only used for onion messages, not payments.

3 months agoMake BlindedPath type private.
Valentine Wallace [Tue, 13 Aug 2024 18:36:07 +0000 (14:36 -0400)]
Make BlindedPath type private.

Users should use the Blinded{Message,Payment}Path types instead.

3 months agoReduce visibility of BlindedMessagePath inner path.
Valentine Wallace [Tue, 13 Aug 2024 18:32:27 +0000 (14:32 -0400)]
Reduce visibility of BlindedMessagePath inner path.

Works towards making the inner BlindedPath struct private to the module.

3 months agoMerge pull request #3241 from TheBlueMatt/2024-08-ret-slice-not-ref-vec
valentinewallace [Thu, 15 Aug 2024 17:38:58 +0000 (13:38 -0400)]
Merge pull request #3241 from TheBlueMatt/2024-08-ret-slice-not-ref-vec

Return slices, rather than `Vec` references, in addresses

3 months agoReduce visibility of BlindedPaymentPath inner path.
Valentine Wallace [Tue, 13 Aug 2024 17:30:58 +0000 (13:30 -0400)]
Reduce visibility of BlindedPaymentPath inner path.

Works towards making the inner BlindedPath struct private to the module.

3 months agoAdd accessor methods for inner blinded path fields.
Valentine Wallace [Tue, 13 Aug 2024 18:28:02 +0000 (14:28 -0400)]
Add accessor methods for inner blinded path fields.

3 months agoMove public_intro_node util into Blinded{Message,Payment}Path
Valentine Wallace [Fri, 9 Aug 2024 19:55:33 +0000 (12:55 -0700)]
Move public_intro_node util into Blinded{Message,Payment}Path

Helps move towards making the BlindedPath struct private.

3 months agoMove compact blinded path util to message paths only.
Valentine Wallace [Fri, 9 Aug 2024 19:50:19 +0000 (12:50 -0700)]
Move compact blinded path util to message paths only.

It's only used for message paths, so let's move it there to help make the
BlindedPath struct private.

3 months agoExpose blinded paths' advance_path_by_one methods.
Valentine Wallace [Mon, 5 Aug 2024 23:30:31 +0000 (16:30 -0700)]
Expose blinded paths' advance_path_by_one methods.

Useful for LDK users that are using the onion messages module, like LNDK.

3 months agoAdd BlindedMessagePath type to disambiguate from blinded payment paths.
Valentine Wallace [Mon, 5 Aug 2024 23:18:51 +0000 (16:18 -0700)]
Add BlindedMessagePath type to disambiguate from blinded payment paths.

3 months agoAdd BlindedPaymentPath type, to disambiguate from message paths.
Valentine Wallace [Mon, 5 Aug 2024 22:18:26 +0000 (15:18 -0700)]
Add BlindedPaymentPath type, to disambiguate from message paths.

Next up, we'll add a BlindedMessagePath type so the API is clear which type of
path is expected in each context.

3 months agoReturn slices, rather than `Vec` references, in addresses 2024-08-ret-slice-not-ref-vec
Matt Corallo [Wed, 14 Aug 2024 19:36:46 +0000 (19:36 +0000)]
Return slices, rather than `Vec` references, in addresses

Its a bit strange to return a reference to a `Vec` in Rust, when a
slice is really intended as the way to do so. Worse, the bindings
don't know how to map a reference to a `Vec` (but do have code to
map a slice of `Clone`able objects).

Here, we move `NodeAnnouncementInfo::addresses` to return a slice,
though to do so we have to adapt the `WithoutLength` `Writeable`
impl to support slices as well.

3 months agoMerge pull request #3192 from jkczyz/2024-07-invoice-error-auth
Matt Corallo [Wed, 14 Aug 2024 18:28:39 +0000 (18:28 +0000)]
Merge pull request #3192 from jkczyz/2024-07-invoice-error-auth

Authenticate `InvoiceError` messages

3 months agoMake PaymentFailureReason downgradable
Jeffrey Czyz [Fri, 9 Aug 2024 16:07:35 +0000 (11:07 -0500)]
Make PaymentFailureReason downgradable

The PaymentFailureReason variants for invoice request failures will
cause downgrades to break. Instead, use a new TLV for the reason and
continue to write the old TLV, only use None for the new reasons.

3 months agoMake PaymentFailureReason upgradable
Jeffrey Czyz [Wed, 7 Aug 2024 22:16:54 +0000 (17:16 -0500)]
Make PaymentFailureReason upgradable

This allows downgrading to version 0.0.124 or later and using None for a
PaymentFailureReason that was added after.

3 months agoAdd PaymentFailureReason::InvoiceRequestRejected
Jeffrey Czyz [Tue, 6 Aug 2024 23:33:51 +0000 (18:33 -0500)]
Add PaymentFailureReason::InvoiceRequestRejected

Instead of re-using PaymentFailureReason::RecipientRejected, define a
new InvoiceRequestRejected variant for when an InvoiceError is received
instead of a Bolt12Invoice. This allows user to differentiate the cause
of the failure.

3 months agoAdd PaymentFailureReason::InvoiceRequestExpired
Jeffrey Czyz [Tue, 6 Aug 2024 23:13:45 +0000 (18:13 -0500)]
Add PaymentFailureReason::InvoiceRequestExpired

Now that Event::PaymentFailed is generated when an InvoiceRequest times
out, define a new PaymentFailureReason for this situation.

3 months agoAdd pending changelog for Event::PaymentFailed
Jeffrey Czyz [Wed, 7 Aug 2024 21:15:35 +0000 (16:15 -0500)]
Add pending changelog for Event::PaymentFailed

3 months agoRemove Event::InvoiceRequestFailed
Jeffrey Czyz [Tue, 6 Aug 2024 22:51:16 +0000 (17:51 -0500)]
Remove Event::InvoiceRequestFailed

Now that Event::PaymentFailed has an option payment_hash, it can be used
in replace of Event::InvoiceRequestFailed. This allows for including a
reason when abandoning a payment before an invoice is received.

3 months agoMake payment_hash optional in Event::PaymentFailed
Jeffrey Czyz [Tue, 6 Aug 2024 22:17:52 +0000 (17:17 -0500)]
Make payment_hash optional in Event::PaymentFailed

When abandoning a BOLT12 payment before a Bolt12Invoice is received, an
Event::InvoiceRequestFailed is generated and the abandonment reason is
lost. Make payment_hash optional in Event::PaymentFailed so that
Event::InvoiceRequestFailed can be removed in favor of it.

3 months agoTest Bolt12Invoice with unknown required features
Jeffrey Czyz [Wed, 31 Jul 2024 22:04:39 +0000 (17:04 -0500)]
Test Bolt12Invoice with unknown required features

3 months agoRemove unused macro param
Jeffrey Czyz [Wed, 31 Jul 2024 21:08:20 +0000 (16:08 -0500)]
Remove unused macro param

3 months agoAdd InvoiceBuilder::features_unchecked
Jeffrey Czyz [Wed, 31 Jul 2024 20:57:14 +0000 (15:57 -0500)]
Add InvoiceBuilder::features_unchecked

In order to test handling of unknown required features in a
Bolt12Invoice, add a test-only function to allow setting arbitrary
feature bits.

3 months agoUse a smaller bit for UnknownFeature
Jeffrey Czyz [Wed, 31 Jul 2024 20:12:40 +0000 (15:12 -0500)]
Use a smaller bit for UnknownFeature

When testing Bolt12Invoice unknown require feature handling, a large
feature bit can cause SendError::TooBigPacket when creating an onion
message. Use a smaller feature bit for UnknownFeature, which also has
the added benefit of reducing test output.

3 months agoMove BOLT12 invoice features check
Jeffrey Czyz [Mon, 29 Jul 2024 21:10:43 +0000 (16:10 -0500)]
Move BOLT12 invoice features check

When handling a BOLT12 invoice, and invoice error is sent if the invoice
contains unknown required features. However, since the payment is still
in state AwaitingInvoice, abandoning it results in losing the reason
since an InvoiceRequestFailed event would be generated. Move the check
to PendingOutboundPayments such that the payment is first moved to state
InvoiceReceived so that a PaymentFailed event is generated instead.

3 months agoDon't include HMAC in Refund paths
Jeffrey Czyz [Fri, 2 Aug 2024 14:39:52 +0000 (09:39 -0500)]
Don't include HMAC in Refund paths

Refunds are typically communicated via QR code, where a smaller size is
desirable. Make the HMAC in OutboundPayment data optional such that it
is elided from blinded paths used in refunds. This prevents abandoning
refunds if the reader sends an invoice_error instead of an invoice
message. However, this use case isn't necessary as the corresponding
outbound payment will either timeout when the refund expires or can be
explicitly abandoned by the creator.

3 months agoDon't use UserAbandoned reason for auto-failing
Jeffrey Czyz [Wed, 24 Jul 2024 22:05:42 +0000 (17:05 -0500)]
Don't use UserAbandoned reason for auto-failing

A BOLT12 payment may be abandoned when handling the invoice or when
receiving an InvoiceError message. When abandoning the payment, don't
use UserAbandoned as the reason since that is meant for when the user
calls ChannelManager::abandon_payment.

3 months agoDon't abandon payments for duplicate invoices
Jeffrey Czyz [Wed, 24 Jul 2024 21:33:02 +0000 (16:33 -0500)]
Don't abandon payments for duplicate invoices

When making an outbound BOLT12 payment, multiple invoices may be
received for the same payment id. Instead of abandoning the payment when
a duplicate invoice received, simply ignore it without responding with
an InvoiceError. This prevents abandoning in-progress payments and
sending unnecessary onion messages.

3 months agoAuthenticate payment_id from OffersContext
Jeffrey Czyz [Thu, 18 Jul 2024 16:54:33 +0000 (11:54 -0500)]
Authenticate payment_id from OffersContext

Before abandoning a payment when receiving an InvoiceError, verify that
the PaymentId included in the OffersContext with the included HMAC. This
prevents a malicious actor sending an InvoiceError with a known payment
id from abandoning our payment.

3 months agoAdd an HMAC to OffersContext::OutboundPayment
Jeffrey Czyz [Thu, 18 Jul 2024 16:45:09 +0000 (11:45 -0500)]
Add an HMAC to OffersContext::OutboundPayment

When receiving an InvoiceError in response to an InvoiceRequest, the
corresponding payment should be abandoned. Add an HMAC to
OffersContext::OutboundPayment such that the payment ID can be
authenticated prior to abandoning the payment.

3 months agoAdd Sha256 HMAC (de)serialization
Jeffrey Czyz [Thu, 18 Jul 2024 16:42:57 +0000 (11:42 -0500)]
Add Sha256 HMAC (de)serialization

An HMAC needs to be included in OffersContext::OutboundPayment to
authenticate the included PaymentId. Implement Readable and Writeable to
allow for this.

3 months agoHMAC construction and verification for PaymentID
Jeffrey Czyz [Thu, 18 Jul 2024 16:38:44 +0000 (11:38 -0500)]
HMAC construction and verification for PaymentID

When receiving an InvoiceError in response to an InvoiceRequest, the
corresponding payment should be abandoned. Add functions for
constructing and verifying an HMAC over a Payment ID to allow for this.

3 months agoMerge pull request #3212 from dunxen/2024-07-sensible-balances
valentinewallace [Wed, 14 Aug 2024 15:22:05 +0000 (11:22 -0400)]
Merge pull request #3212 from dunxen/2024-07-sensible-balances

Accuracy fixes and differentiating sources for `Balance`

3 months agoMerge pull request #3234 from TheBlueMatt/2024-08-lightning-dep-inv
Matt Corallo [Wed, 14 Aug 2024 14:27:39 +0000 (14:27 +0000)]
Merge pull request #3234 from TheBlueMatt/2024-08-lightning-dep-inv

Swap the dep order between `lightning` and `lightning-invoice`

3 months agoMerge pull request #3020 from tnull/2024-04-drop-electrsd-autodownload-for-good
Matt Corallo [Tue, 13 Aug 2024 23:23:43 +0000 (23:23 +0000)]
Merge pull request #3020 from tnull/2024-04-drop-electrsd-autodownload-for-good

Drop `electrsd`'s auto-download feature for good

3 months agoEnable caching for `bitcoind`/`electrs` in CI
Elias Rohrer [Thu, 1 Aug 2024 15:47:45 +0000 (10:47 -0500)]
Enable caching for `bitcoind`/`electrs` in CI

3 months ago`rustfmt` new files added in the past few commits 2024-08-lightning-dep-inv
Matt Corallo [Fri, 9 Aug 2024 15:27:38 +0000 (15:27 +0000)]
`rustfmt` new files added in the past few commits

The past handful of commits were mostly moving code around, so to
aid reviewers violated our `rustfmt` rules. Here we rectify that by
`rustfmt`'ing the newly-added files.