]> git.bitcoin.ninja Git - rust-lightning/log
rust-lightning
10 months agoAvoid enums containing references with lifetimes
Matt Corallo [Sun, 5 Mar 2023 20:38:42 +0000 (20:38 +0000)]
Avoid enums containing references with lifetimes

Having struct fields with references to other structs is tough in
our bindings logic, but even worse if the fields are in an enum.
Its simplest to just take the clone penalty here.

10 months agoExport `outbound_payment` structs in their respective modules
Matt Corallo [Tue, 28 Feb 2023 21:45:14 +0000 (21:45 +0000)]
Export `outbound_payment` structs in their respective modules

Re-exports in Rust make `use` statements a little shorter, but for
otherwise don't materially change a crate's API. Sadly, the C
bindings generator currently can't figure out re-exports, but it
also exports everything into one global namespace, so it doesn't
matter much anyway.

10 months agoUse an explicit `Sign` type on the `ChannelMonitor` read tuple
Matt Corallo [Sat, 24 Dec 2022 04:16:48 +0000 (04:16 +0000)]
Use an explicit `Sign` type on the `ChannelMonitor` read tuple

The bindings currently get confused by the implicit `Sign` type, so
we temporarily remove it on the `impl` here.

10 months agoRestrict ChannelInfo::as_directed_from visibility
Jeffrey Czyz [Tue, 29 Mar 2022 15:20:39 +0000 (10:20 -0500)]
Restrict ChannelInfo::as_directed_from visibility

Bindings can't handle references in return types, so reduce the
visibility to pub(crate).

10 months agoMake `as_directed_to` non-public
Matt Corallo [Tue, 1 Mar 2022 03:46:52 +0000 (03:46 +0000)]
Make `as_directed_to` non-public

...as the bindings generation does not currently have the ability
to map a reference to a `NodeId` inside a tuple.

10 months agoStop relying on a `Clone`able `NetworkGraph` ref in `DefaultRouter`
Matt Corallo [Tue, 23 Jan 2024 19:55:24 +0000 (19:55 +0000)]
Stop relying on a `Clone`able `NetworkGraph` ref in `DefaultRouter`

While there's not really much harm in requiring a `Clone`able
reference (they almost always are), it does make our bindings
struggle a bit as they don't support multi-trait bounds (as it
would require synthesizing a new C trait, which the bindings don't
do automatically). Luckily, there's really no reason for it, and we
can just call the `DefaultMessageRouter` directly when we want to
route a message.

10 months ago[bindings] Move additional score params from `&()` to `Default`
Matt Corallo [Tue, 23 Jan 2024 06:19:24 +0000 (06:19 +0000)]
[bindings] Move additional score params from `&()` to `Default`

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

10 months agoDrop manual `Debug` impl on RGS' `GraphSyncError`
Matt Corallo [Tue, 23 Jan 2024 19:20:05 +0000 (19:20 +0000)]
Drop manual `Debug` impl on RGS' `GraphSyncError`

As it does the same thing as a derived `Debug` does anyway.

10 months agoMove RGS `GraphSyncError` into the top-level module
Matt Corallo [Thu, 18 Jan 2024 20:53:20 +0000 (20:53 +0000)]
Move RGS `GraphSyncError` into the top-level module

The top-level module is only a few hundred lines, so there's not a
lot of reason to hide the `GraphSyncError` in its own module.
Instead, we simply move it to the top-level `lib.rs`, which doesn't
change the public API as it was previously re-exported at the top
level.

10 months agoStore `EntropySource` in `DefaultRouter` instead of passing it
Matt Corallo [Tue, 23 Jan 2024 19:49:36 +0000 (19:49 +0000)]
Store `EntropySource` in `DefaultRouter` instead of passing it

...as an arg to `Router`. Passing an `EntropySource` around all
the time is a bit strange as the `Router` may or may not actually
use it, and the `DefaultRouter` can just as easily store it.

10 months ago[bindings] No-export `RouteHopCandidate` lifetime'd fields
Matt Corallo [Tue, 23 Jan 2024 01:16:46 +0000 (01:16 +0000)]
[bindings] No-export `RouteHopCandidate` lifetime'd fields

The bindings cannot express lifetimes, so exposing any field which
is a reference (and not `clone`-able, at least for garbage
collected language bindings) is unsafe for those expecting a
high-level interface.

Thus, we simply no-export the `RouteHopCandidate` inner struct
fields which are references (there are relevant accessors for them
anyway).

