]> git.bitcoin.ninja Git - rust-lightning/log
rust-lightning
7 months agoMerge pull request #2970 from jkczyz/2024-03-offer-id
Matt Corallo [Thu, 18 Apr 2024 15:21:19 +0000 (08:21 -0700)]
Merge pull request #2970 from jkczyz/2024-03-offer-id

Include a `PaymentContext` in `PaymentPurpose`

7 months agoUpdate PaymentPurpose's payment_preimage docs
Jeffrey Czyz [Wed, 17 Apr 2024 21:45:45 +0000 (16:45 -0500)]
Update PaymentPurpose's payment_preimage docs

Clarify that payment_preimage should only be used to claim a payment
when handling Event::PaymentClaimable, not Event::PaymentClaimed.

7 months agoInclude InvoiceRequest fields in PaymentContext
Jeffrey Czyz [Fri, 29 Mar 2024 02:31:10 +0000 (21:31 -0500)]
Include InvoiceRequest fields in PaymentContext

When receiving a payment, it's useful to know information about the
InvoiceRequest. Include this data in PaymentContext::Bolt12Offer so
users can display information about an inbound payment (e.g., the payer
note).

7 months agoTest for PaymentContext in offers_tests.rs
Jeffrey Czyz [Wed, 27 Mar 2024 01:19:32 +0000 (20:19 -0500)]
Test for PaymentContext in offers_tests.rs

7 months agoUse BOLT 12 PaymentPurpose variants
Jeffrey Czyz [Sat, 13 Apr 2024 23:20:19 +0000 (18:20 -0500)]
Use BOLT 12 PaymentPurpose variants

When constructing a PaymentPurpose in ChannelManager, use the
PaymentContext from OnionPayload to determine which variant to
construct, including those for BOLT 12 payments.

7 months agoBOLT 12 variants of PaymentPurpose
Jeffrey Czyz [Sat, 13 Apr 2024 22:29:24 +0000 (17:29 -0500)]
BOLT 12 variants of PaymentPurpose

In order to provide more context in PaymentClaimable and PaymentClaimed
events, introduce new variants of PaymentPurpose for use with BOLT 12
payments. Separate variants are used for offers and refunds. An unknown
variant is used for backwards compatibility and ease of testing, but is
otherwise not publicly constructable.

7 months agoAdd PaymentPurpose::is_keysend utility method
Jeffrey Czyz [Sat, 13 Apr 2024 02:21:00 +0000 (21:21 -0500)]
Add PaymentPurpose::is_keysend utility method

7 months agoRename InvoicePayment to Bolt11InvoicePayment
Jeffrey Czyz [Sat, 13 Apr 2024 02:17:35 +0000 (21:17 -0500)]
Rename InvoicePayment to Bolt11InvoicePayment

PaymentPurpose will be expanded to include BOLT 12 payment context.
Rename the InvoicePayment variant accordinly before new variants are
added.

7 months agoInclude Refund context in blinded payment paths
Jeffrey Czyz [Tue, 26 Mar 2024 23:57:57 +0000 (18:57 -0500)]
Include Refund context in blinded payment paths

When requesting a payment for a refund, include a context in the
Bolt12Invoice's blinded payment paths indicated it is for such. When the
eventual payment is received, the user can use the payment hash to
correlate it with the corresponding Refund.

7 months agoInclude Offer context in blinded payment paths
Jeffrey Czyz [Tue, 26 Mar 2024 23:48:39 +0000 (18:48 -0500)]
Include Offer context in blinded payment paths

When constructing blinded payment paths for a Bolt12Invoice response,
include the OfferId so that the eventual payment can be correlated with
the Offer.

7 months agoInclude OfferId in VerifiedInvoiceRequest
Jeffrey Czyz [Tue, 26 Mar 2024 23:39:06 +0000 (18:39 -0500)]
Include OfferId in VerifiedInvoiceRequest

Extract the OfferId from the offer metadata sent back in the
InvoiceRequest and include it in VerifiedInvoiceRequest. This can be
used to correspond the eventual payment for the invoice response by
including it in the invoice's blinded payment paths.

7 months agoDefine an OfferId for BOLT 12 Offers
Jeffrey Czyz [Mon, 25 Mar 2024 21:10:36 +0000 (16:10 -0500)]
Define an OfferId for BOLT 12 Offers

Use a merkle root hash of the offer TLV records to define an offer id.
Will be included in a BOLT 12 invoice's blinded payment paths in order
for the recipient to identify which offer the payment is for.

7 months agoPass PaymentContext through HTLC processing
Jeffrey Czyz [Tue, 26 Mar 2024 18:10:04 +0000 (13:10 -0500)]
Pass PaymentContext through HTLC processing

