]> git.bitcoin.ninja Git - rust-lightning/log
rust-lightning
2 years agoRename APIError::MonitorUpdateFailed to MonitorUpdateInProgress
Matt Corallo [Thu, 29 Sep 2022 20:26:48 +0000 (20:26 +0000)]
Rename APIError::MonitorUpdateFailed to MonitorUpdateInProgress

This much more accurately represents the error, indicating that a
monitor update is in progress asynchronously and may complete at a
later time.

2 years agoRename `handle_monitor_err!()` `handle_monitor_update_res!`
Matt Corallo [Tue, 16 Aug 2022 22:16:48 +0000 (22:16 +0000)]
Rename `handle_monitor_err!()` `handle_monitor_update_res!`

2 years agoRename `Channel::monitor_update_failed` to `monitor_updating_paused`
Matt Corallo [Tue, 16 Aug 2022 22:15:32 +0000 (22:15 +0000)]
Rename `Channel::monitor_update_failed` to `monitor_updating_paused`

2 years agoAdd a TODO for an important issue for making async mon updates safe
Matt Corallo [Tue, 16 Aug 2022 21:58:06 +0000 (21:58 +0000)]
Add a TODO for an important issue for making async mon updates safe

If we receive a monitor event from a forwarded-to channel which
contains a preimage for an HTLC, we have to propogate that preimage
back to the forwarded-from channel monitor. However, once we have
that update, we're running in a relatively unsafe state - we have
the preimage in memory, but if we were to crash the forwarded-to
channel monitor will not regenerate the update with the preimage
for us. If we haven't managed to write the monitor update to the
forwarded-from channel by that point, we've lost the preimage, and,
thus, money!

2 years agoRework `chain::Watch` return types to make async updates less scary
Matt Corallo [Mon, 18 Jul 2022 01:32:27 +0000 (01:32 +0000)]
Rework `chain::Watch` return types to make async updates less scary

When a `chain::Watch` `ChannelMonitor` update method is called, the
user has three options:
 (a) persist the monitor update immediately and return success,
 (b) fail to persist the monitor update immediately and return
     failure,
 (c) return a flag indicating the monitor update is in progress and
     will complete in the future.

(c) is rather harmless, and in some deployments should be expected
to be the return value for all monitor update calls, but currently
requires returning `Err(ChannelMonitorUpdateErr::TemporaryFailure)`
which isn't very descriptive and sounds scarier than it is.

Instead, here, we change the return type used to be a single enum
(rather than a Result) and rename `TemporaryFailure`
`UpdateInProgress`.

2 years agoDo not broadcast commitment txn on Permanent mon update failure
Matt Corallo [Tue, 5 Oct 2021 04:32:49 +0000 (04:32 +0000)]
Do not broadcast commitment txn on Permanent mon update failure

See doc updates for more info on the edge case this prevents, and
there isn't really a strong reason why we would need to broadcast
the latest state immediately. Specifically, in the case of HTLC
claims (the most important reason to ensure we have state on chain
if it cannot be persisted), we will still force-close if there are
HTLCs which need claiming and are going to expire.

Surprisingly, there were no tests which failed as a result of this
change, but a new one has been added.

2 years agoMerge pull request #1707 from TheBlueMatt/2022-09-no-global-features
Matt Corallo [Thu, 15 Sep 2022 00:28:32 +0000 (00:28 +0000)]
Merge pull request #1707 from TheBlueMatt/2022-09-no-global-features

Move supported-feature-set logic into the supporting modules

2 years agoAssert that all defined features are in the known features set 2022-09-no-global-features
Matt Corallo [Fri, 9 Sep 2022 04:38:14 +0000 (04:38 +0000)]
Assert that all defined features are in the known features set

Now that the features contexts track the full set of all known
features, rather than the set of supported features, all defined
features should be listed in the context definition macro.

This adds a compile-time assertion to check that all bits for known
features are set in the context known set.

2 years agoStop tracking feature bits as known or required in features.rs
Matt Corallo [Fri, 9 Sep 2022 04:31:18 +0000 (04:31 +0000)]
Stop tracking feature bits as known or required in features.rs

Now that the `*Features::known` constructor has been removed, there
is no reason to define feature bits as either optional required in
`features.rs` - that logic now belongs in the modules that are
responsible for the given features.

Instead, we only list all features in each context.

2 years agoRemove the `*Features::known` constructor
Matt Corallo [Wed, 14 Sep 2022 01:05:25 +0000 (01:05 +0000)]
Remove the `*Features::known` constructor

As we move towards specify supported/required feature bits in the
module(s) where they are supported, the global `known` feature set
constructors no longer make sense.

Here we (finally) remove the `known` constructor entirely,
modifying tests in the `features` module as required.

2 years agoRemove all remaining references to `*Features::known`
Matt Corallo [Wed, 14 Sep 2022 01:05:11 +0000 (01:05 +0000)]
Remove all remaining references to `*Features::known`

As we move towards specify supported/required feature bits in the
module(s) where they are supported, the global `known` feature set
constructors no longer make sense.

In anticipation of removing the `known` constructor, this commit
removes all remaining references to it outside of features.rs.

