rust-lightning
10 months agoBump versions to LDK 116-alpha1 and invoice 24.0-alpha1 2023-06-116-alpha
Matt Corallo [Fri, 23 Jun 2023 19:42:08 +0000 (19:42 +0000)]
Bump versions to LDK 116-alpha1 and invoice 24.0-alpha1

10 months agoMerge pull request #2361 from arik-so/2023-06-anchor-channel-type-features
Matt Corallo [Fri, 23 Jun 2023 19:12:15 +0000 (19:12 +0000)]
Merge pull request #2361 from arik-so/2023-06-anchor-channel-type-features

Replace `opt_anchors` with `ChannelTypeFeatures`

10 months agoSync `ChannelTransactionParameters` features to `ChannelContext`.
Arik Sosman [Wed, 21 Jun 2023 23:41:09 +0000 (16:41 -0700)]
Sync `ChannelTransactionParameters` features to `ChannelContext`.

10 months agoVerify channel type features for decoding.
Arik Sosman [Tue, 20 Jun 2023 20:17:28 +0000 (13:17 -0700)]
Verify channel type features for decoding.

10 months agoReplace `opt_anchors` with `ChannelTypeFeatures`
Arik Sosman [Mon, 19 Jun 2023 17:30:34 +0000 (10:30 -0700)]
Replace `opt_anchors` with `ChannelTypeFeatures`

This change modifies six structs that were keeping
track of anchors features with an `opt_anchors` field,
as well as another field keeping track of nonzero-fee-
anchor-support.

10 months agoMerge pull request #2365 from TheBlueMatt/2023-06-fix-fuzz-dep
valentinewallace [Thu, 22 Jun 2023 22:49:09 +0000 (18:49 -0400)]
Merge pull request #2365 from TheBlueMatt/2023-06-fix-fuzz-dep

Ensure we build if a downstream crate sets `--cfg=fuzzing`

10 months agoMethod for `ChannelTypeFeatures` serialization compatibility.
Arik Sosman [Wed, 21 Jun 2023 23:12:45 +0000 (16:12 -0700)]
Method for `ChannelTypeFeatures` serialization compatibility.

10 months agoDefine `ChannelTypeFeatures` methods for anchors logic.
Arik Sosman [Mon, 19 Jun 2023 17:28:36 +0000 (10:28 -0700)]
Define `ChannelTypeFeatures` methods for anchors logic.

Specifically, introduce a new constructor for an anchors-
supporting feature set, as well as methods that will
maintain forwards-compatible deserialization in older
versions.

10 months agoReference-rhs bitwise operations for features.
Arik Sosman [Thu, 22 Jun 2023 21:14:02 +0000 (14:14 -0700)]
Reference-rhs bitwise operations for features.

10 months agoDocument nonzero anchors in features module.
Arik Sosman [Thu, 22 Jun 2023 22:22:40 +0000 (15:22 -0700)]
Document nonzero anchors in features module.

10 months agoIntroduce nonzero fee anchors feature.
Arik Sosman [Mon, 19 Jun 2023 17:25:01 +0000 (10:25 -0700)]
Introduce nonzero fee anchors feature.

10 months agoMerge pull request #2319 from valentinewallace/2023-05-forward-less-than-onion
Elias Rohrer [Wed, 21 Jun 2023 07:25:07 +0000 (09:25 +0200)]
Merge pull request #2319 from valentinewallace/2023-05-forward-less-than-onion

Allow forwarding less than the amount in the onion

10 months agoEnsure we build if a downstream crate sets `--cfg=fuzzing` 2023-06-fix-fuzz-dep
Matt Corallo [Tue, 20 Jun 2023 17:14:21 +0000 (17:14 +0000)]
Ensure we build if a downstream crate sets `--cfg=fuzzing`

Downstream crates building fur fuzzing will usually set
`--cfg=fuzzing` as a side-effect of the Rust fuzzing tooling. Thus,
we should ensure we build without failure in such cases.

We do this here by simply relying on the `_test_utils` feature,
rather than conditionally-compiling in modules based on the
`fuzzing` flag.

10 months agoDocument on claim events that amount_msat may be > invoice amount
Valentine Wallace [Thu, 15 Jun 2023 19:59:04 +0000 (15:59 -0400)]
Document on claim events that amount_msat may be > invoice amount