PendingInboundPayment::BlindedReceive includes a PaymentContext, which
the recipient includes in each blinded path. Included this when
processing HTLCs in ChannelManager, first into PendingHTLCRouting and
then to OnionPayload. Later, this will be included in the PaymentPurpose
when surfaced to user in PaymentClaimable and PaymentClaimed events.

7 months agoAdd PaymentContext to payment::ReceiveTlvs
Jeffrey Czyz [Tue, 26 Mar 2024 14:48:03 +0000 (09:48 -0500)]
Add PaymentContext to payment::ReceiveTlvs

Providing LDK-specific data in a BlindedPath allows for the data to be
received with the corresponding payment. This is useful as it can then
be surfaced in PaymentClaimable events where the user may correlated
with an Offer, for instance. Define a PaymentContext enum for including
various context (e.g., offer, refund, static invoice).

7 months agoReturn the invoice when requesting a refund
Jeffrey Czyz [Tue, 12 Mar 2024 00:00:40 +0000 (19:00 -0500)]
Return the invoice when requesting a refund

When sending an invoice for a refund, information from the invoice may
be useful for caller. For instance, the payment_hash can be used to
track whether the refund was paid. Return the invoice to facilitate this
use case.

7 months agoMerge pull request #2991 from optout21/txsigs-splicing
Matt Corallo [Tue, 16 Apr 2024 20:27:54 +0000 (13:27 -0700)]
Merge pull request #2991 from optout21/txsigs-splicing

Add tx_signatures.tlvs field (splicing-specific field in dual funding message)

7 months agoAdd tx_signatures.tlvs field (splicing-specific field in dual funding message)
optout [Tue, 16 Apr 2024 05:32:37 +0000 (07:32 +0200)]
Add tx_signatures.tlvs field (splicing-specific field in dual funding message)

7 months agoMerge pull request #2993 from wpaulino/handshake-complete-timer-tick-occurred-race
Matt Corallo [Mon, 15 Apr 2024 21:21:47 +0000 (21:21 +0000)]
Merge pull request #2993 from wpaulino/handshake-complete-timer-tick-occurred-race

Fix race between handshake_complete and timer_tick_occurred

7 months agoImplement Eq and Hash for Bolt12Invoice
Jeffrey Czyz [Mon, 11 Mar 2024 23:31:50 +0000 (18:31 -0500)]
Implement Eq and Hash for Bolt12Invoice

Bolt12Invoice will be added to a new Event::InvoiceGenerated variant.
These traits along with PartialEq are required to be implemented for any
type used in an Event.

7 months agoRefactor handling of Bolt12Invoice
Jeffrey Czyz [Mon, 11 Mar 2024 22:03:26 +0000 (17:03 -0500)]
Refactor handling of Bolt12Invoice

In order to provide an InvoiceGenerated event, it would be cleaner to
have one location where a Bolt12Invoice is successfully created.
Refactor the handling code to this end and clean-up line length by
making some of the type conversions more streamlined.

7 months agoRefactor handling of InvoiceRequest
Jeffrey Czyz [Sun, 10 Mar 2024 00:58:01 +0000 (18:58 -0600)]
Refactor handling of InvoiceRequest

In order to generate and InvoiceSent event, it would be cleaner to have
one location where a Bolt12Invoice is successfully generated. Refactor
the handling code to this end and clean-up line length by making some of
the type conversions more streamlined.

7 months agoMerge pull request #2961 from jkczyz/2024-03-compact-blinded-paths
Matt Corallo [Mon, 15 Apr 2024 17:56:29 +0000 (17:56 +0000)]
Merge pull request #2961 from jkczyz/2024-03-compact-blinded-paths

Compact blinded path handling

7 months agoFix typos
Jeffrey Czyz [Mon, 15 Apr 2024 16:00:28 +0000 (11:00 -0500)]
Fix typos

7 months agoResolve blinded path when creating onion message
Jeffrey Czyz [Sun, 7 Apr 2024 19:10:29 +0000 (21:10 +0200)]
Resolve blinded path when creating onion message