2 years agoStop relying on `*Features::known` in fuzzing tests
Matt Corallo [Fri, 9 Sep 2022 04:15:40 +0000 (04:15 +0000)]
Stop relying on `*Features::known` in fuzzing tests

As we move towards specify supported/required feature bits in the
module(s) where they are supported, the global `known` feature set
constructors no longer make sense.

Here we stop relying on the `known` method in our fuzz tests.

2 years agoStop relying on `*Features::known` in BP and persister tests
Matt Corallo [Fri, 9 Sep 2022 04:00:33 +0000 (04:00 +0000)]
Stop relying on `*Features::known` in BP and persister tests

As we move towards specify supported/required feature bits in the
module(s) where they are supported, the global `known` feature set
constructors no longer make sense.

Here we stop relying on the `known` method in the
`lightning-background-processor` and `lightning-persister` crate
tests.

2 years agoStop relying on the `*Features::known` method in net-tokio
Matt Corallo [Fri, 9 Sep 2022 02:34:27 +0000 (02:34 +0000)]
Stop relying on the `*Features::known` method in net-tokio

As we move towards specify supported/required feature bits in the
module(s) where they are supported, the global `known` feature set
constructors no longer make sense.

Here we stop relying on the `known` method in the
`lightning-net-tokio` crate.

2 years agoStop relying on the `*Features::known` method in lightning-invoice
Matt Corallo [Mon, 12 Sep 2022 19:20:38 +0000 (19:20 +0000)]
Stop relying on the `*Features::known` method in lightning-invoice

As we move towards specify supported/required feature bits in the
module(s) where they are supported, the global `known` feature set
constructors no longer make sense.

Here we stop relying on the `known` method in the
`lightning-invoice` crate.

2 years agoStop relying on `*Features::known` in channel{,manager}.rs
Matt Corallo [Thu, 8 Sep 2022 21:24:34 +0000 (21:24 +0000)]
Stop relying on `*Features::known` in channel{,manager}.rs

As we move towards specify supported/required feature bits in the
module(s) where they are supported, the global `known` feature set
constructors no longer make sense.

Here we stop relying on the `known` method in the channel modules.

2 years agoStop relying on `*Features::known` in functional test utils
Matt Corallo [Thu, 8 Sep 2022 21:18:07 +0000 (21:18 +0000)]
Stop relying on `*Features::known` in functional test utils

As we move towards specify supported/required feature bits in the
module(s) where they are supported, the global `known` feature set
constructors no longer make sense.

Here we stop relying on the `known` method in the
functional_test_utils module.

2 years agoStop relying on the `*Features::known` method in functional tests
Matt Corallo [Thu, 8 Sep 2022 21:11:11 +0000 (21:11 +0000)]
Stop relying on the `*Features::known` method in functional tests

This diff is commit, like the last, stops relying on the `known`
feature set constructor, doing so entirely with import changes and
sed rules.

2 years agoStop relying on the `*Features::known` method in `routing` tests
Matt Corallo [Thu, 8 Sep 2022 21:04:11 +0000 (21:04 +0000)]
Stop relying on the `*Features::known` method in `routing` tests

As we move towards specify supported/required feature bits in the
module(s) where they are supported, the global `known` feature set
constructors no longer make sense.

Here we stop relying on the `known` method in the `routing` module,
which was only used in tests.

2 years agoList supported/required feature bits explicitly in ChannelManager
Matt Corallo [Mon, 12 Sep 2022 17:47:16 +0000 (17:47 +0000)]
List supported/required feature bits explicitly in ChannelManager

Historically, LDK has considered the "set of known/supported
feature bits" to be an LDK-level thing. Increasingly this doesn't
make sense - different message handlers may provide or require
different feature sets.

In a previous PR, we began the process of transitioning with
feature bits sent to peers being sourced from the attached message
handler.

This commit makes further progress by moving the concept of which
feature bits are supported by our ChannelManager into
channelmanager.rs itself, via the new `provided_*_features`
methods, rather than in features.rs via the `known_channel_features`
and `known` methods.

2 years agoMerge pull request #1721 from acid-bit/fix_typo
valentinewallace [Wed, 14 Sep 2022 16:28:39 +0000 (12:28 -0400)]
Merge pull request #1721 from acid-bit/fix_typo

Fix typo in comment in Cargo.toml

2 years agoMerge pull request #1720 from TheBlueMatt/2022-09-fix-fuzz-warnings
Matt Corallo [Wed, 14 Sep 2022 14:35:49 +0000 (14:35 +0000)]
Merge pull request #1720 from TheBlueMatt/2022-09-fix-fuzz-warnings

Fix compile-time warnings in fuzzing

2 years agoFix typo in comment in Cargo.toml
acid-bit [Wed, 14 Sep 2022 10:49:20 +0000 (11:49 +0100)]
Fix typo in comment in Cargo.toml

2 years agoFix warnings in fuzz which should have been fixed in f725c5a90a11e6 2022-09-fix-fuzz-warnings
Matt Corallo [Wed, 14 Sep 2022 00:50:29 +0000 (00:50 +0000)]
Fix warnings in fuzz which should have been fixed in f725c5a90a11e6

2 years agoFix compile warning in fuzzing introduced in cd0d19c005ee4fa11de93a
Matt Corallo [Wed, 14 Sep 2022 00:49:21 +0000 (00:49 +0000)]
Fix compile warning in fuzzing introduced in cd0d19c005ee4fa11de93a