10 months ago[bindings] Mark `WithContext` log wrapper with no-export
Matt Corallo [Thu, 18 Jan 2024 00:42:55 +0000 (00:42 +0000)]
[bindings] Mark `WithContext` log wrapper with no-export

There's not a lot of reason for downstream users to use the
`WithContext` wrapper, it mostly exists for our own downstream
crates anyway, and dealing with lifetimes in bindings isn't super
practical, so simply no-export it.

10 months ago[bindings] Drop the lifetime bound on `Record` for bindings builds
Matt Corallo [Wed, 20 Dec 2023 05:17:43 +0000 (05:17 +0000)]
[bindings] Drop the lifetime bound on `Record` for bindings builds

Because log `Record`s are now being passed by ownership to `log`,
the bindings get quite annoyed that there's a lifetime hanging
around. We already don't use this lifetime in bindings (the
`FormatArgs` is converted to a string and stored on the heap), so
we can just drop the lifetime, even though it requires some
macro'ing of the struct definition to do so.

10 months agoMerge pull request #2844 from TheBlueMatt/2024-01-cut-121 v0.0.121
Matt Corallo [Mon, 22 Jan 2024 23:55:35 +0000 (23:55 +0000)]
Merge pull request #2844 from TheBlueMatt/2024-01-cut-121

Release 0.0.121

10 months agoBump versions to LDK 0.0.121/invoice 0.29 2024-01-cut-121
Matt Corallo [Mon, 22 Jan 2024 22:22:20 +0000 (22:22 +0000)]
Bump versions to LDK 0.0.121/invoice 0.29

10 months agoAdd CHANGELOG entry for 0.0.121
Matt Corallo [Mon, 22 Jan 2024 22:21:16 +0000 (22:21 +0000)]
Add CHANGELOG entry for 0.0.121

10 months agoMerge pull request #2841 from TheBlueMatt/2024-01-batch-deadlock
Matt Corallo [Mon, 22 Jan 2024 22:30:59 +0000 (22:30 +0000)]
Merge pull request #2841 from TheBlueMatt/2024-01-batch-deadlock

Fix deadlock when handling bad calls to `batch_funding.._generated`

10 months agoMerge pull request #2842 from jkczyz/2024-01-fix-peer-handler-unwrap
Matt Corallo [Mon, 22 Jan 2024 22:30:56 +0000 (22:30 +0000)]
Merge pull request #2842 from jkczyz/2024-01-fix-peer-handler-unwrap

Fix panic when peer is mid-handshake

10 months agoRemove unnecessary unwraps
Jeffrey Czyz [Mon, 22 Jan 2024 22:26:54 +0000 (16:26 -0600)]
Remove unnecessary unwraps

10 months agoFix panic when peer is mid-handshake
Jeffrey Czyz [Thu, 18 Jan 2024 21:34:19 +0000 (15:34 -0600)]
Fix panic when peer is mid-handshake

Peer::their_node_id is set to Some during the handshake process.
However, df3ab2ee2753e7f9ec02ddf1c8a51db77c50e35d accesses the field
unconditionally, causing a panic. This may be triggered if a gossip
message is received mid-handshake from another peer or if the user calls
broadcast_node_announcement during this time. The latter tends to be
executed on a timer.

Ensure that Peer::their_node_id is only accessed once the handshake is
complete.

10 months agoFix deadlock when handling bad calls to `batch_funding.._generated` 2024-01-batch-deadlock
Matt Corallo [Mon, 22 Jan 2024 20:26:32 +0000 (20:26 +0000)]
Fix deadlock when handling bad calls to `batch_funding.._generated`

When handling calls to `batch_funding_transaction_generated` which
were missing outputs for one of the batch channels, we'd previously
deadlock when trying to clean up the now-closed channels. This
fixes that and adds a new test case for it.

Found by the full_stack_target fuzzer.

10 months agoMerge pull request #2835 from TheBlueMatt/2024-01-cut-120
Elias Rohrer [Fri, 19 Jan 2024 20:41:51 +0000 (21:41 +0100)]
Merge pull request #2835 from TheBlueMatt/2024-01-cut-120

Change v0.0.120 release name

10 months agoChange v0.0.120 release name 2024-01-cut-120
Matt Corallo [Wed, 17 Jan 2024 23:18:47 +0000 (23:18 +0000)]
Change v0.0.120 release name

"Un"blinded makes more sense, since the fuzzer was unblinded :)