Add a version of the create_onion_message utility function that attempts
to resolved the introduction node of the destination's BlindedPath using
a ReadOnlyNetworkGraph`. Otherwise, if given a path using the compact
representation, using create_onion_message would fail. Keep the current
version for use internally and for external uses where the blinded path
is known to be resolved.

7 months agoCache introduction_node_id lookup in get_route
Jeffrey Czyz [Fri, 29 Mar 2024 16:24:54 +0000 (11:24 -0500)]
Cache introduction_node_id lookup in get_route

7 months agoLook up node id from scid in OnionMessenger
Jeffrey Czyz [Wed, 20 Mar 2024 19:31:30 +0000 (14:31 -0500)]
Look up node id from scid in OnionMessenger

When forwarding onion messages, the next node may be represented by a
short channel id instead of a node id. Parameterize OnionMessenger with
a NodeIdLookUp trait to find which node is the next hop. Implement the
trait for ChannelManager for forwarding to channel counterparties.

Also use this trait when advancing a blinded path one hop when the
sender is the introduction node.

7 months agoResolve IntroductionNode::DirectedShortChannelId
Jeffrey Czyz [Tue, 19 Mar 2024 02:58:04 +0000 (21:58 -0500)]
Resolve IntroductionNode::DirectedShortChannelId

When OnionMessenger creates an OnionMessage to a Destination, the latter
may contain an IntroductionNode::DirectedShortChannelId inside a
BlindedPath. Resolve these in DefaultMessageRouter and handle unresolved
ones in OnionMessenger.

7 months agoGeneralize BlindedPath::introduction_node_id field
Jeffrey Czyz [Fri, 15 Mar 2024 21:52:36 +0000 (16:52 -0500)]
Generalize BlindedPath::introduction_node_id field

Allow using either a node id or a directed short channel id in blinded
paths. This allows for a more compact representation of blinded paths,
which is advantageous for reducing offer QR code size.

Follow-up commits will implement handling the directed short channel id
case in OnionMessenger as it requires resolving the introduction node in
MessageRouter.

7 months agoAdd source reference to BlindedPathCandidate hop
Jeffrey Czyz [Wed, 20 Mar 2024 21:43:03 +0000 (16:43 -0500)]
Add source reference to BlindedPathCandidate hop

Blinded paths currently contain a node id for the introduction node.
However, a compact representation will allow a directed short channel id
instead. Update BlindedPathCandidate and OneHopBlindedPathCandidate to
store a NodeId reference from either the NetworkGraph or from the user-
provided first hops.

This approach avoids looking up the introduction node id on demand,
which may not be resolvable. Thus, that would require returning an
Option from CandidateRouteHop::source and handle None accordingly.

7 months agoMerge pull request #2987 from TheBlueMatt/2024-04-test-ser-bug
valentinewallace [Mon, 15 Apr 2024 15:23:09 +0000 (11:23 -0400)]
Merge pull request #2987 from TheBlueMatt/2024-04-test-ser-bug

Add test coverage for cc78b77c715d6ef62693d4c1bc7190da990ec0fa

7 months agoMerge pull request #2971 from jbesraa/review-club/2815
Matt Corallo [Sat, 13 Apr 2024 19:59:05 +0000 (19:59 +0000)]
Merge pull request #2971 from jbesraa/review-club/2815

Fix comparison in `get_dust_buffer_feerate`

7 months agoFix `cmp::max` execution in `ChannelContext::get_dust_buffer_feerate`
jbesraa [Tue, 26 Mar 2024 17:23:37 +0000 (19:23 +0200)]
Fix `cmp::max` execution in `ChannelContext::get_dust_buffer_feerate`

  The current `cmp::max` doesnt align with the function comment, ie its
  comparing 2530 and `feerate_plus_quarter` instead of `feerate_per_kw
  + 2530` and `feerate_plus_quarter` which is fixed in this commit

7 months agoFix race between handshake_complete and timer_tick_occurred
Wilmer Paulino [Fri, 12 Apr 2024 17:23:45 +0000 (10:23 -0700)]
Fix race between handshake_complete and timer_tick_occurred

The initial noise handshake on connection establishment must complete
within a single timer tick. This timeout is enforced via
`awaiting_pong_timer_tick_intervals` whenever a timer tick fires while
our handshake has yet to complete. Currently, on an inbound connection,
if a timer tick fires after we've sent act two of the noise handshake
along with our init message and before receiving the counterparty's init
message, we begin enforcing such timeout. Even if we immediately
continue to process the counterparty's init message to complete to
handshake, the timeout enforcement is not cleared. With the handshake
complete, `awaiting_pong_timer_tick_intervals` is now tracked to enforce
a pong timeout, except a ping was never actually sent. If a single timer
tick fires again without having received a message from the peer, or
enough timer ticks fire to trigger the
`MAX_BUFFER_DRAIN_TICK_INTERVALS_PER_PEER` logic, we'll end up
disconnecting the peer due to a timeout for a pong we'll never receive.

We fix this by always resetting `awaiting_pong_timer_tick_intervals`
upon processing our counterparty's init message.

7 months agoAdd BlindedPath::introduction_node_id method
Jeffrey Czyz [Wed, 20 Mar 2024 21:42:30 +0000 (16:42 -0500)]
Add BlindedPath::introduction_node_id method

Blinded paths use a pubkey to identify the introduction node, but it
will soon allow using a directed short channel id instead. Add an
introduction_node_id method to BlindedPath to facilitate lookup in the
latter case.

7 months agoAdd IndexedMap::get_key_value
Jeffrey Czyz [Tue, 12 Dec 2023 20:51:22 +0000 (14:51 -0600)]
Add IndexedMap::get_key_value

Useful for applying Option::map when needing both the key and value for
when needing a reference to the key with a longer lifetime.

7 months agoGeneralize onion message ForwardTlvs::next_node_id
Jeffrey Czyz [Sat, 2 Mar 2024 18:28:20 +0000 (12:28 -0600)]
Generalize onion message ForwardTlvs::next_node_id

Allow either using a node id or a short channel id when forwarding an
onion message. This allows for a more compact representation of blinded
paths, which is advantageous for reducing offer QR code size.

Follow-up commits will implement handling the short channel id case as
it requires looking up the destination node id.

7 months agoMerge pull request #2910 from tnull/2024-02-rustfmt-sign-mod
Matt Corallo [Wed, 10 Apr 2024 20:50:46 +0000 (20:50 +0000)]
Merge pull request #2910 from tnull/2024-02-rustfmt-sign-mod

`rustfmt`:  Format `sign` module

7 months agoAdd test coverage for cc78b77c715d6ef62693d4c1bc7190da990ec0fa 2024-04-test-ser-bug
Valentine Wallace [Fri, 29 Mar 2024 21:48:26 +0000 (17:48 -0400)]
Add test coverage for cc78b77c715d6ef62693d4c1bc7190da990ec0fa

cc78b77c715d6ef62693d4c1bc7190da990ec0fa fixed an important
downgrade bug, but neglected to add test coverage. Here we recitfy
that by adding a few simple tests of common cases.

Tests heavily tweaked by Matt Corallo <git@bluematt.me>.

7 months agoRemove `no-std-check/src/lib.rs` from `rustfmt` exclusion list
Elias Rohrer [Fri, 23 Feb 2024 11:12:50 +0000 (12:12 +0100)]
Remove `no-std-check/src/lib.rs` from `rustfmt` exclusion list

.. now continously checking its formatting in CI.

7 months agoRemove `msrv-no-dev-deps-check/src/lib.rs` from `rustfmt` exclusion list
Elias Rohrer [Fri, 23 Feb 2024 11:11:50 +0000 (12:11 +0100)]
Remove `msrv-no-dev-deps-check/src/lib.rs` from `rustfmt` exclusion list

.. now continously checking its formatting in CI.

7 months agoRun `rustfmt` on `msrv-no-dev-deps-check/src/lib.rs`
Elias Rohrer [Fri, 23 Feb 2024 11:12:19 +0000 (12:12 +0100)]
Run `rustfmt` on `msrv-no-dev-deps-check/src/lib.rs`

7 months agoRemove `sign/type_resolver.rs` from `rustfmt` exclusion list
Elias Rohrer [Fri, 23 Feb 2024 10:45:47 +0000 (11:45 +0100)]
Remove `sign/type_resolver.rs` from `rustfmt` exclusion list

.. now continously checking its formatting in CI.

7 months agoRun `rustfmt` on `sign/type_resolver.rs`
Elias Rohrer [Wed, 27 Mar 2024 11:14:50 +0000 (12:14 +0100)]
Run `rustfmt` on `sign/type_resolver.rs`

7 months agoRemove `sign/taproot.rs` from `rustfmt` exclusion list
Elias Rohrer [Fri, 23 Feb 2024 10:43:44 +0000 (11:43 +0100)]
Remove `sign/taproot.rs` from `rustfmt` exclusion list

.. now continously checking its formatting in CI.

7 months agoRun `rustfmt` on `sign/taproot.rs`
Elias Rohrer [Wed, 27 Mar 2024 11:14:24 +0000 (12:14 +0100)]
Run `rustfmt` on `sign/taproot.rs`

7 months agoRemove `sign/mod.rs` from `rustfmt` exclusion list
Elias Rohrer [Fri, 23 Feb 2024 10:41:53 +0000 (11:41 +0100)]
Remove `sign/mod.rs` from `rustfmt` exclusion list

.. now continously checking its formatting in CI.

7 months agoRun `rustfmt` on `sign/mod.rs`
Elias Rohrer [Tue, 9 Apr 2024 11:09:37 +0000 (13:09 +0200)]
Run `rustfmt` on `sign/mod.rs`

7 months agoMove `input_idx` retrieval into closure
Elias Rohrer [Wed, 27 Mar 2024 11:08:40 +0000 (12:08 +0100)]
Move `input_idx` retrieval into closure

7 months agoMove `htlc_basepoint` to variable
Elias Rohrer [Wed, 27 Mar 2024 10:55:19 +0000 (11:55 +0100)]
Move `htlc_basepoint` to variable

7 months agoMove `hash_to_message` to variable
Elias Rohrer [Wed, 27 Mar 2024 10:53:33 +0000 (11:53 +0100)]
Move `hash_to_message` to variable

7 months agoMove low-R comments into blocks
Elias Rohrer [Wed, 27 Mar 2024 10:50:07 +0000 (11:50 +0100)]
Move low-R comments into blocks

7 months agoPull anchor check into helper function
Elias Rohrer [Wed, 27 Mar 2024 10:43:55 +0000 (11:43 +0100)]
Pull anchor check into helper function

7 months agoRemove `sign/ecdsa.rs` from `rustfmt` exclusion list
Elias Rohrer [Fri, 23 Feb 2024 10:39:10 +0000 (11:39 +0100)]
Remove `sign/ecdsa.rs` from `rustfmt` exclusion list

.. now continously checking its formatting in CI.

7 months agoRun `rustfmt` on `sing/ecdsa.rs`
Elias Rohrer [Fri, 23 Feb 2024 10:40:59 +0000 (11:40 +0100)]
Run `rustfmt` on `sing/ecdsa.rs`

7 months agoMerge pull request #2969 from TheBlueMatt/2024-03-fix-upgradable-enum
valentinewallace [Mon, 8 Apr 2024 14:34:14 +0000 (16:34 +0200)]
Merge pull request #2969 from TheBlueMatt/2024-03-fix-upgradable-enum

7 months agoAllow `MaybeReadable` to not fully read in `upgradable_option` 2024-03-fix-upgradable-enum
Matt Corallo [Thu, 28 Mar 2024 22:06:36 +0000 (22:06 +0000)]
Allow `MaybeReadable` to not fully read in `upgradable_option`

Whils this is generally not supported, issues in our
`MaybeReadable` implementations may occur, and we should try to be
robust against them.

7 months agoEnsure we read the full TLV stream length when maybe-reading `None`
Matt Corallo [Thu, 28 Mar 2024 22:02:09 +0000 (22:02 +0000)]
Ensure we read the full TLV stream length when maybe-reading `None`

If we are reading an object that is `MaybeReadable` in a TLV stream
using `upgradable_required`, it may return early with `Ok(None)`.
In this case, it will not read any further TLVs from the TLV
stream. This is fine, except that we generally expect
`MaybeReadable` always consume the correct number of bytes for the
full object, even if it doesn't understand it.

This could pose a problem, for example, in cases where we're
reading a TLV-stream `MaybeReadable` object inside another
TLV-stream object. In that case, the `MaybeReadable` object may
return `Ok(None)` and not consume all the available bytes, causing
the outer TLV read to fail as the TLV length does not match.

7 months agoFix unknown handling in `impl_writeable_tlv_based_enum_upgradable`
Matt Corallo [Tue, 26 Mar 2024 15:08:20 +0000 (15:08 +0000)]
Fix unknown handling in `impl_writeable_tlv_based_enum_upgradable`

`impl_writeable_tlv_based_enum_upgradable` professed to supporting
upgrades by returning `None` from `MaybeReadable` when unknown
variants written by newer versions of LDK were read. However, it
generally didn't support this as it didn't discard bytes for
unknown types, resulting in corrupt reading.

This is fixed here for enum variants written as a TLV stream,
however we don't have a length prefix for tuple enum variants, so
the documentation on the macro is updated to mention that
downgrades are not supported for tuple variants.

7 months agoMerge pull request #2704 from jkczyz/2023-11-channelmanager-docs
dunxen [Sun, 7 Apr 2024 18:34:57 +0000 (20:34 +0200)]
Merge pull request #2704 from jkczyz/2023-11-channelmanager-docs

`ChannelManager` documentation refresh

7 months agoAdd BOLT 12 Refunds section to ChannelManager docs
Jeffrey Czyz [Tue, 23 Jan 2024 19:01:37 +0000 (13:01 -0600)]
Add BOLT 12 Refunds section to ChannelManager docs

7 months agoAdd BOLT 12 Offers section to ChannelManager docs
Jeffrey Czyz [Mon, 22 Jan 2024 21:34:27 +0000 (15:34 -0600)]
Add BOLT 12 Offers section to ChannelManager docs

7 months agoAdd a payments section to ChannelManager docs
Jeffrey Czyz [Wed, 27 Dec 2023 03:13:52 +0000 (22:13 -0500)]
Add a payments section to ChannelManager docs

7 months agoAdd a channels section to ChannelManager docs
Jeffrey Czyz [Thu, 28 Dec 2023 23:00:16 +0000 (17:00 -0600)]
Add a channels section to ChannelManager docs

7 months agoAdd an operations section to ChannelManager docs
Jeffrey Czyz [Wed, 27 Dec 2023 03:06:56 +0000 (22:06 -0500)]
Add an operations section to ChannelManager docs

7 months agoChannelManager initialization docs with example
Jeffrey Czyz [Fri, 17 Nov 2023 23:58:56 +0000 (17:58 -0600)]
ChannelManager initialization docs with example

7 months agoMerge pull request #2954 from TheBlueMatt/2024-03-test-ci-beta-fail
Elias Rohrer [Fri, 5 Apr 2024 10:53:40 +0000 (12:53 +0200)]
Merge pull request #2954 from TheBlueMatt/2024-03-test-ci-beta-fail

Fix new warnings causing CI build failures on rustc beta

7 months agoMerge pull request #2967 from tnull/2024-03-refactor-drop-handle-message
Gursharan Singh [Fri, 5 Apr 2024 10:26:51 +0000 (12:26 +0200)]
Merge pull request #2967 from tnull/2024-03-refactor-drop-handle-message

Split `PeerManager::handle_message` to avoid explicit `mem::drop`

7 months agoFix unused warning for un-accessed enum variant field in net-tokio 2024-03-test-ci-beta-fail
Matt Corallo [Thu, 21 Mar 2024 15:53:00 +0000 (15:53 +0000)]
Fix unused warning for un-accessed enum variant field in net-tokio

7 months agoRemove a handful of redundant imports
Matt Corallo [Thu, 21 Mar 2024 15:48:54 +0000 (15:48 +0000)]
Remove a handful of redundant imports

... that newer rustc now warns about.

7 months agoMark several test_utils which are only used in test as `cfg(test)`
Matt Corallo [Thu, 21 Mar 2024 15:46:31 +0000 (15:46 +0000)]
Mark several test_utils which are only used in test as `cfg(test)`

7 months agoDrop now-unused methods on `Time`
Matt Corallo [Thu, 21 Mar 2024 15:44:45 +0000 (15:44 +0000)]
Drop now-unused methods on `Time`

We no longer use `Time` during scoring, which makes several of its
methods now useless. We remove those here.

7 months agoUse `crate::prelude::*` rather than specific imports
Matt Corallo [Thu, 21 Mar 2024 14:27:05 +0000 (14:27 +0000)]
Use `crate::prelude::*` rather than specific imports

New rustc beta now warns on duplicate imports when one of the
imports is from a wildcard import or the default prelude. Thus, to
avoid this here we prefer to always use `crate::prelude::*` and let
it decide if we actually need to import anything.

7 months agoAdd more `std` prelude items to `crate::prelude`
Matt Corallo [Thu, 21 Mar 2024 14:22:52 +0000 (14:22 +0000)]
Add more `std` prelude items to `crate::prelude`

New rustc beta now warns on duplicate imports when one of the
imports is from a wildcard import or the default prelude. Thus, for
simplicity, we need to make our `crate::prelude` mostly identical
to the `std` one, allowing us to always simply use the
`crate::prelude` and let it decide if we need to import anything.

7 months agoAllow(unused_imports) on prelude imports
Matt Corallo [Thu, 21 Mar 2024 15:18:22 +0000 (15:18 +0000)]
Allow(unused_imports) on prelude imports

New rustc now warns on duplicate imports when one of the imports
is from a wildcard import or the default prelude. Thus, because we
often don't actually use the imports from our prelude (as they
exist to duplicate the `std` default prelude), we have to mark most
of our `crate::prelude` imports with `#[allow(unused_imports)]`,
which we do here.

