Commit graph

6082 commits

Author SHA1 Message Date
Matt Corallo
f47270e760 Immediately unblock channels on duplicate claims
When `MonitorUpdateCompletionAction`s were added, we didn't
consider the case of a duplicate claim during normal HTLC
processing (as the handling only had an `if let` rather than a
`match`, which made the branch easy to miss). This can lead to a
channel freezing indefinitely if an HTLC is claimed (without a
`commitment_signed`), the peer disconnects, and then the HTLC is
claimed again, leading to a never-completing
`MonitorUpdateCompletionAction`.

The fix is simple - if we get back an
`UpdateFulfillCommitFetch::DuplicateClaim` when claiming from the
inbound edge, immediately unlock the outbound edge channel with a
new `MonitorUpdateCompletionAction::FreeOtherChannelImmediately`.

Here we implement this fix by actually generating the new variant
when a claim is duplicative.
2023-10-19 15:27:57 +00:00
Matt Corallo
9ea90a4a44 Add an immediately-freeing MonitorUpdateCompletionAction.
When `MonitorUpdateCompletionAction`s were added, we didn't
consider the case of a duplicate claim during normal HTLC
processing (as the handling only had an `if let` rather than a
`match`, which made the branch easy to miss). This can lead to a
channel freezing indefinitely if an HTLC is claimed (without a
`commitment_signed`), the peer disconnects, and then the HTLC is
claimed again, leading to a never-completing
`MonitorUpdateCompletionAction`.

The fix is simple - if we get back an
`UpdateFulfillCommitFetch::DuplicateClaim` when claiming from the
inbound edge, immediately unlock the outbound edge channel with a
new `MonitorUpdateCompletionAction::FreeOtherChannelImmediately`.

Here we add the new variant, which we start generating in the next
commit.
2023-10-19 15:27:57 +00:00
Matt Corallo
6d85be27d4 Indicate to claim_funds_internal that we're replaying on startup
While we'd previously avoided this, this is sadly now required in
the next commit.
2023-10-19 15:27:57 +00:00
Matt Corallo
82b532c54d Log when we prepare to block a channel's next revoke_and_ack
This may help in debugging blocking actions in the future.
2023-10-19 15:27:57 +00:00
Matt Corallo
6cafba9f5b
Merge pull request #2650 from TheBlueMatt/2023-10-make-clippy-shut-up
Make clippy shut up about `PartialOrd` and `Ord` both impl'd
2023-10-12 20:44:46 +00:00
Matt Corallo
60c10735f9
Merge pull request #2657 from Fedeparma74/fix-close-channel-deadlock
Fix deadlock when closing an unavailable channel
2023-10-12 18:16:02 +00:00
Fedeparma74
7cdb31ae20 Fix deadlock when closing an unavailable channel 2023-10-11 10:50:28 +02:00
Elias Rohrer
989304ed36
Merge pull request #2652 from tnull/2023-10-deref-achannelmanager 2023-10-08 09:11:19 +02:00
valentinewallace
1f1a8dd5c5
Merge pull request #2651 from G8XSU/rm-same-feerate-log
Remove log for not changing feerate when it was equal
2023-10-06 13:18:32 -10:00
Matt Corallo
89749eddec
Merge pull request #2649 from benthecarman/display-outpoint
Impl Display for Outpoint
2023-10-06 19:00:01 +00:00
Elias Rohrer
808e72ad15
Have methods take AChannelManager as Deref::Target 2023-10-06 07:30:45 -10:00
benthecarman
42c5640d19
Impl Display for Outpoint 2023-10-05 22:45:29 -05:00
Gursharan Singh
2ee554a1c4
Remove log for not changing feerate when it was equal
Log is not required in this case and creates unnecessary log lines at
trace level.
2023-10-05 15:19:36 -10:00
Matt Corallo
ec7d665436 Make clippy shut up about PartialOrd and Ord both impl'd
Clippy gets mad that we have an implementation of `ParialOrd` and
`Ord` separately, even though both are identical. Making
`ParitalOrd` call `Ord` makes clippy shut up.
2023-10-06 00:02:45 +00:00
Matt Corallo
eea19de198
Merge pull request #2640 from sr-gi/20231003-expose-from-be-bytes
Makes Features::from_be_bytes public
2023-10-05 23:45:59 +00:00
Sergi Delgado Segura
2b1d6937a8 Makes Features::from_be_bytes public
Downstream projects building Feature<T> are most likely doing so with a
big-endian byte array, however only `from_le_bytes` is exposed.
2023-10-05 15:27:13 -04:00
Matt Corallo
9de51f0bee
Merge pull request #2645 from TheBlueMatt/2023-10-changelog-dates
Set the timestamp for and provide diff stats for 0.0.117 CHANGELOG
2023-10-04 02:16:04 +00:00
Matt Corallo
e515c87cf3 Set the timestamp for and provide diff stats for 0.0.117 CHANGELOG 2023-10-03 23:56:58 +00:00
Matt Corallo
dba48f62ea
Merge pull request #2620 from TheBlueMatt/2023-09-cut-0.0.117
Cut 0.0.117
2023-10-03 23:16:59 +00:00
Matt Corallo
c74874604e Bump crate versions to 0.0.117/invoice 0.25 2023-10-03 23:00:48 +00:00
Matt Corallo
3133286c88 Add 0.0.117 release notes 2023-10-03 23:00:48 +00:00
Matt Corallo
7aefa3131c
Merge pull request #2631 from TheBlueMatt/2023-09-pm-no-refs-reqd
Fix `Simple*PeerManager` to not require refs to the `UtxoLookup`
2023-10-03 17:12:19 +00:00
Matt Corallo
0ce1c5a674
Merge pull request #2634 from TheBlueMatt/2023-09-claimable-unwrap
Avoid unwrap'ing `channel_parameters` in to_counterparty signing
2023-10-03 17:12:08 +00:00
Matt Corallo
0b4bb24af8 Clean up at least some lifetimes on SimpleRefPeerManager
Rather than simply a, b, c, d...we at least use names for a few
things, also splitting the reused 'f lifetime.
2023-10-03 04:36:25 +00:00
Matt Corallo
60567da0bd Note when we're allowed to unwrap channel parameters in docs
This further documents the parameter-fetching utilities in
`InMemorySigner` to hopefully make them more robust against future
spurious `unwrap`s.
2023-10-03 04:32:40 +00:00
Matt Corallo
65569ed5d6 Make InMemorySigner parameter-fetching utilities return Options
In the previous commit we fixed a bug where we were spuriously
(indirectly) `unwrap`ing the `channel_parameters` in
`InMemorySigner`. Here we make such bugs much less likely in the
future by having the utilities which do the `unwrap`ing internally
return `Option`s instead.

