Commit Graph

8427 Commits

Author SHA1 Message Date
Matt Corallo
aa2c6fed24
Merge pull request #3408 from valentinewallace/2024-11-async-receive-offer-utils
Add static invoice creation utils to `ChannelManager`
2025-01-17 15:12:14 +00:00
Matt Corallo
3fbf97d75f
Merge pull request #3530 from TheBlueMatt/2025-01-0.1-relnotes
Add draft 0.1 release notes
2025-01-15 21:55:04 +00:00
Matt Corallo
2c5a1f67b6
Merge pull request #3544 from valentinewallace/2025-01-fix-build
Fix build for `cfg(async_payments)`
2025-01-15 21:42:15 +00:00
Valentine Wallace
4e3f8d7f18
Fix build for cfg(async_payments)
Static invoices don't have an amount_msats field.
2025-01-15 14:51:20 -05:00
Matt Corallo
5d1b6e0710 Add draft 0.1 release notes 2025-01-15 18:28:58 +00:00
Matt Corallo
6d604c52b2
Merge pull request #3535 from jkczyz/2025-01-invoice-amount
Validate `amount_msats` against invreq amount
2025-01-15 17:55:10 +00:00
Jeffrey Czyz
c2360be049
Add InvoiceRequest::has_amount_msats
When InvoiceRequest::amount_msats returns Some, it may have been
inferred from the Offer::amount and InvoiceRequest::quantity. Add a
method to InvoiceRequest for determining if the amount was explicitly
set.
2025-01-15 11:23:32 -06:00
Ian Slane
99889d27fd
Validate amount_msats against invreq amount
Add a check to ensure that the amount_msats in an invoice matches the
amount_msats specified in the invoice_request or offer (or refund).
Reject the invoice as invalid if there is a mismatch between these
amounts. Otherwise, an invoice may be paid with an amount greater than
the requested amount.

Co-authored-by: Ian Slane <slaneian@gmail.com>
Co-authored-by: Jeffrey Czyz <jkczyz@gmail.com>
2025-01-15 11:23:32 -06:00
Matt Corallo
bcbff6546f
Merge pull request #3533 from tnull/2025-01-allow-setting-process-callback-in-c-bindings
`liquidity`: Allow setting `process_events` callback in `c_bindings`
2025-01-15 14:11:38 +00:00
Elias Rohrer
e05b76af7b
liquidity: Allow setting process_events callback in c_bindings
To trigger message processing, we previously had the user set a callback
to `PeerManager::process_events` via an `Fn()` callback. This is however
not supported by `c_bindings`.

Here, we therefore introduce as `ProcessMesssagesCallback` trait that
can be used via `LiquidityManager::set_process_msgs_callback_fn`, which
is exposed in `c_bindings`.
2025-01-15 09:58:43 +01:00
Matt Corallo
de7d756688
Merge pull request #3538 from morehouse/fix_package_splitting
Fix package splitting logic
2025-01-15 01:09:44 +00:00
Matt Morehouse
a1d63560af
Fix package splitting logic
When scanning confirmed transactions for spends that conflict with our
existing packages, we should continue scanning after detecting the first
conflicting package since a transaction can conflict with multiple
packages.

This ensures that we remove *all* inputs from our packages that have
already been spent by the counterparty so that valid claim transactions
are generated.

Fixes https://github.com/lightningdevkit/rust-lightning/issues/3537.
2025-01-14 15:40:07 -06:00
Matt Corallo
ad462bd9c8
Merge pull request #3528 from tnull/2025-01-introduce-secondary-msrv-1.75
Move `lightning-transaction-sync` tests to dedicated script
2025-01-14 16:31:11 +00:00
Elias Rohrer
cd5b4f763e
Move lightning-transaction-sync tests to dedicated script
.. and bump its MSRV to 1.75.

Recently, `rustls` bumped their MSRV to 1.71. As we depend on them and
don't want to continuously pin this security-critical dependency back,
we have no choice left but to bump the MSRV for
`lightning-transaction-sync` to a version >= 1.71, too.

Here, we hence move the `lightning-transaction-sync` tests to a
dedicated script and propose to introduce a secondary MSRV of 1.75.

We chose this particular version, because:

a) it's > 1 year old
b) it provides a buffer to 1.71, i.e., if some crate bumped to a version
 > 1.71, there is a chance we don't immediately have to react again