7 months agoDebug more information when we fail to find a lock call symbol
Matt Corallo [Wed, 20 Mar 2024 20:40:41 +0000 (20:40 +0000)]
Debug more information when we fail to find a lock call symbol

7 months agoFix new warnings causing CI build failures on rustc beta
Matt Corallo [Wed, 20 Mar 2024 19:14:40 +0000 (19:14 +0000)]
Fix new warnings causing CI build failures on rustc beta

7 months agoSplit `PeerManager::handle_message` to avoid explicit `mem::drop`
Elias Rohrer [Mon, 25 Mar 2024 15:35:37 +0000 (16:35 +0100)]
Split `PeerManager::handle_message` to avoid explicit `mem::drop`

Previously, `handle_message` was a single large method consisting of two
logical parts: one modifying the peer state hence requiring us to hold
the `peer_lock` `MutexGuard`, and, after calling `mem::drop(peer_lock)`,
the remainder which does not only *not* require to hold the
`MutexGuard`, but relies on it being dropped to avoid double-locking.

However, the `mem::drop` was easily overlooked, making reasoning about
lock orders etc. a headache. Here, we therefore have
`handle_message` call two sub-methods reflecting the two logical parts,
allowing us to avoid the explicit `mem::drop`, while at the same time
making it less error-prone due to the two methods' signatures.