This makes the `unwrap`s clear at the callsite.
2023-10-03 04:25:03 +00:00
Matt Corallo
04841acb86
Merge pull request #2595 from TheBlueMatt/2023-09-117-bindings-part1
Various cleanups to make bindings generation simpler
2023-10-03 03:56:46 +00:00
Matt Corallo
a938fecc00
Merge pull request #2632 from TheBlueMatt/2023-09-writeable-rwlock
Implement Readable/Writeable for RwLock wrappers
2023-10-03 03:45:03 +00:00
Jeffrey Czyz
9b1b724dad
Merge pull request #2633 from TheBlueMatt/2023-09-expose-onion-parse
Expose `parse_onion_address` publicly in `no-std`
2023-10-02 20:16:13 -05:00
Matt Corallo
6a55dcce83 Avoid unwrap'ing channel_parameters in to_counterparty signing
Previously, `StaticPaymentOutputDescriptor`s did not include
`channel_parameters` for the signer. As a result, when going to
spend old `StaticPaymentOutputDescriptor`s,
`InMemorySigner::sign_counterparty_payment_input` may be called
with `channel_parameters` set to `None`. This should be fine, but
in fa2a2efef4 we started relying on
it (indirectly via `channel_features`) for signing. This caused an
`unwrap` when spending old output descriptors.

This is fixed here by simply avoiding the unwrap and assuming old
`StaticPaymentOutputDescriptor`s represent non-anchor channels.
2023-10-01 00:40:20 +00:00
Matt Corallo
7a583bb756 Remove unused mem::drop which drops a reference 2023-10-01 00:05:01 +00:00
Matt Corallo
6b75fafaf3 Fix new unused variable warning in test_utils.rs 2023-10-01 00:05:01 +00:00
Matt Corallo
add71d42a0 Use crate::prelude::* to load Vec, rather than crate::Vec
This is kinda dumb, but the bindings get confused when referring
to `Vec` absolutely in a `use` statement, and there's no reason not
to load our prelude everywhere.
2023-10-01 00:05:01 +00:00
Matt Corallo
34f36d5ffe Drop various bounds on types passed to MonitorUpdatingPersister
The new `MonitorUpdatingPersister` has a few redundant type bounds
(re-specified on functions after having been specified on the
struct itself), which we remove here.

Further, it requires a `Deref<FeeEstimator>` which is `Clone`able.
This is generally fine in rust, but annoying in bindings, so we
simply elide it in favor if a `&Deref<FeeEstimator>`.
2023-10-01 00:05:01 +00:00
Matt Corallo
07205a2869 Make create_onion_message a freestanding function
The new `create_onion_message` function in `OnionMessenger` is hard
to handle - it has various generic requirements indirectly via the
struct, but they're not bounded by any of the method parameters.
Thus, you can't simply call `OnionMessenger::create_onion_message`,
as various bounds are not specified.