2 years agoMerge pull request #1685 from wpaulino/anchors-prep
Matt Corallo [Tue, 13 Sep 2022 21:09:25 +0000 (21:09 +0000)]
Merge pull request #1685 from wpaulino/anchors-prep

2 years agoMerge pull request #1717 from TheBlueMatt/2022-09-req-features-in-handlers
valentinewallace [Tue, 13 Sep 2022 20:17:57 +0000 (16:17 -0400)]
Merge pull request #1717 from TheBlueMatt/2022-09-req-features-in-handlers

Move checking of specific require peer feature bits to handlers

2 years agoMerge pull request #1706 from jkczyz/2022-09-filtered-blocks
Matt Corallo [Tue, 13 Sep 2022 19:50:34 +0000 (19:50 +0000)]
Merge pull request #1706 from jkczyz/2022-09-filtered-blocks

Support filtered blocks in `lightning-block-sync`

2 years agoUpdate anchors test vectors to zero HTLC transaction fee variant
Wilmer Paulino [Fri, 26 Aug 2022 19:56:09 +0000 (12:56 -0700)]
Update anchors test vectors to zero HTLC transaction fee variant

Each test featuring HTLCs had a minimum and maximum feerate case. This
is no longer necessary for the zero HTLC transaction anchors variant as
the commitment feerate does not impact whether HTLCs can be trimmed or
not, only the dust limit does.

2 years agoAccount for zero fee HTLC transaction within dust limit calculation
Wilmer Paulino [Mon, 29 Aug 2022 19:34:34 +0000 (12:34 -0700)]
Account for zero fee HTLC transaction within dust limit calculation

With the zero fee HTLC transaction anchors variant, HTLCs can no longer
be trimmed due to their amount being too low to have a mempool valid
HTLC transaction. Now they can only be trimmed based on the dust limit
of each party within the channel.

2 years agoUpdate HTLC script detection to check for anchor output variants
Wilmer Paulino [Thu, 25 Aug 2022 20:23:29 +0000 (13:23 -0700)]
Update HTLC script detection to check for anchor output variants

2 years agoUse zero fee HTLC transactions for anchor channels
Wilmer Paulino [Wed, 27 Jul 2022 21:59:49 +0000 (14:59 -0700)]
Use zero fee HTLC transactions for anchor channels

This is based on the assumption that we only support the zero HTLC
transaction fee variant of anchor channels.

2 years agoExclude HTLC transactions from broadcast on anchor channels
Wilmer Paulino [Thu, 25 Aug 2022 20:36:17 +0000 (13:36 -0700)]
Exclude HTLC transactions from broadcast on anchor channels

HTLC transactions from anchor channels are constrained by a CSV of 1
block, so broadcasting them along with the unconfirmed commitment
tranasction will result in them being immediately rejected as premature.

2 years agoAvoid commitment broadcast upon detected funding spend
Wilmer Paulino [Thu, 25 Aug 2022 20:11:19 +0000 (13:11 -0700)]
Avoid commitment broadcast upon detected funding spend

There's no need to broadcast our local commitment transaction if we've
already seen a confirmed one as it'll be immediately rejected as a
duplicate/conflict.

This will also help prevent dispatching spurious events for bumping
commitment and HTLC transactions through anchor outputs (once
implemented in future work) and the dispatch for said events follows the
same flow as our usual commitment broadcast.

2 years agoUse proper sighash flag for remote HTLCs with anchor outputs
Wilmer Paulino [Thu, 25 Aug 2022 20:27:00 +0000 (13:27 -0700)]
Use proper sighash flag for remote HTLCs with anchor outputs

2 years agoSupport filtered blocks in lightning-block-sync
Jeffrey Czyz [Thu, 8 Sep 2022 20:17:05 +0000 (15:17 -0500)]
Support filtered blocks in lightning-block-sync

Expand the BlockSource trait to allow filtered blocks now that
chain::Listen supports them (d629a7edb7241eee7fde9f5ccdf1c481d2d6297b).
This makes it possible to use BIP 157/158 compact block filters with
lightning-block-sync.

2 years agoMerge pull request #1703 from TheBlueMatt/2022-09-badonion-first-check
valentinewallace [Tue, 13 Sep 2022 17:47:23 +0000 (13:47 -0400)]
Merge pull request #1703 from TheBlueMatt/2022-09-badonion-first-check

Correctly handle BADONION onion errors

2 years agoAdd now-missing `unwrap`s on test calls to `peer_connected`. 2022-09-req-features-in-handlers
Matt Corallo [Mon, 12 Sep 2022 19:09:50 +0000 (19:09 +0000)]
Add now-missing `unwrap`s on test calls to `peer_connected`.

2 years agoMove checking of specific require peer feature bits to handlers
Matt Corallo [Mon, 12 Sep 2022 19:06:17 +0000 (19:06 +0000)]
Move checking of specific require peer feature bits to handlers

As we remove the concept of a global "known/supported" feature set
in LDK, we should also remove the concept of a global "required"
feature set. This does so by moving the checks for specific
required features into handlers.