10 months agoMerge pull request #2834 from TheBlueMatt/2024-01-cut-120 v0.0.120
Matt Corallo [Wed, 17 Jan 2024 23:02:24 +0000 (23:02 +0000)]
Merge pull request #2834 from TheBlueMatt/2024-01-cut-120

Cut 0.0.120

10 months agoBump crate versions to 0.0.120/invoice 0.28
Matt Corallo [Wed, 17 Jan 2024 21:25:50 +0000 (21:25 +0000)]
Bump crate versions to 0.0.120/invoice 0.28

10 months agoAdd CHANGELOG entry for 0.0.120
Matt Corallo [Wed, 17 Jan 2024 21:00:26 +0000 (21:00 +0000)]
Add CHANGELOG entry for 0.0.120

10 months agoMerge pull request #2818 from valentinewallace/2024-01-blinded-path-retries
Matt Corallo [Wed, 17 Jan 2024 21:21:36 +0000 (21:21 +0000)]
Merge pull request #2818 from valentinewallace/2024-01-blinded-path-retries

Avoid retrying over previously failed blinded paths

10 months agoMerge pull request #2828 from TheBlueMatt/2024-01-crypto-module
valentinewallace [Wed, 17 Jan 2024 17:53:02 +0000 (12:53 -0500)]
Merge pull request #2828 from TheBlueMatt/2024-01-crypto-module

Move cryptographic algorithms and utilities to a new `crypto` mod

10 months agoTest that we won't retry over previously failed blinded paths.
Valentine Wallace [Tue, 9 Jan 2024 16:58:13 +0000 (11:58 -0500)]
Test that we won't retry over previously failed blinded paths.

10 months agoTest util: separate out code to construct a blinded path.
Valentine Wallace [Tue, 9 Jan 2024 16:53:51 +0000 (11:53 -0500)]
Test util: separate out code to construct a blinded path.

10 months agoAvoid building routes over previously failed blinded payment paths.
Valentine Wallace [Tue, 9 Jan 2024 16:52:37 +0000 (11:52 -0500)]
Avoid building routes over previously failed blinded payment paths.

10 months agoStore previously failed blinded paths on outbound payment failure.
Valentine Wallace [Tue, 9 Jan 2024 16:32:38 +0000 (11:32 -0500)]
Store previously failed blinded paths on outbound payment failure.

Useful so we don't retry over these paths.

10 months agoPersist previously failed blinded paths in RouteParameters.
Valentine Wallace [Tue, 9 Jan 2024 16:28:38 +0000 (11:28 -0500)]
Persist previously failed blinded paths in RouteParameters.

Useful so we don't retry over these paths.

10 months agoAdd failed_within_blinded_path to DecodedOnionFailure.
Valentine Wallace [Fri, 12 Jan 2024 16:35:08 +0000 (11:35 -0500)]
Add failed_within_blinded_path to DecodedOnionFailure.

Will be used to ensure correctness when we store previously failed blinded
paths to avoid retrying over them.

10 months agoAdd failed_within_blinded_path to onion util internal struct.
Valentine Wallace [Fri, 12 Jan 2024 01:11:14 +0000 (20:11 -0500)]
Add failed_within_blinded_path to onion util internal struct.

Will be used to ensure correctness when we store previously failed blinded
paths to avoid retrying over them.

10 months agoMerge pull request #2831 from jkczyz/2024-01-fix-cltv-expiry-delta
Matt Corallo [Wed, 17 Jan 2024 00:47:48 +0000 (00:47 +0000)]
Merge pull request #2831 from jkczyz/2024-01-fix-cltv-expiry-delta

Use consistent `cltv_expiry_delta` in `ForwardTlvs`

10 months agoMerge pull request #2832 from p2pderivatives/fix-ln-net-tokio-dropping-messages
Matt Corallo [Wed, 17 Jan 2024 00:37:09 +0000 (00:37 +0000)]
Merge pull request #2832 from p2pderivatives/fix-ln-net-tokio-dropping-messages

Fix lightning-net-tokio sometimes dropping messages

10 months agoMerge pull request #2812 from valentinewallace/2023-12-blinded-forwarding
Matt Corallo [Wed, 17 Jan 2024 00:28:30 +0000 (00:28 +0000)]
Merge pull request #2812 from valentinewallace/2023-12-blinded-forwarding

Complete route blinding support

10 months agoFix lightning-net-tokio sometimes dropping messages
Tibo-lg [Wed, 17 Jan 2024 00:20:30 +0000 (09:20 +0900)]
Fix lightning-net-tokio sometimes dropping messages