10 months agoCheck UpdateAddHTLC::skimmed_fee_msat on receive
Valentine Wallace [Wed, 24 May 2023 23:21:21 +0000 (19:21 -0400)]
Check UpdateAddHTLC::skimmed_fee_msat on receive

Make sure the penultimate hop took the amount of fee that they claimed to take.
Without checking this TLV, we're heavily relying on the receiving wallet code
to correctly implement logic to calculate that that the fee is as expected.

10 months agoSet UpdateAddHTLC::skimmed_fee_msat on forward
Valentine Wallace [Wed, 24 May 2023 23:15:25 +0000 (19:15 -0400)]
Set UpdateAddHTLC::skimmed_fee_msat on forward

So the receiver can verify it and approve underpaying HTLCs (see
ChannelConfig::accept_underpaying_htlcs).

10 months agoPersist update_add sender skimmed fee in Channel
Valentine Wallace [Fri, 9 Jun 2023 11:42:07 +0000 (13:42 +0200)]
Persist update_add sender skimmed fee in Channel

10 months agoTrack the sender's skimmed fee in UpdateAddHTLC
Valentine Wallace [Thu, 25 May 2023 13:57:16 +0000 (09:57 -0400)]
Track the sender's skimmed fee in UpdateAddHTLC

10 months agoAllow receiving less than the onion claims to pay
Valentine Wallace [Wed, 24 May 2023 15:53:05 +0000 (11:53 -0400)]
Allow receiving less than the onion claims to pay

Useful for penultimate hops in routes to take an extra fee, if for example they
opened a JIT channel to the payee and want them to help bear the channel open
cost.

10 months agoAdd PaymentClaimable::counterparty_skimmed_fee_msat
Valentine Wallace [Tue, 16 May 2023 20:14:40 +0000 (16:14 -0400)]
Add PaymentClaimable::counterparty_skimmed_fee_msat

See its docs

10 months agoPersist counterparty skimmed fee in ClaimableHTLC
Valentine Wallace [Thu, 15 Jun 2023 16:54:58 +0000 (12:54 -0400)]
Persist counterparty skimmed fee in ClaimableHTLC

Used to get an accurate skimmed fee in the resulting PaymentClaimable event.

10 months agoSet extra skimmed fee on intercepted forward
Valentine Wallace [Thu, 15 Jun 2023 16:37:21 +0000 (12:37 -0400)]
Set extra skimmed fee on intercepted forward

Receivers need to use this value to verify incoming payments if
ChannelConfig::accept_underpaying_htlcs is set.

10 months agoAdd config knob for accepting underpaying HTLCs
Valentine Wallace [Tue, 16 May 2023 18:18:47 +0000 (14:18 -0400)]
Add config knob for accepting underpaying HTLCs

See ChannelConfig::accept_underpaying_htlcs

10 months agoMove next hop packet pubkey calculation to outside channel lock
Valentine Wallace [Tue, 20 Jun 2023 21:40:12 +0000 (17:40 -0400)]
Move next hop packet pubkey calculation to outside channel lock

10 months agoMove PendingHTLCStatus construction inside channel lock
Valentine Wallace [Tue, 16 May 2023 20:14:40 +0000 (16:14 -0400)]
Move PendingHTLCStatus construction inside channel lock

We need the channel lock for constructing a pending HTLC's status because we
need to know if the channel accepts underpaying HTLCs in upcoming commits.

10 months agoMerge pull request #2120 from valentinewallace/2023-03-blinded-pathfinding
Matt Corallo [Tue, 20 Jun 2023 15:51:59 +0000 (15:51 +0000)]
Merge pull request #2120 from valentinewallace/2023-03-blinded-pathfinding

10 months agoMerge pull request #2089 from wpaulino/bump-transaction-event-handler
Matt Corallo [Mon, 19 Jun 2023 22:45:54 +0000 (22:45 +0000)]
Merge pull request #2089 from wpaulino/bump-transaction-event-handler

Add BumpTransaction event handler

10 months agoProvide a default CoinSelectionSource implementation via a new trait
Wilmer Paulino [Thu, 27 Apr 2023 00:44:49 +0000 (17:44 -0700)]
Provide a default CoinSelectionSource implementation via a new trait