Specifically, it allows the handler `peer_connected` method to
return an `Err` if the peer should be disconnected. Only one such
required feature bit is currently set - `static_remote_key`, which
is required in `ChannelManager`.

2 years agoSwap some `peer_connected` features to `known` from `empty` in test
Matt Corallo [Mon, 12 Sep 2022 19:34:59 +0000 (19:34 +0000)]
Swap some `peer_connected` features to `known` from `empty` in test

In the next commit we'll enforce counterparty `InitFeatures`
matching our required set in `ChannelManager`, implying they must
be set for many tests where they previously did not need to be (as
they were enforced in `PeerManager`, which is not used in
functional tests).

2 years agoAdd a note that `peer_disconnected` impls must be idempotent
Matt Corallo [Mon, 12 Sep 2022 18:54:05 +0000 (18:54 +0000)]
Add a note that `peer_disconnected` impls must be idempotent

It appears our code is already correct here, but its also nice to
add a quick safety check in `channel.rs` which ensures we will
remain idempotent.

2 years agoAdd test for malformed update error with NODE bit set 2022-09-badonion-first-check
Duncan Dean [Mon, 12 Sep 2022 13:24:14 +0000 (15:24 +0200)]
Add test for malformed update error with NODE bit set

Some tweaks by Matt Corallo <git@bluematt.me>

2 years agoCorrectly handle BADONION onion errors
Matt Corallo [Wed, 7 Sep 2022 21:08:22 +0000 (21:08 +0000)]
Correctly handle BADONION onion errors

Currently we entirely ignore the BADONION bit when deciding how to
handle HTLC failures. This opens us up to an attack where a
malicious node always fails HTLCs backwards via
`update_fail_malformed_htlc` with an error code of
`BADONION|NODE|PERM|X`. In this case, we may decide to interpret
this as a permanent node failure for the node encrypting the onion,
i.e. the counterparty of the node who sent the
`update_fail_malformed_htlc` message and ultimately failed the
HTLC.

Thus, any node we route through could cause us to fully remove its
counterparty from our network graph. Luckily we do not do any
persistent tracking of removed nodes, and thus will re-add the
removed node once it is re-announced or on restart, however we are
likely to add such persistent tracking (at least in-memory) in the
future.

2 years agoMerge pull request #1712 from TheBlueMatt/2022-09-111 v0.0.111
Matt Corallo [Tue, 13 Sep 2022 00:27:54 +0000 (00:27 +0000)]
Merge pull request #1712 from TheBlueMatt/2022-09-111

Cut 0.0.111

2 years agoBump versions to lightning* 0.0.111 and lightning-invoice 0.19 2022-09-111
Matt Corallo [Mon, 12 Sep 2022 22:33:26 +0000 (22:33 +0000)]
Bump versions to lightning* 0.0.111 and lightning-invoice 0.19

2 years agoUpdate release notes for 0.0.111
Matt Corallo [Fri, 9 Sep 2022 18:39:15 +0000 (18:39 +0000)]
Update release notes for 0.0.111

2 years agoMerge pull request #1714 from TheBlueMatt/2022-09-111-bindings-discovered-cleanups
Matt Corallo [Mon, 12 Sep 2022 20:51:51 +0000 (20:51 +0000)]
Merge pull request #1714 from TheBlueMatt/2022-09-111-bindings-discovered-cleanups

Small Cleanups Discovered during Bindings for 0.0.111

2 years agoMerge pull request #1715 from TheBlueMatt/2022-09-fix-msg-send
Matt Corallo [Mon, 12 Sep 2022 20:01:32 +0000 (20:01 +0000)]
Merge pull request #1715 from TheBlueMatt/2022-09-fix-msg-send

Fix encryption of broadcasted gossip messages

2 years agoUpdate `Simple*PeerManager` type aliases to support Onion Messages 2022-09-111-bindings-discovered-cleanups
Matt Corallo [Mon, 12 Sep 2022 18:05:58 +0000 (18:05 +0000)]
Update `Simple*PeerManager` type aliases to support Onion Messages

Note that `SimpleArcPeerHandler` is also updated to not wrap
`IgnoringMessageHandler` in an `Arc`, as `IgnoringMessageHandler`
is already zero-sized.

2 years agoMerge pull request #1716 from TheBlueMatt/2022-09-log-unreadable-type
Matt Corallo [Mon, 12 Sep 2022 18:10:47 +0000 (18:10 +0000)]
Merge pull request #1716 from TheBlueMatt/2022-09-log-unreadable-type

Include the message type when we send unreadable gossip msg errors

2 years agoEncrypt+MAC most P2P messages in-place 2022-09-fix-msg-send
Matt Corallo [Mon, 12 Sep 2022 15:20:37 +0000 (15:20 +0000)]
Encrypt+MAC most P2P messages in-place

For non-gossip-broadcast messages, our current flow is to first
serialize the message into a `Vec`, and then allocate a new `Vec`
into which we write the encrypted+MAC'd message and header.

This is somewhat wasteful, and its rather simple to instead
allocate only one buffer and encrypt the message in-place.

2 years agoFix encryption of broadcasted gossip messages
Matt Corallo [Mon, 12 Sep 2022 15:16:41 +0000 (15:16 +0000)]
Fix encryption of broadcasted gossip messages