7 months agoMerge pull request #2731 from shaavan/issue2711
Matt Corallo [Thu, 4 Apr 2024 08:12:36 +0000 (08:12 +0000)]
Merge pull request #2731 from shaavan/issue2711

Delay broadcasting Channel Updates until connected to peers

7 months agoDelay broadcasting Channel Updates until connected to peers
shaavan [Wed, 27 Mar 2024 13:03:42 +0000 (18:33 +0530)]
Delay broadcasting Channel Updates until connected to peers

    - We might generate channel updates to be broadcast when
      we are not connected to any peers to broadcast them to.
    - This PR ensures to cache them and broadcast them only when
      we are connected to some peers.

Other Changes:
    1. Introduce a test.
    2. Update the relevant current tests affected by this change.
    3. Fix a typo.
    4. Introduce two functions in functional_utils that optionally
       connect and disconnect a dummy node during broadcast testing.

7 months agoMerge pull request #2978 from wpaulino/reserve-async-signing-channel-tlvs
Elias Rohrer [Mon, 1 Apr 2024 10:07:58 +0000 (12:07 +0200)]
Merge pull request #2978 from wpaulino/reserve-async-signing-channel-tlvs

Reserve async signing related channel TLV types

7 months agoReserve async signing related channel TLV types
Wilmer Paulino [Fri, 29 Mar 2024 18:50:26 +0000 (11:50 -0700)]
Reserve async signing related channel TLV types