c) it
 stabilized `async fn`s in traits (see
 https://blog.rust-lang.org/2023/12/21/async-fn-rpit-in-traits.html),
 which might become handy for related (BDK) crates, which hopefully will
 adopt the same target.
2025-01-14 14:31:29 +01:00
dunxen
7953b45e7b
Merge pull request #3513 from jkczyz/2024-12-refactor-channel-phase
Refactor `ChannelPhase` variants from `ChannelManager`
2025-01-14 14:52:18 +02:00
Elias Rohrer
c835e8002d
Merge pull request #3521 from TheBlueMatt/2025-01-fix-pin
Fix fuzz CI failures
2025-01-13 19:48:31 +01:00
valentinewallace
5f68d71cbe
Merge pull request #3522 from TheBlueMatt/2025-01-overflow-cltv
Fix max-value overflows in `set_max_path_length`
2025-01-13 12:34:54 -05:00
Matt Corallo
3e88b327ef Fix max-value overflows in set_max_path_length
When either the amount or the `max_total_cltv_expiry_delta` are
set to max-value, `set_max_path_length` can trigger overflows in
`build_onion_payloads_callback`, leading to debug-panics.
2025-01-13 14:51:26 +00:00
Matt Corallo
5a771c3de7 Clean up fuzz test build to fix disk space usage fuzz CI failures 2025-01-13 13:07:34 +00:00
Elias Rohrer
f92c4dc780
Merge pull request #3524 from TheBlueMatt/2025-01-spurious-assert
Drop spurious debug assertion in sweeping logic
2025-01-13 09:24:48 +01:00
Matt Corallo
0282b0d963 Drop spurious debug assertion in sweeping logic
With the `Confirm` interface, transaction confirmations can come
in at any time, so asserting that a confirmation is more recent
than the last time we broadcasted a transaction can lead to
spurious assertion failures.
2025-01-11 17:39:50 +00:00
Matt Corallo
c25dfaffb2
Merge pull request #3520 from jkczyz/2025-01-bindings-payment-paths
Support `Bolt12Invoice::payment_paths` in bindings
2025-01-10 20:28:11 +00:00
Jeffrey Czyz
4579e63e9e
Remove unnecessary lifetime parameter 2025-01-10 11:18:21 -06:00
Jeffrey Czyz
442b030504
Rename ChannelPhase to Channel
In preparation for hiding ChannelPhase inside a Channel type, rename
ChannelPhase to Channel.
2025-01-10 11:18:13 -06:00
Jeffrey Czyz
c55508860f
Rename Channel to FundedChannel
In preparation for hiding ChannelPhase inside a Channel type, rename
Channel to FundedChannel.
2025-01-10 11:16:13 -06:00
Jeffrey Czyz
4a81e65b0e
Implement From<PendingV2Channel> for ChannelPhase
Exposing ChannelPhase in ChannelManager has led to verbose match
statements, which need to be modified each time a ChannelPhase is added.
Making ChannelPhase an implementation detail of Channel would help avoid
this.

As a step in this direction, define a conversion from PendingV2Channel
to ChannelPhase (to be renamed Channel).
2025-01-10 11:16:13 -06:00
Jeffrey Czyz
e8c4849dc7
Implement From<InboundV1Channel> for ChannelPhase
Exposing ChannelPhase in ChannelManager has led to verbose match
statements, which need to be modified each time a ChannelPhase is added.
Making ChannelPhase an implementation detail of Channel would help avoid
this.

As a step in this direction, define a conversion from InboundV1Channel
to ChannelPhase (to be renamed Channel).
2025-01-10 11:16:12 -06:00
Jeffrey Czyz
583224f4f9
Implement From<OutboundV1Channel> for ChannelPhase
Exposing ChannelPhase in ChannelManager has led to verbose match
statements, which need to be modified each time a ChannelPhase is added.
Making ChannelPhase an implementation detail of Channel would help avoid
this.

As a step in this direction, define a conversion from OutboundV1Channel
to ChannelPhase (to be renamed Channel).
2025-01-10 11:16:12 -06:00
Jeffrey Czyz
12ff3614c9
Implement From<Channel> for ChannelPhase
Exposing ChannelPhase in ChannelManager has led to verbose match
statements, which need to be modified each time a ChannelPhase is added.
Making ChannelPhase an implementation detail of Channel would help avoid
this.

As a step in this direction, define a conversion from Channel (to be
renamed FundedChannel) to ChannelPhase (to be renamed Channel).
2025-01-10 11:16:12 -06:00
Jeffrey Czyz
28971d4be1
Remove ChannelPhase::Unfunded*V1 pattern matches
Exposing ChannelPhase in ChannelManager has led to verbose match
statements, which need to be modified each time a ChannelPhase is added.
Making ChannelPhase an implementation detail of Channel would help avoid
this.

As a step in this direction, update ChannelManager methods to use
methods on ChannelPhase for obtaining the appropriate V1 channel types.
2025-01-10 11:16:12 -06:00
Jeffrey Czyz
06a61b3b15
Remove ChannelPhase from convert_chan_phase_err
Exposing ChannelPhase in ChannelManager has led to verbose match
statements, which need to be modified each time a ChannelPhase is added.
Making ChannelPhase an implementation detail of Channel would help avoid
this.

As a step in this direction, update the convert_chan_phase_err macro to
use ChannelPhase::as_funded_mut instead.
2025-01-10 11:16:12 -06:00
Jeffrey Czyz
4b965e0f78
Remove ChannelPhase::UnfundedV2 pattern matches
Exposing ChannelPhase in ChannelManager has led to verbose match
statements, which need to be modified each time a ChannelPhase is added.
Making ChannelPhase an implementation detail of Channel would help avoid
this.

As a step in this direction, update ChannelManager methods to use
ChannelPhase::as_unfunded_v2_mut and ChannelPhase::into_unfunded_v2
methods.
2025-01-10 11:16:12 -06:00
Jeffrey Czyz
537ed88ae9
Rewrite ChannelManager::timer_tick_occurred
Exposing ChannelPhase in ChannelManager has led to verbose match
statements, which need to be modified each time a ChannelPhase is added.
Making ChannelPhase an implementation detail of Channel would help avoid
this.

As a step in this direction, update ChannelManager::timer_tick_occurred
to use ChannelPhase::as_funded_mut and a new
ChannelPhase::unfunded_context_mut method.
2025-01-10 11:16:11 -06:00
Jeffrey Czyz
e24082c6ab
Rewrite ChannelManager::handle_error
Exposing ChannelPhase in ChannelManager has led to verbose match
statements, which need to be modified each time a ChannelPhase is added.
Making ChannelPhase an implementation detail of Channel would help avoid
this.

As a step in this direction, update ChannelManager::handle_error to use
a new ChannelPhase::maybe_handle_error_without_close.
2025-01-10 11:16:11 -06:00
Jeffrey Czyz
fdbce7f75b
Rewrite ChannelManager::peer_connected
Exposing ChannelPhase in ChannelManager has led to verbose match
statements, which need to be modified each time a ChannelPhase is added.
Making ChannelPhase an implementation detail of Channel would help avoid
this.

As a step in this direction, update ChannelManager::peer_connected to
use ChannelPhase::as_funded_mut and a new
ChannelPhase::maybe_get_open_channel method.
2025-01-10 11:16:11 -06:00
Jeffrey Czyz
a6c70eab0a
Rewrite ChannelManager::peer_disconnected
Exposing ChannelPhase in ChannelManager has led to verbose match
statements, which need to be modified each time a ChannelPhase is added.
Making ChannelPhase an implementation detail of Channel would help avoid
this.

As a step in this direction, update ChannelManager::peer_disconnected to
use ChannelPhase::as_funded_mut and a new ChannelPhase::is_resumable
method.
2025-01-10 11:16:11 -06:00
Jeffrey Czyz
cae893af64
Rewrite ChannelManager::signer_unblocked
Exposing ChannelPhase in ChannelManager has led to verbose match
statements, which need to be modified each time a ChannelPhase is added.
Making ChannelPhase an implementation detail of Channel would help avoid
this.

As a step in this direction, update ChannelManager::signer_unblocked to
use ChannelPhase::as_funded and a new method on ChannelPhase dispatching
to each variant's signer_maybe_unblocked method.
2025-01-10 11:16:11 -06:00
Jeffrey Czyz
307e0485d2
Handle tx_abort without using ChannelPhase
Exposing ChannelPhase in ChannelManager has led to verbose match
statements, which need to be modified each time a ChannelPhase is added.
Making ChannelPhase an implementation detail of Channel would help avoid
this.

As a step in this direction, update ChannelManager::internal_tx_abort to
use ChannelPhase::is_funded and a new ChannelPhase::as_unfunded_v2_mut
method.
2025-01-10 11:16:11 -06:00
Jeffrey Czyz
6f119eb20c
Rewrite ChannelManager::unfunded_channel_count
Exposing ChannelPhase in ChannelManager has led to verbose match
statements, which need to be modified each time a ChannelPhase is added.
Making ChannelPhase an implementation detail of Channel would help avoid
this.

As a step in this direction, rewrite ChannelManager's
unfunded_channel_count method to use ChannelPhase::as_funded and a new
ChannelPhase::as_unfunded_v2 method.
2025-01-10 11:16:10 -06:00
Jeffrey Czyz
401bdb84e3
Add ChannelPhase::is_funded for filtering channels.
Exposing ChannelPhase in ChannelManager has led to verbose match
statements, which need to be modified each time a ChannelPhase is added.
Making ChannelPhase an implementation detail of Channel would help avoid
this.

As a step in this direction, introduce ChannelPhase::is_funded for use
in ChannelManager when a Channel (to be later renamed FundedChannel)
needs to be tested for.
2025-01-10 11:16:03 -06:00
Jeffrey Czyz
93d00b385d
Support Bolt12Invoice::payment_paths in bindings
Lack of bindings support was because the method used to return a slice
of tuples, it seems. Now that it returns &[BlindedPaymentPath], bindings
should be possible given that they can be generated for
Bolt12Invoice::message_paths.
2025-01-10 09:51:31 -06:00
Elias Rohrer
cb5bf96cca
Merge pull request #3518 from dunxen/2025-01-allow-unnecessary-map-or
ci: silence unnecessary_map_or lint as solution requires MSRV >= 1.70
2025-01-10 09:14:36 +01:00
Duncan Dean
ec579f0303
ci: silence unnecessary_map_or lint as solution requires MSRV >= 1.70
Rust 1.84.0 was recently released along with some new clippy lints, one
of which is `unnecessary_map_or`. Unfortunately this lint suggests using
`Option::is_some_and` as a fix, but this is only available in Rust
 version >= 1.70, while we still have an MSRV of 1.63. So we silence that
lint for now.

We'd still like our lint CI to use stable Rust so that we can benefit from
new lint checks which may be helpful and don't require an MSRV bump, but
sometimes new lints (like in this case) do.

See:
  https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_or
  https://doc.rust-lang.org/std/option/enum.Option.html#method.is_some_and
2025-01-10 08:02:12 +02:00
Matt Corallo
0282cfb29e
Merge pull request #3511 from cequals/amackillop/2024-12-30/add-debug-to-scorer-params
Add debug implementations for scoring parameters
2025-01-09 16:22:44 +00:00
dunxen
7c77daff85
Merge pull request #3498 from jkczyz/2024-12-combine-inbound-v2-phases
Combine `InboundV2Channel` and `OutboundV2Channel`
2025-01-09 11:56:25 +02:00
Jeffrey Czyz
1780ce4e5a
Hide ChannelPhase::Funded behind as_funded method
Exposing ChannelPhase in ChannelManager has led to verbose match
statements, which need to be modified each time a ChannelPhase is added.
Making ChannelPhase an implementation detail of Channel would help avoid
this.

As a step in this direction, introduce ChannelPhase::as_funded and
ChannelPhase::as_funded_mut for use in ChannelManager when a Channel (to
be later renamed FundedChannel) is needed.
2025-01-08 21:29:43 -06:00
Jeffrey Czyz
d6637d7d04
Combine UnfundedInboundV2 and UnfundedOutboundV2
Now that InboundV2Channel and OutboundV2Channel have been combined into
a PendingV2Channel, only one ChannelPhase variant is needed.
2025-01-08 14:09:12 -06:00
Jeffrey Czyz
270c5ab7ab
Remove InteractivelyFunded trait
Now that InboundV2Channel and OutboundV2Channel have been combined into
a PendingV2Channel, the InteractivelyFunded trait is no longer needed.
2025-01-08 14:09:12 -06:00
Jeffrey Czyz
91ff6c1a32
Combine InboundV2Channel and OutboundV2Channel
Pending v2 channels will need to be broken up into separate phases for
constructing and signing the funding transaction. To avoid increasing
the number of phases, combine the InboundV2Channel and OutboundV2Channel
types so that the can be used in one phase. Whether the channel is
inbound or outbound can be inferred from the ChannelContext.
2025-01-08 14:08:55 -06:00
Austin Mackillop
48ceefdc03
Add debug implementations for scoring parameters
Derives Debug for
ProbabilisticScoringFeeParameters and
ProbabiliticScoringDecayParameters
2025-01-08 10:54:06 -05:00