In 47e818f198abafba01b9ad278582886f9007dac2, forwarding broadcasted
gossip messages was split into a separate per-peer message buffer.
However, both it and the original regular-message queue are
encrypted immediately when the messages are enqueued. Because the
lightning P2P encryption algorithm is order-dependent, this causes
messages to fail their MAC checks as the messages from the two
queues may not be sent to peers in the order in which they were
encrypted.

The fix is to simply queue broadcast gossip messages unencrypted,
encrypting them when we add them to the regular outbound buffer.

2 years agoDrop unused type parameter on `BlindedRoute::new`
Matt Corallo [Sun, 11 Sep 2022 21:18:01 +0000 (21:18 +0000)]
Drop unused type parameter on `BlindedRoute::new`

I'm not sure why rustc didn't complain about the unused parameter
or why we're allowed to get away without explicitly bounding the
`Sign` in the `KeysInterface`, but the current code requires all
`BlindedPath` construction to explicitly turbofish an unused type.

2 years agoAdd relevant `(C-not exported)` tags on OnionMessenger aliases
Matt Corallo [Sun, 11 Sep 2022 21:12:16 +0000 (21:12 +0000)]
Add relevant `(C-not exported)` tags on OnionMessenger aliases

The "helpful" type aliases don't make sense for C bindings as all
generics are concretized anyway.

2 years agoInline generic bounds rather than using the `where` clause
Matt Corallo [Sat, 10 Sep 2022 20:31:52 +0000 (20:31 +0000)]
Inline generic bounds rather than using the `where` clause

The bindings generator is pretty naive in its generic resolution
and doesn't like `where` clauses for bounds that are simple traits.
This should eventually change, but for now its simplest to just
inline the relevant generic bounds.

2 years agoDo not use blanket impls when building for `c_bindings`
Matt Corallo [Sat, 10 Sep 2022 20:31:42 +0000 (20:31 +0000)]
Do not use blanket impls when building for `c_bindings`

The C bindings generator isn't capable of figuring out if a blanket
impl applies in a given context, and instead opts to always write
out any relevant impl's for a trait. Thus, blanket impls should be
disabled when building with `#[cfg(c_bindings)]`.

2 years agoRename `{Signed,}RawInvoice::hash` to avoid naming collisions
Matt Corallo [Sat, 10 Sep 2022 20:31:12 +0000 (20:31 +0000)]
Rename `{Signed,}RawInvoice::hash` to avoid naming collisions

Now that `{Signed,}RawInvoice` implement the std `Hash` trait,
having a method called `hash` is ambiguous.

Instead, we rename the `hash` methods `signed_hash` to make it
clear that the hash is the one used for the purpose of signing the
invoice.

2 years agoInclude the message type when we send unreadable gossip msg errors 2022-09-log-unreadable-type
Matt Corallo [Mon, 12 Sep 2022 15:35:56 +0000 (15:35 +0000)]
Include the message type when we send unreadable gossip msg errors

2 years agoMerge pull request #1710 from TheBlueMatt/2022-09-compile-warn
Matt Corallo [Sun, 11 Sep 2022 14:54:05 +0000 (14:54 +0000)]
Merge pull request #1710 from TheBlueMatt/2022-09-compile-warn

Fix several compile warnings added in some of my recent commits

2 years agoFix several compile warnings when testing in no-std mode 2022-09-compile-warn
Matt Corallo [Fri, 9 Sep 2022 19:41:58 +0000 (19:41 +0000)]
Fix several compile warnings when testing in no-std mode

2 years agoFix (really dumb) warning rustc introduced in latest beta
Matt Corallo [Fri, 9 Sep 2022 17:09:27 +0000 (17:09 +0000)]
Fix (really dumb) warning rustc introduced in latest beta

2 years agoFix several compile warnings added in some of my recent commits
Matt Corallo [Fri, 9 Sep 2022 16:01:54 +0000 (16:01 +0000)]
Fix several compile warnings added in some of my recent commits

2 years agoMerge pull request #1688 from valentinewallace/2022-08-flip-om-feature-bit
Matt Corallo [Fri, 9 Sep 2022 21:48:33 +0000 (21:48 +0000)]
Merge pull request #1688 from valentinewallace/2022-08-flip-om-feature-bit

Onion messages: flip feature bit ðŸŽ‰

2 years agoMerge pull request #1713 from TheBlueMatt/2022-09-bad-doc-versions
Matt Corallo [Fri, 9 Sep 2022 21:13:36 +0000 (21:13 +0000)]
Merge pull request #1713 from TheBlueMatt/2022-09-bad-doc-versions

Correct `get_claimable_balance` version info

2 years agoMerge pull request #1711 from TheBlueMatt/2022-08-0conf-panic
Matt Corallo [Fri, 9 Sep 2022 20:24:07 +0000 (20:24 +0000)]
Merge pull request #1711 from TheBlueMatt/2022-08-0conf-panic

Fix spurious panic on receipt of a block while awaiting funding

2 years agoUpdate ChannelMessageHandler::provided_node_features docs
Valentine Wallace [Fri, 9 Sep 2022 20:01:41 +0000 (16:01 -0400)]
Update ChannelMessageHandler::provided_node_features docs

To be uniform with the other handler provided_node_features docs