A LDK user deployed to production a WIP version of the async signing
branch in which two new TLVs were added to channel. To prevent them from
needing to perform a migration, we can just new types for TLVs that have
yet to be included in a release. A note has been added to ensure types
45 and 47 are not used for another purpose.

7 months agoMerge pull request #2975 from valentinewallace/2024-03-blinded-path-custom-tlvs
valentinewallace [Fri, 29 Mar 2024 00:36:20 +0000 (20:36 -0400)]
Merge pull request #2975 from valentinewallace/2024-03-blinded-path-custom-tlvs

7 months agoMerge pull request #2845 from wpaulino/decode-htlc-onion-when-committed
Matt Corallo [Thu, 28 Mar 2024 20:44:36 +0000 (20:44 +0000)]
Merge pull request #2845 from wpaulino/decode-htlc-onion-when-committed

Support decoding HTLC onions once fully committed

7 months agoTest sending + receiving custom TLVs to blinded paths.
Valentine Wallace [Wed, 27 Mar 2024 20:41:40 +0000 (16:41 -0400)]
Test sending + receiving custom TLVs to blinded paths.

7 months agoMerge pull request #2974 from benthecarman/dang-value
Matt Corallo [Thu, 28 Mar 2024 18:34:15 +0000 (18:34 +0000)]
Merge pull request #2974 from benthecarman/dang-value