Instead, we move it to a freestanding function so that it can be
called directly without explicitly setting bounds.
2023-10-01 00:05:01 +00:00
Matt Corallo
6ce4c6cbc5 Mark AChannelManager no-export
The trait itself has no purpose for bindings, as all structs are
concretized anyway. Further, the bindings have specific handling
for generic bounding traits like this.
2023-10-01 00:05:01 +00:00
Matt Corallo
09cd4ed976 Mark SpendableOutputDescriptor::to_psbt_input as no-export
Its honestly likely not all that useful as its not materially
interoperable with other PSBT libraries. Instead, users should
simply fetch the full PSBT and use the inputs from it as they see
fit.
2023-10-01 00:05:01 +00:00
Matt Corallo
9c78d8e90e Drop unnecessary crate:: prefix when accessing bitcoin in macro
Unexported macros don't need to use the `$crate` prefix.
2023-10-01 00:05:01 +00:00
Matt Corallo
095fca9293 Avoid ref to a Vec when accessing custom onion TLVs
The bindings can't easily return a reference to a `Vec`, so we
instead split the implementation into vec/slice depending on the
`c_bindings` flag.
2023-10-01 00:05:01 +00:00
Matt Corallo
087c8f683a Avoid blanket impls in bindings builds
The C bindings implements `Deref` for all traits, so having a
blanket `Deref` implementation ends up conflicting with this.
2023-10-01 00:05:01 +00:00
Matt Corallo
0bc0de46fa Simplify score bounding with a unified type
In a few places we require a unified scorer, which implements both
`ScoreLookUp` and `ScoreUpdate`. Rather than double-bounding (which
the bindings generator can't handle directly), we use a top-level
`Score` trait which requires both and is implemented for all
implementers of both supertraits.
2023-10-01 00:05:01 +00:00
Matt Corallo
748bebadb4 Remove unnecessary bounds in scoring
In our scoring logic we have a handful of unnecessary bounds,
leading to extra diff in the bindings branch when those bounds have
to be removed as well as a few cases where bindings generation
simply gets confused.

Here we remove a number of bounds across the scoring traits and
impls, cleaning things up and simplifying bindings changes.
2023-10-01 00:05:01 +00:00
Matt Corallo
26c1639ab6 Use Default::default() to construct () as score-updating param
In 6b0d94a302 we switched most tests
to `Default::default()` for scoring parameters passed to
route-fetching. Here we do the same for the scoring parameters when
passed to score-updating.
2023-10-01 00:05:01 +00:00
Matt Corallo
327142894d Expose parse_onion_address publicly in no-std
The reason for having a separate `parse_onion_address` from
`FromStr` is to have an onion parsing function in `no-std`, but
when we added it we forgot to make it public. We do this here, as
well as fix a few compilation warnings in `no-std`.
2023-09-30 18:06:38 +00:00
Matt Corallo
783e255d4f Switch Simple*ChannelManager locks around Score to RwLock
This switches the locks used around `ProbabilisticScorer` in
`Simple*ChannelManager` type aliases to `RwLock`.
2023-09-30 18:04:31 +00:00
Matt Corallo
6482635ba6 Fix Simple*PeerManager to not require refs to the UtxoLookup
`UtxoLookup` doesn't strictly need to be referenced from the
`PeerManager`, and in fact the new `GossipVerifier` in
`lightning-block-sync` requires itself to be owned by the
`PeerManager` (for circular type reasons).

This allows us to use `lightning-block-sync`'s `GossipVerifier`
with `SimpleArcPeerManager` in ldk-sample.
2023-09-30 17:57:54 +00:00
Matt Corallo
3e93f9ad88 Implement Readable/Writeable for RwLock wrappers
We now support separate R/W locks in `LockableScore`, which allow
us to do routefinding in parallel, however in order to support
`WriteableScore` for such users we need to implement `Writeable`
for `RwLock` wrappers around `Writeable` types, which we do here.
2023-09-30 17:41:43 +00:00
Matt Corallo
20f287f439
Merge pull request #2630 from TheBlueMatt/2023-09-117-rc1
Bump crate versions to 0.0.117-rc1/invoice 0.25-rc1
2023-09-30 00:38:27 +00:00
Matt Corallo
cff2061335
Merge pull request #2610 from wpaulino/missing-htlc-claim-balance
Fix matching of second-stage HTLC claim in get_htlc_balance
2023-09-29 23:55:04 +00:00
Matt Corallo
f534ce26c9
Merge pull request #2621 from G8XSU/dont-persist-erroneous-update
Persist entire monitor if there is an error while applying monitor_update
2023-09-29 23:45:57 +00:00