2 years agoDon't advertise onion messages in known channel features
Valentine Wallace [Fri, 9 Sep 2022 16:41:23 +0000 (12:41 -0400)]
Don't advertise onion messages in known channel features

2 years agoOR InitFeatures and NodeFeatures from onion message handler
Valentine Wallace [Fri, 9 Sep 2022 16:29:13 +0000 (12:29 -0400)]
OR InitFeatures and NodeFeatures from onion message handler

Similar to how we OR our InitFeaures and NodeFeatures across both our channel
and routing message handlers, we also want to OR the features of our onion
message handler.

2 years agoSupport forwarding onion messages in advertised features
Valentine Wallace [Fri, 26 Aug 2022 23:40:10 +0000 (19:40 -0400)]
Support forwarding onion messages in advertised features

In upcoming commit(s), onion message support will be advertised conditionally
based on the OnionMessageProvider provided to PeerManager.

2 years agoAdd missing wumbo feature bit docs
Valentine Wallace [Sat, 6 Aug 2022 22:23:30 +0000 (18:23 -0400)]
Add missing wumbo feature bit docs

2 years agoAdd a new NodeFeatures constructor to capture the types of flags
Valentine Wallace [Fri, 9 Sep 2022 16:17:33 +0000 (12:17 -0400)]
Add a new NodeFeatures constructor to capture the types of flags

When ChannelMessageHandler implementations wish to return a NodeFeatures which
contain all the known flags that are relevant to channel handling, but not
gossip  handling, they currently need to do so by manually constructing a
NodeFeatures with all known flags and then clearing the ones they don't want.

Instead of spreading this logic across the codebase, this consolidates such
construction into one place in features.rs.

2 years agoOR NodeFeatures from both Channel and Routing message handlers
Valentine Wallace [Fri, 9 Sep 2022 16:12:50 +0000 (12:12 -0400)]
OR NodeFeatures from both Channel and Routing message handlers

When we broadcast a node announcement, the features we support are really a
combination of all the various features our different handlers support. This
commit captures this concept by OR'ing our NodeFeatures across both our channel
and routing message handlers.

2 years agoCorrect `get_claimable_balance` version info 2022-09-bad-doc-versions
Matt Corallo [Fri, 9 Sep 2022 19:30:30 +0000 (19:30 +0000)]
Correct `get_claimable_balance` version info

5a8ede09fb3c8bbcd8694d94c12dac9ea7485537 updated the documentation
on `get_claimable_balance` to note that if a channel went on-chain
with an LDK version older than 0.0.108 some
counterparty-revoked-output claimable balances my be missing.
However, this failed to account for the fact that we rely on the
entirely-new-in-0.0.111
`confirmed_commitment_tx_counterparty_output` field for some
balances as well.

Thus, the comment should have been in terms of 0.0.111, not
0.0.108.

2 years agoMerge pull request #1709 from tnull/2022-09-make-access-error-debug
Matt Corallo [Fri, 9 Sep 2022 18:46:41 +0000 (18:46 +0000)]
Merge pull request #1709 from tnull/2022-09-make-access-error-debug

Derive `Debug` for `AccessError`

2 years agoFix spurious panic on receipt of a block while awaiting funding 2022-08-0conf-panic
Matt Corallo [Mon, 29 Aug 2022 18:42:34 +0000 (18:42 +0000)]
Fix spurious panic on receipt of a block while awaiting funding

When we receive a block we always test if we should send our
channel_ready via `check_get_channel_ready`. If the channel in
question requires confirmations, we quickly return if the funding
transaction has not yet confirmed (or even been defined), however
for 0conf channels the checks are necessarily more involved.

In any case, we wish to panic if the funding transaction has
confirmations prior to when it should have been broadcasted. This
is useful as it is easy for users to violate our broadcast-time
invariants without noticing and the panic gives us an opportunity
to catch it.

Sadly, in the case of 0conf channels, if we hadn't yet seen the
funding transaction at all but receive a block we would hit this
sanity check as we don't check whether there are actually funding
transaction confirmations prior to panicing.

2 years agoEnable all feature sets to OR with another set of the same type
Valentine Wallace [Fri, 9 Sep 2022 15:54:22 +0000 (11:54 -0400)]
Enable all feature sets to OR with another set of the same type

2 years agoMerge pull request #1701 from TheBlueMatt/2022-09-feature-or
Matt Corallo [Fri, 9 Sep 2022 16:47:25 +0000 (16:47 +0000)]
Merge pull request #1701 from TheBlueMatt/2022-09-feature-or

Fetch InitFeatures from both Channel and Routing Message Handlers

2 years agoMake clear_initial_routing_sync more consistent with other APIs 2022-09-feature-or
Matt Corallo [Wed, 7 Sep 2022 17:43:14 +0000 (17:43 +0000)]
Make clear_initial_routing_sync more consistent with other APIs

2 years agoAdd a new InitFeatures constructor to capture the types of flags
Matt Corallo [Wed, 7 Sep 2022 17:55:01 +0000 (17:55 +0000)]
Add a new InitFeatures constructor to capture the types of flags

When `ChannelMessageHandler` implementations wish to return an
`InitFeatures` which contain all the known flags that are relevant
to channel handling, but not gossip handling, they currently need
to do so by manually constructing an InitFeatures with all known
flags and then clearing the ones they dont want.