10 months agoUse consistent cltv_expiry_delta in ForwardTlvs
Jeffrey Czyz [Thu, 11 Jan 2024 19:13:12 +0000 (13:13 -0600)]
Use consistent cltv_expiry_delta in ForwardTlvs

When converting from CounterpartyForwardingInfo to PaymentRelay, the
cltv_expiry_delta is copied. Then, when forming a blinded payment path,
the value is mutated so that esoteric values don't reveal information
about the path. However, the value was only used in computing
PaymentConstraints and wasn't actually updated in PaymentRelay. Move the
logic for modifying the cltv_expiry_delta to the conversion code to
avoid this inconsistency.

10 months agoAdvertise route blinding feature as supported.
Valentine Wallace [Thu, 11 Jan 2024 18:47:17 +0000 (13:47 -0500)]
Advertise route blinding feature as supported.

Now that we fully support forwarding blinded payments, we should advertise
support so nodes on the network can include us in their blinded paths.

10 months agoFix sender double-including shadow offset in CLTV expiry height.
Valentine Wallace [Wed, 20 Dec 2023 19:04:04 +0000 (14:04 -0500)]
Fix sender double-including shadow offset in CLTV expiry height.

The excess delta is included in the final RouteHop::cltv_expiry_delta, so by
adding it explicitly to cur_cltv we were erroneously including it twice in the
total cltv expiry.

This could've add up to an extra MAX_SHADOW_CLTV_DELTA_OFFSET (432) blocks to
the total cltv expiry.

10 months agoRename test var to be more descriptive.
Valentine Wallace [Wed, 20 Dec 2023 19:00:17 +0000 (14:00 -0500)]
Rename test var to be more descriptive.

10 months agoComplete remaining TODOs for failing blinded non-intro forwards.
Valentine Wallace [Mon, 18 Dec 2023 19:42:07 +0000 (14:42 -0500)]
Complete remaining TODOs for failing blinded non-intro forwards.

10 months agoAdd failure mode info to BlindedForward struct.
Valentine Wallace [Mon, 18 Dec 2023 19:36:57 +0000 (14:36 -0500)]
Add failure mode info to BlindedForward struct.

See added docs.

10 months agoMove cryptographic algorithms and utilities to a new `crypto` mod 2024-01-crypto-module
Matt Corallo [Mon, 15 Jan 2024 01:25:10 +0000 (01:25 +0000)]
Move cryptographic algorithms and utilities to a new `crypto` mod

As we'd generally like the `lightning` crate to, over time, have
more modules rather than being very monolithic, we should move the
cryptographic things into their own module, which we do here.

We also take this opportunity to move stream adapters into their
own module and make clear that the ChaChaPoly `decrypt` method is
variable time.

10 months agoMerge pull request #2824 from shuoer86/main
Elias Rohrer [Mon, 15 Jan 2024 09:38:03 +0000 (10:38 +0100)]
Merge pull request #2824 from shuoer86/main

Fix typos

10 months agoFix typo lightning/src/util/wakers.rs
shuoer86 [Fri, 12 Jan 2024 12:46:47 +0000 (20:46 +0800)]
Fix typo lightning/src/util/wakers.rs

10 months agoFix typo lightning/src/routing/router.rs
shuoer86 [Fri, 12 Jan 2024 12:46:40 +0000 (20:46 +0800)]
Fix typo lightning/src/routing/router.rs

10 months agoFix typo lightning/src/ln/peer_handler.rs
shuoer86 [Fri, 12 Jan 2024 12:46:33 +0000 (20:46 +0800)]
Fix typo lightning/src/ln/peer_handler.rs

10 months agoFix typo lightning-invoice/src/ser.rs
shuoer86 [Fri, 12 Jan 2024 12:46:26 +0000 (20:46 +0800)]
Fix typo lightning-invoice/src/ser.rs

10 months agoFix typo CONTRIBUTING.md
shuoer86 [Fri, 12 Jan 2024 12:46:16 +0000 (20:46 +0800)]
Fix typo CONTRIBUTING.md

10 months agoMerge pull request #2800 from optout21/channel-close-add-funding
Matt Corallo [Thu, 11 Jan 2024 19:35:26 +0000 (19:35 +0000)]
Merge pull request #2800 from optout21/channel-close-add-funding

Add channel funding txo to Channel Event::ChannelClosed