Certain users may not care how their UTXOs are selected, or their wallet
may not expose enough controls to fully implement the
`CoinSelectionSource` trait. As an alternative, we introduce another
trait `WalletSource` they could opt to implement instead, which is much
simpler as it just returns the set of confirmed UTXOs that may be used.
This trait implementation is then consumed into a wrapper `Wallet` which
implements the `CoinSelectionSource` trait using a "smallest
above-dust-after-spend first" coin selection algorithm.

10 months agoAdd BumpTransaction event handler
Wilmer Paulino [Thu, 27 Apr 2023 00:42:35 +0000 (17:42 -0700)]
Add BumpTransaction event handler

This allows users to bump their commitments and HTLC transactions
without having to worry about all the little details to do so. Instead,
we'll just require that they implement the `CoinSelectionSource` trait
over their wallet/UTXO source, granting the event handler permission to
spend confirmed UTXOs for the transactions it'll produce.

While the event handler should in most cases produce valid transactions,
assuming the provided confirmed UTXOs are valid, it may not produce
relayable transactions due to not satisfying certain Replace-By-Fee
(RBF) mempool policy requirements. Some of these require that the
replacement transactions have a higher feerate and absolute fee than the
conflicting transactions it aims to replace. To make sure we adhere to
these requirements, we'd have to persist some state for all transactions
the event handler has produced, greatly increasing its complexity. While
we may consider implementing so in the future, we choose to go with a
simple initial version that relies on the OnchainTxHandler's bumping
frequency. For each new bumping attempt, the OnchainTxHandler proposes a
25% feerate increase to ensure transactions can propagate under
constrained mempool circumstances.

10 months agoExpose ClaimId for each claim bump in BumpTransactionEvent
Wilmer Paulino [Thu, 11 May 2023 20:50:46 +0000 (13:50 -0700)]
Expose ClaimId for each claim bump in BumpTransactionEvent

10 months agoExpose existing PackageID to API and rename to ClaimId
Wilmer Paulino [Thu, 11 May 2023 20:49:00 +0000 (13:49 -0700)]
Expose existing PackageID to API and rename to ClaimId

In a future commit, we plan to expand `BumpTransactionEvent` variants to
include the unique identifier assigned to pending output claims by the
`OnchainTxHandler` when a commitment is broadcast/confirmed. This
requires making it public in our API. We also choose to rename it to
`ClaimId` for the benefit of users, as the previous `PackageID` term
could be interpreted to be the ID of a BIP-331 transaction package.

10 months agoChange package ID computation for HTLC claims on anchor channels
Wilmer Paulino [Thu, 11 May 2023 22:39:13 +0000 (15:39 -0700)]
Change package ID computation for HTLC claims on anchor channels

While the previous way of computing the identifier was safe, it wouldn't
have been in certain scenarios if we considered splitting aggregated
packages. While this type of splitting has yet to be implemented, it may
come in the near future. To ensure we're prepared to handle such, we
opt to instead commit to all of the HTLCs to claim in the request.

10 months agoImplement routing to blinded payment paths
Valentine Wallace [Wed, 14 Jun 2023 22:14:29 +0000 (18:14 -0400)]
Implement routing to blinded payment paths

Sending to them is still disallowed, for now.

10 months agoRouter: clean up Path construction
Valentine Wallace [Thu, 15 Jun 2023 13:48:31 +0000 (09:48 -0400)]
Router: clean up Path construction

We don't need to collect a vec of Results anymore.

10 months agoAdd CandidateRouteHop::Blinded and ::OneHopBlinded variant
Valentine Wallace [Tue, 13 Jun 2023 23:37:53 +0000 (19:37 -0400)]
Add CandidateRouteHop::Blinded and ::OneHopBlinded variant

It's unclear what values 1-hop blinded paths should set their BlindedPayInfos
to, because those values are meant to refer to the fees/cltv delta on the path
*between* the intro node and the destination. We zero out these values in the
new variant's methods so they don't mess with path finding/construction.

10 months agoUpdate CandidateRouteHop::short_channel_id to be optional
Valentine Wallace [Tue, 13 Jun 2023 23:36:12 +0000 (19:36 -0400)]
Update CandidateRouteHop::short_channel_id to be optional

10 months agoMerge pull request #2351 from TheBlueMatt/2023-04-remove-legacy-recv
Matt Corallo [Sat, 17 Jun 2023 18:38:25 +0000 (18:38 +0000)]
Merge pull request #2351 from TheBlueMatt/2023-04-remove-legacy-recv

Drop `create_inbound_payment*_legacy` breaking downgrade to 0.0.103