Instead of spreading this logic out across the codebase, this
consolidates such construction to one place in features.rs.

2 years agoOR InitFeatures from both Channel and Routing message handlers
Matt Corallo [Wed, 7 Sep 2022 17:35:50 +0000 (17:35 +0000)]
OR InitFeatures from both Channel and Routing message handlers

When we go to send an Init message to new peers, the features we
support are really a combination of all the various features our
different handlers support. This commit captures this concept by
OR'ing our InitFeatures across both our Channel and Routing
handlers.

Note that this also disables setting the `initial_routing_sync`
flag in init messages, as was intended in
e742894492c55802b241eebc585bbd28aa16481b, per the comment added on
`clear_initial_routing_sync`, though this should not be a behavior
change in practice as nodes which support gossip queries ignore the
initial routing sync flag.

2 years agoFetch our `InitFeatures` from `ChannelMessageHandler`
Matt Corallo [Wed, 7 Sep 2022 17:51:16 +0000 (17:51 +0000)]
Fetch our `InitFeatures` from `ChannelMessageHandler`

Like we now do for `NodeFeatures`, this converts to asking our
registered `ChannelMessageHandler` for our `InitFeatures` instead
of hard-coding them to the global LDK known set.

This allows handlers to set different feature bits based on what
our configuration actually supports rather than what LDK supports
in aggregate.

2 years agoDerive `Debug` for `AccessError`
Elias Rohrer [Fri, 9 Sep 2022 13:18:43 +0000 (15:18 +0200)]
Derive `Debug` for `AccessError`

2 years agoMerge pull request #1699 from TheBlueMatt/2022-08-announcement-rework
Matt Corallo [Fri, 9 Sep 2022 00:34:10 +0000 (00:34 +0000)]
Merge pull request #1699 from TheBlueMatt/2022-08-announcement-rework

2 years agoMerge pull request #1704 from TheBlueMatt/2022-09-always-probe-failed
Matt Corallo [Thu, 8 Sep 2022 20:35:15 +0000 (20:35 +0000)]
Merge pull request #1704 from TheBlueMatt/2022-09-always-probe-failed

Dont use PaymentPathFailed a probe fails without making it out

2 years agoAdd a folder to track CHANGELOG entries for the next release 2022-08-announcement-rework
Matt Corallo [Wed, 7 Sep 2022 00:01:12 +0000 (00:01 +0000)]
Add a folder to track CHANGELOG entries for the next release

2 years agoMove `broadcast_node_announcement` to `PeerManager`
Matt Corallo [Tue, 6 Sep 2022 22:34:29 +0000 (22:34 +0000)]
Move `broadcast_node_announcement` to `PeerManager`

Some `NodeFeatures` will, in the future, represent features which
are not enabled by the `ChannelManager`, but by other message
handlers handlers. Thus, it doesn't make sense to determine the
node feature bits in the `ChannelManager`.

The simplest fix for this is to change to generating the
node_announcement in `PeerManager`, asking all the connected
handlers which feature bits they support and simply OR'ing them
together. While this may not be sufficient in the future as it
doesn't consider feature bit dependencies, support for those could
be handled at the feature level in the future.

This commit moves the `broadcast_node_announcement` function to
`PeerHandler` but does not yet implement feature OR'ing.

2 years agoSend channel_{announcement,update} msgs on connection, not timer
Matt Corallo [Tue, 6 Sep 2022 21:30:33 +0000 (21:30 +0000)]
Send channel_{announcement,update} msgs on connection, not timer

When we connect to a new peer, immediately send them any
channel_announcement and channel_update messages for any public
channels we have with other peers. This allows us to stop sending
those messages on a timer when they have not changed and ensures
we are sending messages when we have peers connected, rather than
broadcasting at startup when we have no peers connected.

2 years agoImprove debuggability when tests fail due to excess events 2022-09-always-probe-failed
Matt Corallo [Wed, 7 Sep 2022 21:53:13 +0000 (21:53 +0000)]
Improve debuggability when tests fail due to excess events

2 years agoDont use PaymentPathFailed a probe fails without making it out
Matt Corallo [Wed, 7 Sep 2022 21:39:17 +0000 (21:39 +0000)]
Dont use PaymentPathFailed a probe fails without making it out

When we fail to forward a probe HTLC at all and immediately fail it
(e.g. due to the first hop channel closing) we'd previously
spuriously generate only a `PaymentPathFailed` event. This violates
the expected API, as users expect a `ProbeFailed` event instead.

This fixes the oversight by ensuring we generate the correct event.

Thanks to @jkczyz for pointing out this issue.

2 years agoDrop redundant code in `fail_holding_cell_htlcs`
Matt Corallo [Wed, 7 Sep 2022 21:09:50 +0000 (21:09 +0000)]
Drop redundant code in `fail_holding_cell_htlcs`

`fail_holding_cell_htlcs` calls through to
`fail_htlc_backwards_internal` for HTLCs that need to be
failed-backwards but opts to generate its own payment failure
events for `HTLCSource:;OutboundRoute` HTLCs. There is no reason
for that as `fail_htlc_backwards_internal` will also happily
generate (now-)equivalent events for `HTLCSource::OutboundRoute`
HTLCs.