Add DecodeError::DangerousValue for decoding invalid channel managers

7 months agoAdd DecodeError::DangerousValue for decoding invalid channel managers
benthecarman [Wed, 27 Mar 2024 18:42:19 +0000 (13:42 -0500)]
Add DecodeError::DangerousValue for decoding invalid channel managers

This would help distinguish different types of errors when deserialzing
a channel manager. InvalidValue was used previously but this could be
because it is an old serialization format, whereas DangerousValue is a
lot more clear on why the deserialization failed.

7 months agoContrast ChannelManager and ChannelMonitor in docs
Jeffrey Czyz [Fri, 3 Nov 2023 22:02:15 +0000 (17:02 -0500)]
Contrast ChannelManager and ChannelMonitor in docs

7 months agoRe-write ChannelManager summary documentation
Jeffrey Czyz [Fri, 3 Nov 2023 21:23:18 +0000 (16:23 -0500)]
Re-write ChannelManager summary documentation

7 months agoMerge pull request #2976 from wvanlint/simplify_trait_object_impl
Matt Corallo [Thu, 28 Mar 2024 14:33:31 +0000 (14:33 +0000)]
Merge pull request #2976 from wvanlint/simplify_trait_object_impl

Simplify implementation for KVStore trait objects

7 months agoSimplify implementation for KVStore trait objects
Willem Van Lint [Thu, 28 Mar 2024 01:16:19 +0000 (18:16 -0700)]
Simplify implementation for KVStore trait objects

The implementation of the Persist and Persister trait for KVStore types
can also be used for trait objects if there is no implicit bound of
`Sized`.

8 months agoBreak ChannelManager docs into sections
Jeffrey Czyz [Fri, 3 Nov 2023 19:44:45 +0000 (14:44 -0500)]
Break ChannelManager docs into sections