10 months agoMerge pull request #2822 from TheBlueMatt/2024-01-pm-dyn-ref
Elias Rohrer [Thu, 11 Jan 2024 17:41:01 +0000 (18:41 +0100)]
Merge pull request #2822 from TheBlueMatt/2024-01-pm-dyn-ref

Drop `PeerManager` type bound on `UtxoLookup` entirely

10 months agoMake BlindedFailure enum pub.
Valentine Wallace [Mon, 18 Dec 2023 19:27:12 +0000 (14:27 -0500)]
Make BlindedFailure enum pub.

Necessary to include it in the public PendingHTLCInfo struct in the next commit.

10 months agoTest successful payment to 3-hop blinded path.
Valentine Wallace [Mon, 18 Dec 2023 19:16:02 +0000 (14:16 -0500)]
Test successful payment to 3-hop blinded path.

10 months agoFix final blinded hop CLTV expiry on send.
Valentine Wallace [Wed, 20 Dec 2023 00:16:37 +0000 (19:16 -0500)]
Fix final blinded hop CLTV expiry on send.

Previously, we were setting the final blinded hop's CLTV expiry height to
best_block_height + total_blinded_path_cltv_delta + shadow_cltv_offset. This is
incorrect, it should instead be set to best_block_height + shadow_cltv_offset
only -- it doesn't make sense to include the delta for the other blinded hops
in the final hop's expiry.

The reason this too-high final cltv value didn't cause test failures previously
is because of a 2nd bug that is fixed in an upcoming commit where the sender
adds the shadow offset twice to the total path CLTV expiry. This 2nd offset
meant that intermediate nodes had some buffer CLTV to subtract their delta from
while still (usually) have enough leftover to meet the expiry in the final hop's
onion.

10 months agoSupport forwarding blinded HTLCs as non-intro node.
Valentine Wallace [Mon, 18 Dec 2023 19:15:48 +0000 (14:15 -0500)]
Support forwarding blinded HTLCs as non-intro node.

Error handling will be completed in upcoming commit(s).

10 months agoMerge pull request #2801 from valentinewallace/2023-12-rb-groundwork-followups
valentinewallace [Thu, 11 Jan 2024 16:30:46 +0000 (11:30 -0500)]
Merge pull request #2801 from valentinewallace/2023-12-rb-groundwork-followups

#2128 follow-ups

10 months agoMerge pull request #2820 from TheBlueMatt/2024-01-fuzz-ooo-monitor-updates
valentinewallace [Thu, 11 Jan 2024 16:22:34 +0000 (11:22 -0500)]
Merge pull request #2820 from TheBlueMatt/2024-01-fuzz-ooo-monitor-updates

Test individual monitor update compl in chanmon_consistency fuzzer

10 months agoMerge pull request #2821 from TheBlueMatt/2024-01-om-direct-export
valentinewallace [Thu, 11 Jan 2024 14:52:00 +0000 (09:52 -0500)]
Merge pull request #2821 from TheBlueMatt/2024-01-om-direct-export

Expose `onion_message` items directly rather than via re-exports

10 months agoAdd channel funding txo to Channel Event::ChannelClosed
optout [Thu, 11 Jan 2024 08:15:53 +0000 (09:15 +0100)]
Add channel funding txo to Channel Event::ChannelClosed

10 months agoMerge pull request #2791 from valentinewallace/2023-12-multihop-recv-followups
Matt Corallo [Thu, 11 Jan 2024 00:04:39 +0000 (00:04 +0000)]
Merge pull request #2791 from valentinewallace/2023-12-multihop-recv-followups

Follow-ups to #2688

10 months agoExpose `onion_message` items directly rather than via re-exports 2024-01-om-direct-export
Matt Corallo [Wed, 10 Jan 2024 18:27:57 +0000 (18:27 +0000)]
Expose `onion_message` items directly rather than via re-exports

When we originally added the `onion_message` module, there weren't
a lot of public items in it, and it didn't make a lot of sense to
export the whole sub-module structure publicly. So, instead, we
exported the public items via re-exports directly in the
`onion_message` top-level module. However, as time went on, more
and more things entered the module, which left the top-level module
rather cluttered.

Worse, in 0.0.119, we exposed
`onion_message::messenger::SendSuccess` via the return type of
`send_message`, but forgot to re-export the enum itself, making
it impossible to actually use from external code.

Here we address both issues and simply replace the re-export with
the underlying sub-module structure.