10 months agoRouting: accommodate for blinded paths in used liquidity tracking
Valentine Wallace [Tue, 13 Jun 2023 21:47:36 +0000 (17:47 -0400)]
Routing: accommodate for blinded paths in used liquidity tracking

10 months agoReplace max_channel_saturation_power_of_half hardcode with const
Valentine Wallace [Wed, 14 Jun 2023 22:36:48 +0000 (18:36 -0400)]
Replace max_channel_saturation_power_of_half hardcode with const

10 months agoAdd utils for creating blinded PaymentParameters
Valentine Wallace [Fri, 19 May 2023 21:37:58 +0000 (17:37 -0400)]
Add utils for creating blinded PaymentParameters

10 months agoReverse (BlindedPath, BlindedPayInfo) tuple order in offers invoice.
Valentine Wallace [Fri, 16 Jun 2023 13:45:04 +0000 (09:45 -0400)]
Reverse (BlindedPath, BlindedPayInfo) tuple order in offers invoice.

To make it uniform with PaymentParameters' Payee::Blinded::route_hints.

10 months agoMerge pull request #2077 from dunxen/2023-02-splitchannelstate
Matt Corallo [Fri, 16 Jun 2023 06:01:10 +0000 (06:01 +0000)]
Merge pull request #2077 from dunxen/2023-02-splitchannelstate

Split prefunded `Channel` into `Inbound`/`Outbound` channels

10 months agoRename `inbound_is_awaiting_accept()` to `is_awaiting_accept()`
Duncan Dean [Tue, 13 Jun 2023 15:17:59 +0000 (17:17 +0200)]
Rename `inbound_is_awaiting_accept()` to `is_awaiting_accept()`

10 months agoRename `InboundV1Channel::new_from_req` to `InboundV1Channel::new`
Duncan Dean [Wed, 7 Jun 2023 18:49:26 +0000 (20:49 +0200)]
Rename `InboundV1Channel::new_from_req` to `InboundV1Channel::new`

10 months agoMove inbound channel methods into `InboundV1Channel`'s impl
Duncan Dean [Wed, 7 Jun 2023 16:14:59 +0000 (18:14 +0200)]
Move inbound channel methods into `InboundV1Channel`'s impl

10 months agoMove outbound channel methods into `OutboundV1Channel`'s impl
Duncan Dean [Wed, 7 Jun 2023 16:09:23 +0000 (18:09 +0200)]
Move outbound channel methods into `OutboundV1Channel`'s impl

10 months agoCreate and use methods for counting channels
Duncan Dean [Wed, 7 Jun 2023 17:52:21 +0000 (19:52 +0200)]
Create and use methods for counting channels

This commit also adds two new maps to `PeerState` for keeping track
of `OutboundV1Channel`s and `InboundV1Channel`s so that further
commits are a bit easier to review.

10 months agoRefactor channel map update macros for use with `ChannelContext`
Duncan Dean [Wed, 7 Jun 2023 17:22:59 +0000 (19:22 +0200)]
Refactor channel map update macros for use with `ChannelContext`

10 months agoMove `Channel::force_shutdown` to `ChannelContext` impl
Duncan Dean [Tue, 13 Jun 2023 15:31:28 +0000 (17:31 +0200)]
Move `Channel::force_shutdown` to `ChannelContext` impl

10 months agoMove inbound channel constructor into `InboundV1Channel` impl
Duncan Dean [Wed, 7 Jun 2023 14:17:18 +0000 (16:17 +0200)]
Move inbound channel constructor into `InboundV1Channel` impl

10 months agoMove outbound channel constructor into `OutboundV1Channel` impl
Duncan Dean [Wed, 7 Jun 2023 14:09:35 +0000 (16:09 +0200)]
Move outbound channel constructor into `OutboundV1Channel` impl

10 months agoIntroduce `InboundV1Channel` & `OutboundV1Channel`
Duncan Dean [Wed, 5 Apr 2023 11:43:02 +0000 (13:43 +0200)]
Introduce `InboundV1Channel` & `OutboundV1Channel`

10 months agoMove channel constants up
Duncan Dean [Thu, 30 Mar 2023 09:17:32 +0000 (11:17 +0200)]
Move channel constants up