ChannelManager docs aren't very approachable as they consist of a large
wall of texts without much direction. As a first step of improvement,
add sections to help delineate the existing text and make it easier to
scan.

8 months agoDecode update_add_htlc onions before forwarding HTLCs
Wilmer Paulino [Sat, 9 Mar 2024 08:53:48 +0000 (00:53 -0800)]
Decode update_add_htlc onions before forwarding HTLCs

This commit completes all of the groundwork necessary to decode incoming
`update_add_htlc` onions once they're fully committed to by both sides.
HTLCs are tracked in batches per-channel on the channel they were
received on. While this path is unreachable for now, until
`InboundHTLCResolution::Resolved` is replaced with
`InboundHTLCResolution::Pending`, it will allow us to obtain
`HTLCHandlingFailed` events for _any_ failed HTLC that comes across a
channel.

8 months agoRefactor forward_htlcs to return whether to push a forward event
Wilmer Paulino [Fri, 8 Mar 2024 07:30:18 +0000 (23:30 -0800)]
Refactor forward_htlcs to return whether to push a forward event

When decoding pending `update_add_htlc` onions, we may need to forward
HTLCs using `ChannelManager::forward_htlcs`. This may end up queueing a
`PendingHTLCsForwardable` event, but we're only decoding these pending
onions as a result of handling a `PendingHTLCsForwardable`, so we
shouldn't have to queue another one and wait for it to be handled. By
having a `forward_htlcs` variant that does not push the forward event,
we can ignore the forward event push when forwarding HTLCs which we just
decoded the onion for.

8 months agoConsider pending decode_update_add_htlcs when pushing forward event
Wilmer Paulino [Fri, 8 Mar 2024 07:35:30 +0000 (23:35 -0800)]
Consider pending decode_update_add_htlcs when pushing forward event

Since decoding pending `update_add_htlc` onions will go through the HTLC
forwarding path, we'll want to make sure we don't queue more events than
necessary if we have both HTLCs to forward/fail and pending
`update_add_htlc` onions to decode.

8 months agoRefactor incoming HTLC accept checks out from Channel::update_add_htlc
Wilmer Paulino [Fri, 8 Mar 2024 08:19:40 +0000 (00:19 -0800)]
Refactor incoming HTLC accept checks out from Channel::update_add_htlc

In the future, we plan to completely remove
`decode_update_add_htlc_onion` and replace it with a batched variant.
This refactor, while improving readability in its current form, does not
feature any functional changes and allows us to reuse the incoming HTLC
acceptance checks in the batched variant.

8 months agoOnly include channel_update in failure if needed by error code
Wilmer Paulino [Fri, 8 Mar 2024 07:31:14 +0000 (23:31 -0800)]
Only include channel_update in failure if needed by error code

This simplifies the failure path by allowing us to return the general
error code for a failure, which we can then amend based on whether it
was for a phantom forward.

8 months agoRefactor outgoing channel lookup out from decode_update_add_htlc_onion
Wilmer Paulino [Wed, 24 Jan 2024 01:14:14 +0000 (17:14 -0800)]
Refactor outgoing channel lookup out from decode_update_add_htlc_onion

In the future, we plan to complete remove `decode_update_add_htlc_onion`
and replace it with a batched variant. This refactor, while improving
readability in its current form, does not feature any functional changes
and allows us to reuse most of the logic in the batched variant.

8 months agoRefactor outgoing HTLC checks out from decode_update_add_htlc_onion
Wilmer Paulino [Wed, 24 Jan 2024 01:08:17 +0000 (17:08 -0800)]
Refactor outgoing HTLC checks out from decode_update_add_htlc_onion

In the future, we plan to complete remove `decode_update_add_htlc_onion`
and replace it with a batched variant. This refactor, while improving
readability in its current form, does not feature any functional changes
and allows us to reuse most of the logic in the batched variant.

8 months agoRefactor HTLCFailureMsg generation out from decode_update_add_htlc_onion
Wilmer Paulino [Wed, 24 Jan 2024 00:55:40 +0000 (16:55 -0800)]
Refactor HTLCFailureMsg generation out from decode_update_add_htlc_onion

In the future, we plan to complete remove `decode_update_add_htlc_onion`
and replace it with a batched variant. This refactor, while improving
readability in its current form, does not feature any functional changes
and allows us to reuse most of the logic in the batched variant.

8 months agoAdd is_intro_node_blinded_forward helper for onion_utils::Hop
Wilmer Paulino [Fri, 8 Mar 2024 08:05:14 +0000 (00:05 -0800)]
Add is_intro_node_blinded_forward helper for onion_utils::Hop