10 months agoMerge pull request #2809 from TheBlueMatt/2023-12-closing-event-cleanup-fixes
Matt Corallo [Wed, 10 Jan 2024 22:37:07 +0000 (22:37 +0000)]
Merge pull request #2809 from TheBlueMatt/2023-12-closing-event-cleanup-fixes

Clean Up Funding Error Handling and shutdown

10 months agoDrop `PeerManager` type bound on `UtxoLookup` entirely 2024-01-pm-dyn-ref
Matt Corallo [Wed, 10 Jan 2024 22:24:43 +0000 (22:24 +0000)]
Drop `PeerManager` type bound on `UtxoLookup` entirely

In 67659677d4fdb6bf418d66dfa37c61706425232b we relaxed the bounds
set on `UtxoLookup` to enable those using `RoutingMessageHandler`
other than `P2PGossipSync` to use `UtxoLookup`. Sadly, because this
requires having a concrete `PeerManager` type which does *not* use
`UtxoLookup` in the `RoutingMessageHandler` type, this broke users
who were directly using `P2PGossipSync`.

We could split `UtxoLookup` into two, with different bounds, for
the two use-cases, but instead here we simply switch to storing a
reference to the `PeerManager` via a `dyn Fn` which allows us to
wake the `PeerManager` when we need to.

Fixes #2813

10 months agoRename parameter from err_packet to err_contents.
Valentine Wallace [Wed, 13 Dec 2023 21:27:54 +0000 (16:27 -0500)]
Rename parameter from err_packet to err_contents.

This name is more accurate since the method has been generalized to support
malformed HTLCs.

10 months agoRemove outdated comment.
Valentine Wallace [Wed, 13 Dec 2023 19:23:23 +0000 (14:23 -0500)]
Remove outdated comment.

10 months agoNormalize order of (sha256_of_onion, failure_code) in trait.
Valentine Wallace [Wed, 13 Dec 2023 19:20:51 +0000 (14:20 -0500)]
Normalize order of (sha256_of_onion, failure_code) in trait.

This helps avoid destructuring the tuple.

10 months agoDRY malformed HTLC handling during htlc batch processing.
Valentine Wallace [Wed, 13 Dec 2023 19:15:58 +0000 (14:15 -0500)]
DRY malformed HTLC handling during htlc batch processing.

10 months agoFix logger usage during batched htlc processing of malforms.
Valentine Wallace [Wed, 13 Dec 2023 19:09:16 +0000 (14:09 -0500)]
Fix logger usage during batched htlc processing of malforms.

Introduced due to a rebase error.

10 months agoClean up code DRY'd in previous commit.
Valentine Wallace [Wed, 10 Jan 2024 16:19:09 +0000 (11:19 -0500)]
Clean up code DRY'd in previous commit.

10 months agoRename OutboundOnionPayload::BlindedReceive::amt_msat to be more descriptive.
Valentine Wallace [Thu, 14 Dec 2023 20:34:51 +0000 (15:34 -0500)]
Rename OutboundOnionPayload::BlindedReceive::amt_msat to be more descriptive.

10 months agoRename OutboundOnionPayload::Receive::amt_msat to be more descriptive.
Valentine Wallace [Thu, 14 Dec 2023 20:32:34 +0000 (15:32 -0500)]
Rename OutboundOnionPayload::Receive::amt_msat to be more descriptive.

10 months agoRename InboundOnionPayload::BlindedReceive::amt_msat to be more descriptive.
Valentine Wallace [Thu, 14 Dec 2023 20:21:15 +0000 (15:21 -0500)]
Rename InboundOnionPayload::BlindedReceive::amt_msat to be more descriptive.

10 months agoRename InboundOnionPayload::Receive::amt_msat to be more descriptive.
Valentine Wallace [Thu, 14 Dec 2023 20:15:41 +0000 (15:15 -0500)]
Rename InboundOnionPayload::Receive::amt_msat to be more descriptive.

10 months agoRename OutboundOnionPayload::BlindedReceive::outgoing_cltv_value.
Valentine Wallace [Wed, 13 Dec 2023 22:22:50 +0000 (17:22 -0500)]
Rename OutboundOnionPayload::BlindedReceive::outgoing_cltv_value.

There is no outgoing HTLC for received HTLCs, so rename to be more accurate.

10 months agoRename OutboundOnionPayload::Receive::outgoing_cltv_value.
Valentine Wallace [Wed, 13 Dec 2023 22:18:56 +0000 (17:18 -0500)]
Rename OutboundOnionPayload::Receive::outgoing_cltv_value.