10 months agoMake `ChannelManager::issue_channel_close_events` take a `ChannelContext`
Duncan Dean [Tue, 13 Jun 2023 14:43:43 +0000 (16:43 +0200)]
Make `ChannelManager::issue_channel_close_events` take a `ChannelContext`

10 months agoConvert `ChannelDetails::from_channel` to `ChannelDetails::from_channel_context`
Duncan Dean [Wed, 7 Jun 2023 09:03:46 +0000 (11:03 +0200)]
Convert `ChannelDetails::from_channel` to `ChannelDetails::from_channel_context`

This rename and refactor is so that we can get channel details from a
`ChannelContext` which is a common object to all channels.

10 months agoMove `Channel::get_available_balances` to `ChannelContext` impl
Duncan Dean [Tue, 13 Jun 2023 14:40:49 +0000 (16:40 +0200)]
Move `Channel::get_available_balances` to `ChannelContext` impl

10 months agoMove `Channel::next_*_commit_tx_fee_msat` methods to `ChannelContext` impl
Duncan Dean [Tue, 13 Jun 2023 11:54:40 +0000 (13:54 +0200)]
Move `Channel::next_*_commit_tx_fee_msat` methods to `ChannelContext` impl

10 months agoMove `Channel::commit_tx_fee_msat` to file-level utilities
Duncan Dean [Tue, 13 Jun 2023 11:26:50 +0000 (13:26 +0200)]
Move `Channel::commit_tx_fee_msat` to file-level utilities

10 months agoMove `Channel::get_*_pending_htlc_stats` to `ChannelContext` impl
Duncan Dean [Tue, 13 Jun 2023 11:19:02 +0000 (13:19 +0200)]
Move `Channel::get_*_pending_htlc_stats` to `ChannelContext` impl

10 months agoPrepare some methods for upcoming moves to `ChannelContext`
Duncan Dean [Tue, 13 Jun 2023 10:34:36 +0000 (12:34 +0200)]
Prepare some methods for upcoming moves to `ChannelContext`

To reduce interleaving in commits, we introduce a `context` variable
in methods to be moved in upcoming commits so there is minimal change
with the moves.

10 months agoMove `Channel::get_feerate_sat_per_1000_weight` and other methods
Duncan Dean [Wed, 7 Jun 2023 10:33:41 +0000 (12:33 +0200)]
Move `Channel::get_feerate_sat_per_1000_weight` and other methods

This is one of a series of commits to make sure methods are moved by
chunks so they are easily reviewable in diffs. Unfortunately they are
not purely move-only as fields to be updated for things to
compile, but these should be quite clear.

This commit also uses the `context` field where needed for compilation
and tests to pass due to the above change.

f s/tarcontext.get_/target_/

10 months agoMove `Channel::build_holder_transaction_keys` and some other methods
Duncan Dean [Wed, 7 Jun 2023 10:26:53 +0000 (12:26 +0200)]
Move `Channel::build_holder_transaction_keys` and some other methods

This is one of a series of commits to make sure methods are moved by
chunks so they are easily reviewable in diffs. Unfortunately they are
not purely move-only as fields need to be updated for things to
compile, but these should be quite clear.

This commit also uses the `context` field where needed for compilation
and tests to pass due to the above change.

10 months agoMove `Channel::build_commitment_transaction` to `ChannelContext` impl
Duncan Dean [Wed, 7 Jun 2023 10:20:25 +0000 (12:20 +0200)]
Move `Channel::build_commitment_transaction` to `ChannelContext` impl

This is one of a series of commits to make sure methods are moved by
chunks so they are easily reviewable in diffs. Unfortunately they are
not purely move-only as fields need to be updated for things to
compile, but these should be quite clear.

This commit also uses the `context` field where needed for compilation
and tests to pass due to the above change.

10 months agoMove `Channel::channel_id` and some other methods to `ChannelContext` impl
Duncan Dean [Wed, 7 Jun 2023 10:15:24 +0000 (12:15 +0200)]
Move `Channel::channel_id` and some other methods to `ChannelContext` impl

This is one of a series of commits to make sure methods are moved by
chunks so they are easily reviewable in diffs. Unfortunately they are
not purely move-only as fields need to be updated for things to
compile, but these should be quite clear.

This commit also uses the `context` field where needed for compilation
and tests to pass due to the above change.

10 months agoMove `Channel::get_update_time_counter` and some other methods
Duncan Dean [Wed, 7 Jun 2023 09:57:35 +0000 (11:57 +0200)]
Move `Channel::get_update_time_counter` and some other methods