Thus, we can drop the redundant code and always call
`fail_htlc_backwards_internal` for each HTLC in
`fail_holding_cell_htlcs`.

2 years agoMerge pull request #1702 from TheBlueMatt/2022-09-one-hop-retryable
Matt Corallo [Thu, 8 Sep 2022 17:34:04 +0000 (17:34 +0000)]
Merge pull request #1702 from TheBlueMatt/2022-09-one-hop-retryable

Mark failed one-hop HTLCs as retrably

2 years agoMerge pull request #1700 from TheBlueMatt/2022-09-missing-event-deser
Matt Corallo [Thu, 8 Sep 2022 15:41:58 +0000 (15:41 +0000)]
Merge pull request #1700 from TheBlueMatt/2022-09-missing-event-deser

Add missing deserialization of Event::HTLCHandlingFailed

2 years agoAdd missing deserialization of Event::HTLCHandlingFailed 2022-09-missing-event-deser
Matt Corallo [Tue, 6 Sep 2022 22:51:29 +0000 (22:51 +0000)]
Add missing deserialization of Event::HTLCHandlingFailed

17e6c374c513f2eca810fa4e931be65f0d4fc29f added the
`HTLCHandlingFailed` event, including serialization thereof,
however failed to add corresponding deserialization. This corrects
that oversight by adding said deserialization.

Thanks to @wpaulino for catching the oversight.

2 years agoRename `rejected_by_dest` -> `payment_failed_permanently` 2022-09-one-hop-retryable
Matt Corallo [Wed, 7 Sep 2022 20:58:05 +0000 (20:58 +0000)]
Rename `rejected_by_dest` -> `payment_failed_permanently`

The `rejected_by_dest` field of the `PaymentPathFailed` event has
always been a bit of a misnomer, as its really more about retry
than where a payment failed. Now is as good a time as any to
rename it.

2 years agoMark failed counterparty-is-destination HTLCs retryable
Matt Corallo [Wed, 7 Sep 2022 20:02:04 +0000 (20:02 +0000)]
Mark failed counterparty-is-destination HTLCs retryable

When our counterparty is the payment destination and we receive
an `HTLCFailReason::Reason` in `fail_htlc_backwards_internal` we
currently always set `rejected_by_dest` in the `PaymentPathFailed`
event, implying the HTLC should *not* be retried.

There are a number of cases where we use `HTLCFailReason::Reason`,
but most should reasonably be treated as retryable even if our
counterparty was the destination (i.e. `!rejected_by_dest`):
 * If an HTLC times out on-chain, this doesn't imply that the
   payment is no longer retryable, though the peer may well be
   offline so retrying may not be very useful,
 * If a commitment transaction "containing" a dust HTLC is
   confirmed on-chain, this definitely does not imply the payment
   is no longer retryable
 * If the channel we intended to relay over was closed (or
   force-closed) we should retry over another path,
 * If the channel we intended to relay over did not have enough
   capacity we should retry over another path,
 * If we received a update_fail_malformed_htlc message from our
   peer, we likely should *not* retry, however this should be
   exceedingly rare, and appears to nearly never appear in practice

Thus, this commit simply disables the behavior here, opting to
treat all `HTLCFailReason::Reason` errors as retryable.

Note that prior to 93e645daf46f85949ae0edf60d36bf21e9fde8af this
change would not have made sense as it would have resulted in us
retrying the payment over the same channel in some cases, however
we now "blame" our own channel and will avoid it when routing for
the same payment.

2 years agoMerge pull request #1697 from TheBlueMatt/2022-08-event-docs
valentinewallace [Wed, 7 Sep 2022 02:04:39 +0000 (22:04 -0400)]
Merge pull request #1697 from TheBlueMatt/2022-08-event-docs

Clarify and consolidate event handling requirements

2 years agoMerge pull request #1698 from TheBlueMatt/2022-09-release-names
valentinewallace [Wed, 7 Sep 2022 01:57:16 +0000 (21:57 -0400)]
Merge pull request #1698 from TheBlueMatt/2022-09-release-names

Add release names to CHANGELOG

2 years agoMerge pull request #1691 from TheBlueMatt/2022-08-dust-retry
valentinewallace [Wed, 7 Sep 2022 00:02:50 +0000 (20:02 -0400)]
Merge pull request #1691 from TheBlueMatt/2022-08-dust-retry

Correct payment resolution after on chain failure of dust HTLCs

2 years agoAdd release names to CHANGELOG 2022-09-release-names
Matt Corallo [Tue, 6 Sep 2022 21:17:15 +0000 (21:17 +0000)]
Add release names to CHANGELOG

There have been release names in Github for some time, though some
releases were missed. This adds them to CHANGELOG.

2 years agoClarify and consolidate event handling requirements 2022-08-event-docs
Matt Corallo [Tue, 6 Sep 2022 20:56:24 +0000 (20:56 +0000)]
Clarify and consolidate event handling requirements

We've seen a bit of user confusion about the requirements for event
handling, largely because the idempotency and consistency
requirements weren't super clearly phrased. While we're at it, we
also consolidate some documentation out of the event handling
function onto the trait itself.

Fixes #1675.