There is no outgoing HTLC for received HTLCs, so rename to be more accurate.

10 months agoRename InboundOnionPayload::BlindedReceive::outgoing_cltv_value.
Valentine Wallace [Wed, 13 Dec 2023 21:43:27 +0000 (16:43 -0500)]
Rename InboundOnionPayload::BlindedReceive::outgoing_cltv_value.

There is no outgoing HTLC for received HTLCs, so rename to be more accurate.

10 months agoRename InboundOnionPayload::Receive::outgoing_cltv_value
Valentine Wallace [Tue, 12 Dec 2023 22:45:46 +0000 (17:45 -0500)]
Rename InboundOnionPayload::Receive::outgoing_cltv_value

.. since there is no outgoing cltv for received HTLCs.

10 months agoRename outgoing_cltv_value internal var.
Valentine Wallace [Tue, 12 Dec 2023 22:59:41 +0000 (17:59 -0500)]
Rename outgoing_cltv_value internal var.

There is no outgoing CLTV for received HTLCs, so this new var makes more sense.

10 months agoRename InboundOnionErr to InboundHTLCErr.
Valentine Wallace [Tue, 12 Dec 2023 22:39:10 +0000 (17:39 -0500)]
Rename InboundOnionErr to InboundHTLCErr.

The prior name seems to reference onion decode errors specifically, when in
fact the error contents are generic failure codes for any error that occurs
during HTLC receipt.

10 months agoRemove trailing whitespace.
Valentine Wallace [Wed, 10 Jan 2024 15:55:55 +0000 (10:55 -0500)]
Remove trailing whitespace.

10 months agoMerge pull request #2748 from TheBlueMatt/2023-11-2675-followups
Matt Corallo [Tue, 9 Jan 2024 23:22:48 +0000 (23:22 +0000)]
Merge pull request #2748 from TheBlueMatt/2023-11-2675-followups

Doc and style followups from #2675

10 months agoUpdate docs on `HTLC` and `DelayedPayment` keys for clarity 2023-11-2675-followups
Matt Corallo [Mon, 27 Nov 2023 18:52:37 +0000 (18:52 +0000)]
Update docs on `HTLC` and `DelayedPayment` keys for clarity

This also adds required linebreaks to keep the docs to a reasonable
width.

10 months agoDrop the unused `PaymentKey` type
Matt Corallo [Mon, 27 Nov 2023 18:51:13 +0000 (18:51 +0000)]
Drop the unused `PaymentKey` type

935a716cc6c4fada075e2b740a70bb1b7b349d49 added new wrappers for the
various channel keys, including a payment_key. However, the
`payment_key` has been unused in lightning since the introduction
(and broad requiring) of the `static_remotekey` feature.

Thus, we simply remove it (and an incredibly stale TODO) here.

10 months agoUpdate docs for slightly more clarity on channel key derivation
Matt Corallo [Mon, 27 Nov 2023 18:32:08 +0000 (18:32 +0000)]
Update docs for slightly more clarity on channel key derivation

10 months agoMerge pull request #2807 from Jossec101/log-errors-do-accept-inbound-channel
Matt Corallo [Tue, 9 Jan 2024 20:08:25 +0000 (20:08 +0000)]
Merge pull request #2807 from Jossec101/log-errors-do-accept-inbound-channel

Log the errors before we return them from ChannelManager::do_accept_inbound_channel

10 months agoTest individual monitor update compl in chanmon_consistency fuzzer 2024-01-fuzz-ooo-monitor-updates
Matt Corallo [Tue, 9 Jan 2024 17:11:03 +0000 (17:11 +0000)]
Test individual monitor update compl in chanmon_consistency fuzzer

When users do async monitor updating, it may not be the case that
all pending monitors will complete updating at once. Thus, we
should fuzz monitor updates completing out of order, which we do
here.

10 months agoMerge pull request #2817 from tnull/2024-01-time-in-electrum
Matt Corallo [Tue, 9 Jan 2024 16:57:16 +0000 (16:57 +0000)]
Merge pull request #2817 from tnull/2024-01-time-in-electrum

Feature-gate `time` use also in `ElectrumSyncClient`

10 months agoImproved error logging in ChannelManager::do_accept_inbound_channel
José A.P [Tue, 9 Jan 2024 10:26:14 +0000 (11:26 +0100)]
Improved error logging in ChannelManager::do_accept_inbound_channel

This refactor ensures that all API errors in do_accept_inbound_channel
are logged before they are returned.