This is one of a series of commits to make sure methods are moved by
chunks so they are easily reviewable in diffs. Unfortunately they are
not purely move-only as fields need to be updated for things to
compile, but these should be quite clear.

This commit also uses these methods through the `context` field where
needed for compilation and tests to pass due to the above change.

10 months agoMove `Channel::opt_anchors` to `ChannelContext` impl & move some util fns
Duncan Dean [Wed, 7 Jun 2023 09:29:44 +0000 (11:29 +0200)]
Move `Channel::opt_anchors` to `ChannelContext` impl & move some util fns

This is one of a series of commits to make sure methods are moved by
chunks so they are easily reviewable in diffs. Unfortunately they are
not purely move-only as fields need to be updated for things to
compile, but these should be quite clear.

10 months agoMove `Channel` fields into `ChannelContext` struct
Duncan Dean [Tue, 7 Mar 2023 19:56:01 +0000 (21:56 +0200)]
Move `Channel` fields into `ChannelContext` struct

This is a first step for simplifying the channel state and introducing
new unfunded channel types that hold similar state before being promoted
to funded channels.

Essentially, we want the outer `Channel` type (and upcoming channel types)
to wrap the context so we can apply typestate patterns to the that wrapper
while also deduplicating code for common state and other internal fields.

10 months agoMerge pull request #2294 from jkczyz/2023-05-onion-message-replies
Matt Corallo [Tue, 13 Jun 2023 21:01:32 +0000 (21:01 +0000)]
Merge pull request #2294 from jkczyz/2023-05-onion-message-replies

BOLT 12 Offers message handling support

10 months agoReduce log level of potential noisy log statement
Jeffrey Czyz [Tue, 13 Jun 2023 17:35:41 +0000 (12:35 -0500)]
Reduce log level of potential noisy log statement

10 months agoFuzz test onion message replies
Jeffrey Czyz [Fri, 24 Feb 2023 23:27:18 +0000 (17:27 -0600)]
Fuzz test onion message replies

10 months agoUse different node secrets in onion message fuzzer
Jeffrey Czyz [Wed, 7 Jun 2023 15:55:00 +0000 (10:55 -0500)]
Use different node secrets in onion message fuzzer

When generating onion message fuzz data, the same public key was used
for each node. However, the code now advances the blinded path if the
sender is the introduction node. Use different node secrets for each
node to avoid this. Note that the exercised handling code is for the
sender's immediate peer.

10 months agoTest onion message replies
Jeffrey Czyz [Fri, 24 Feb 2023 00:06:25 +0000 (18:06 -0600)]
Test onion message replies

10 months agoSplit TestCustomMessage into Request and Response
Jeffrey Czyz [Thu, 23 Feb 2023 22:54:58 +0000 (16:54 -0600)]
Split TestCustomMessage into Request and Response

This will allow for testing onion message replies.

10 months agoRemove unnecessary Sized bound
Jeffrey Czyz [Thu, 8 Jun 2023 19:30:38 +0000 (14:30 -0500)]
Remove unnecessary Sized bound

10 months agoSupport onion message replies in OnionMessenger
Jeffrey Czyz [Sun, 19 Feb 2023 01:29:14 +0000 (19:29 -0600)]
Support onion message replies in OnionMessenger

Modify onion message handlers to return an optional response message for
OnionMessenger to reply with.

10 months agoMessageRouter trait for OnionMessenger
Jeffrey Czyz [Thu, 23 Feb 2023 04:22:42 +0000 (22:22 -0600)]
MessageRouter trait for OnionMessenger

Add a trait for finding routes for onion messages and parameterize
OnionMessenger with it. This allows OnionMessenger to reply to messages
that it handles via one of its handlers (e.g., OffersMessageHandler).

10 months agoAdd OnionMessagePath wrapper struct
Jeffrey Czyz [Thu, 25 May 2023 20:02:10 +0000 (15:02 -0500)]
Add OnionMessagePath wrapper struct

To avoid confusion in the upcoming MessageRouter trait, introduce an
OnionMessagePath struct that wraps the intermediate nodes and the
destination. Use this in OnionMessenger::send_onion_message.

10 months agoOffersMessageHandler trait for OnionMessenger
Jeffrey Czyz [Wed, 15 Feb 2023 22:10:59 +0000 (16:10 -0600)]
OffersMessageHandler trait for OnionMessenger

Add a trait for handling BOLT 12 Offers messages to OnionMessenger and a
skeleton implementation of it for ChannelManager. This allows users to
either provide their own custom handling Offers messages or rely on a
version provided by LDK using stateless verification.

10 months agoAvoid an unnecessary unwrap
Jeffrey Czyz [Thu, 18 May 2023 18:15:00 +0000 (13:15 -0500)]
Avoid an unnecessary unwrap

10 months agoOnion message payload for BOLT 12 Offers
Jeffrey Czyz [Tue, 14 Feb 2023 23:41:18 +0000 (17:41 -0600)]
Onion message payload for BOLT 12 Offers

BOLT 12 Offers makes use of onion messages to request and respond with
invoices. Add these types and an error type to OnionMessageContents
along with the necessary parsing and encoding.

10 months agoPass logger to onion payload decoder
Jeffrey Czyz [Fri, 2 Jun 2023 13:08:59 +0000 (08:08 -0500)]
Pass logger to onion payload decoder

In an upcoming commit, messages for BOLT 12 offers are read from the
onion payload. Passing a logger allows for logging semantic errors when
parsing the messages.

10 months agoAdd InvoiceError message
Jeffrey Czyz [Thu, 18 May 2023 22:08:46 +0000 (17:08 -0500)]
Add InvoiceError message

If an InvoiceRequest or an Invoice delivered via an onion message cannot
be handled, the recipient should reply with an InvoiceError if a reply
path was given. Define the message and conversion from SemanticError.

10 months agoSupport WithoutLength for UntrustedString
Jeffrey Czyz [Mon, 5 Jun 2023 20:55:13 +0000 (15:55 -0500)]
Support WithoutLength for UntrustedString

10 months agoFix oops'd docs on PaymentParameters::with_max_channel_saturation
Valentine Wallace [Fri, 19 May 2023 21:37:02 +0000 (17:37 -0400)]
Fix oops'd docs on PaymentParameters::with_max_channel_saturation

10 months agoFix panic on pathfinding to blinded recipient
Valentine Wallace [Tue, 9 May 2023 18:26:10 +0000 (14:26 -0400)]
Fix panic on pathfinding to blinded recipient

The previous dummy payee id was an invalid pubkey

10 months agoMerge pull request #2353 from TheBlueMatt/2023-06-fix-msrv-build
Matt Corallo [Mon, 12 Jun 2023 20:50:53 +0000 (20:50 +0000)]
Merge pull request #2353 from TheBlueMatt/2023-06-fix-msrv-build

10 months agoFix build on supported platforms due to `log` breakage 2023-06-fix-msrv-build
Matt Corallo [Mon, 12 Jun 2023 18:37:17 +0000 (18:37 +0000)]
Fix build on supported platforms due to `log` breakage