10 months agoFeature-gate `time` use also in `ElectrumSyncClient`
Elias Rohrer [Tue, 9 Jan 2024 08:37:14 +0000 (09:37 +0100)]
Feature-gate `time` use also in `ElectrumSyncClient`

A previous commit introduced the `time` feature to gate the use of
`SystemTime` dependent APIs in `EsploraSyncClient`. It however omitted
doing the same for the Electrum side of things. Here, we address this
oversight.

10 months agoMerge pull request #2802 from TheBlueMatt/2023-12-no-pub-enum
Matt Corallo [Mon, 8 Jan 2024 21:33:00 +0000 (21:33 +0000)]
Merge pull request #2802 from TheBlueMatt/2023-12-no-pub-enum

Move `CandidateRouteHop` enum variant fields into structs

10 months agoMerge pull request #2808 from TheBlueMatt/2023-12-fuzzing-fixes-1
Matt Corallo [Mon, 8 Jan 2024 20:58:30 +0000 (20:58 +0000)]
Merge pull request #2808 from TheBlueMatt/2023-12-fuzzing-fixes-1

10 months agoFix reachable unwrap on non-channel_type manual channel acceptance 2023-12-fuzzing-fixes-1
Matt Corallo [Sun, 24 Dec 2023 17:12:10 +0000 (17:12 +0000)]
Fix reachable unwrap on non-channel_type manual channel acceptance

If we receive an `OpenChannel` message without a `channel_type`
with `manually_accept_inbound_channels` set, we will `unwrap()`
`None`.

This is uncommon these days as most nodes support `channel_type`,
but sadly is rather trivial for a peer to hit for those with manual
channel acceptance enabled.

Reported in and fixes #2804. Luckily, the updated
`full_stack_target` has no issue reaching this issue quickly.

10 months agoMerge pull request #2799 from benthecarman/tx-sync-wasm
Elias Rohrer [Mon, 8 Jan 2024 17:55:07 +0000 (18:55 +0100)]
Merge pull request #2799 from benthecarman/tx-sync-wasm

Don't call system time in no-std

10 months agoMove `CandidateRouteHop` enum variant fields into structs 2023-12-no-pub-enum
Matt Corallo [Tue, 19 Dec 2023 18:21:21 +0000 (18:21 +0000)]
Move `CandidateRouteHop` enum variant fields into structs

The bindings generator struggles a bit with the references in enum
variant fields in `CandidateRouteHop`. While we could probably fix
this, its much eaiser (and less risky) to inline the enum variant
fields from `CandidateRouteHop` into structs. This also lets us
make some of the fields non-public, which seems better at least for
the opaque `hint_idx` in the blinded paths.

10 months agoFix handling of duplicate initial `ChannelMonitor` writing 2023-12-closing-event-cleanup-fixes
Matt Corallo [Mon, 25 Dec 2023 06:55:08 +0000 (06:55 +0000)]
Fix handling of duplicate initial `ChannelMonitor` writing

In e06484b0f44155e647ff29810d2f187967e45813, we added specific
handling for outbound-channel initial monitor updates failing -
in such a case we have a counterparty who tried to open a second
channel with the same funding info we just gave them, causing us
to force-close our outbound channel as it shows up as
duplicate-funding. Its largely harmless as it leads to a spurious
force-closure of a channel with a peer doing something absurd,
however it causes the `full_stack_target` fuzzer to fail.

Sadly, in 574c77e7bc95fd8dea5a8058b6b35996cc99db8d, as we were
dropping handling of `PermanentFailure` handling for updates, we
accidentally dropped handling for initial updates as well.

Here we fix the issue (again) and add a test.

10 months agoDo not panic if a peer learns our funding info before we fund
Matt Corallo [Tue, 26 Dec 2023 18:16:51 +0000 (18:16 +0000)]
Do not panic if a peer learns our funding info before we fund

We'd previously assumed that LDK would receive
`funding_transaction_generated` prior to our peer learning the txid
and panicked if the peer tried to open a redundant channel to us
with the same funding outpoint.

While this assumption is generally safe, some users may have
out-of-band protocols where they notify their LSP about a funding
outpoint first, or this may be violated in the future with
collaborative transaction construction protocols, i.e. the upcoming
dual-funding protocol.

10 months agoDrop now-unused fields from `MsgHandleErrInternal`
Matt Corallo [Fri, 29 Dec 2023 03:55:52 +0000 (03:55 +0000)]
Drop now-unused fields from `MsgHandleErrInternal`