The `log` crate decided to break support for rustc 1.48 (Debian
bullseye) the day the next release of Debian comes out, obviously
before anyone has had a chance to upgrade to the new Debian
bookworm (at https://github.com/rust-lang/log/pull/543). Thus, we
have to manually pin it back to the previous release.

Sadly, the `log` crate is a transitive dependency of `tokio` until
0.20, which requires rustc 1.49. Luckily at least we won't have to
deal with this again, as `log` won't be a dependency of ours
anymore soon.

10 months agoStop writing old `user_payment_id` field not read since 0.0.103 2023-04-remove-legacy-recv
Matt Corallo [Mon, 12 Jun 2023 16:50:45 +0000 (16:50 +0000)]
Stop writing old `user_payment_id` field not read since 0.0.103

Since we're breaking downgrade compatibility to LDK version 0.0.103
and before, we might as well go ahead and remove other code we have
for compatibility.

10 months agoDrop `create_inbound_payment*_legacy` breaking downgrade to 0.0.103
Matt Corallo [Sat, 10 Jun 2023 19:52:52 +0000 (19:52 +0000)]
Drop `create_inbound_payment*_legacy` breaking downgrade to 0.0.103

0.0.103 is now downright ancient, and certainly shouldn't exist in
production anywhere today. Thus, it seems fine to remove the
ability to create legacy stateful inbound payment entries.

Users downgrading to 0.0.103 will thus not be able to claim any
payments created on modern LDK, though we still retain the ability
to claim such payments at least for one more release.

10 months agoMerge pull request #2156 from alecchendev/2023-04-mpp-keysend
Matt Corallo [Sat, 10 Jun 2023 19:48:54 +0000 (19:48 +0000)]
Merge pull request #2156 from alecchendev/2023-04-mpp-keysend

Support MPP Keysend

10 months agoAdd test for duplicate keysend payment
Alec Chen [Mon, 22 May 2023 20:20:02 +0000 (15:20 -0500)]
Add test for duplicate keysend payment

The logic has been changed around duplicate keysend payments such that
it's no longer explicitly clear that we reject duplicate keysend
payments now that we handle receiving multi-part keysends. This test
catches that. Note that this also tests that we reject MPP keysends when
our config states we should, and that we reject MPP keysends without
payemnt secrets when our config states we support MPP keysends.

10 months agoSupport receiving MPP keysend
Alec Chen [Wed, 5 Apr 2023 22:45:41 +0000 (17:45 -0500)]
Support receiving MPP keysend

This commit refactors a significant portion of the receive validation in
`ChannelManager::process_pending_htlc_forwards` now that we repurpose
previous MPP validation logic to accomodate keysends. This also removes
a previous restriction on claiming, as well as tests sending and
receiving MPP keysends.

10 months agoTrack MPP data while receiving keysends
Alec Chen [Tue, 2 May 2023 04:05:43 +0000 (23:05 -0500)]
Track MPP data while receiving keysends

This commit adds the field `payment_data: FinalOnionHopData` to
`ReceiveKeysend` which will allow us to check for payment secrets and
total amounts which is needed to support receiving MPP keysends. This
field is non-backwards compatible since we wouldn't be able to handle
an MPP keysend properly if we were to downgrade to a prior version.

We also no longer reject keysends with payment secrets if we support MPP
keysend.

10 months agoHelp users support sending MPP keysend
Alec Chen [Mon, 8 May 2023 22:51:19 +0000 (17:51 -0500)]
Help users support sending MPP keysend

When routing a keysend payment, the user may want to signal to the
router whether to find multi-path routes in the
`PaymentParameters::for_keysend` helper, without going through manual
construction. Since some implementations do not support MPP keysend, we
have the user make the choice here rather than making it the default.

Some implementations will reject keysend payments with payment secrets,
so this commit also adds docs to `RecipientOnionFields` to communicate
this to the user.

10 months agoMerge pull request #2334 from jkczyz/2023-06-bolt12-test-vectors
Matt Corallo [Thu, 8 Jun 2023 18:51:05 +0000 (18:51 +0000)]
Merge pull request #2334 from jkczyz/2023-06-bolt12-test-vectors

Update BOLT 12 test vectors

10 months agoMerge pull request #2333 from benthecarman/chan-mon-bal-helper
Wilmer Paulino [Thu, 8 Jun 2023 01:06:01 +0000 (18:06 -0700)]
Merge pull request #2333 from benthecarman/chan-mon-bal-helper

Add helper for getting claimable balance

10 months agoMerge pull request #2342 from vladimirfomene/2023-06-use-untrustedstring-in-error...
Matt Corallo [Wed, 7 Jun 2023 23:06:15 +0000 (23:06 +0000)]
Merge pull request #2342 from vladimirfomene/2023-06-use-untrustedstring-in-error-logs

Use PrintableString for displaying errors in PeerManager

10 months agoInclude signature check in BOLT 12 signature test
Jeffrey Czyz [Fri, 2 Jun 2023 19:46:00 +0000 (14:46 -0500)]
Include signature check in BOLT 12 signature test

The BOLT 12 test vectors had inadvertently left out a signature, but it
has since been added. Include a signature check in the corresponding
test for completeness.

10 months agoUpdate BOLT 12 test vectors
Jeffrey Czyz [Fri, 2 Jun 2023 19:36:38 +0000 (14:36 -0500)]
Update BOLT 12 test vectors

The previous test vectors contained recurrences and older TLV types, and
therefore couldn't be parsed. Update the tests with the latest test
vectors from the spec and stop ignoring the tests.

10 months agoRemove custom blinded path test vector
Jeffrey Czyz [Fri, 2 Jun 2023 19:21:35 +0000 (14:21 -0500)]
Remove custom blinded path test vector

These were added to help debug an encoding issue. However, the encoding
code was moved to the blinded_path module. Additionally, the test vector
used an old TLV encoding.