]> git.bitcoin.ninja Git - rust-lightning/log
rust-lightning
3 years agoSend initial closing_signed message asynchronously and handle errs
Matt Corallo [Mon, 19 Jul 2021 19:57:37 +0000 (19:57 +0000)]
Send initial closing_signed message asynchronously and handle errs

When we added the support for external signing, many of the
signing functions were allowed to return an error, closing the
channel in such a case. `sign_closing_transaction` is one such
function which can now return an error, except instead of handling
it properly we'd simply never send a `closing_signed` message,
hanging the channel until users intervene and force-close it.

Piping the channel-closing error back through the various callsites
(several of which already have pending results by the time they
call `maybe_propose_first_closing_signed`) may be rather
complicated, so instead we simply attempt to propose the initial
`closing_signed` in `get_and_clear_pending_msg_events` like we do
for holding-cell freeing.

Further, since we now (possibly) generate a `ChannelMonitorUpdate`
on `shutdown`, we may need to wait for monitor updating to complete
before we can send a `closing_signed`, meaning we need to handle
the send asynchronously anyway.

This simplifies a few function interfaces and has no impact on
behavior, aside from a few message-ordering edge-cases, as seen in
the two small test changes required.

3 years agoDo not serialize `Channel::last_sent_closing_fee` to disk
Matt Corallo [Mon, 19 Jul 2021 18:32:11 +0000 (18:32 +0000)]
Do not serialize `Channel::last_sent_closing_fee` to disk

We're supposed to write `Channel` to disk as if
`remove_uncommitted_htlcs_and_mark_paused` had just run, however we
were writing `last_sent_closing_fee` to disk (if it is not-None),
whereas `remove_uncommitted_htlcs_and_mark_paused` clears it.
Indeed, the BOLTs say fee "... negotiation restarts on
reconnection."

3 years agoLog shutdown including which side of the channel initiated shutdown
Matt Corallo [Tue, 6 Jul 2021 23:51:11 +0000 (23:51 +0000)]
Log shutdown including which side of the channel initiated shutdown

3 years agoImplement the closing_signed TLV suffix with allowed fee ranges
Matt Corallo [Mon, 5 Jul 2021 23:21:36 +0000 (23:21 +0000)]
Implement the closing_signed TLV suffix with allowed fee ranges

This adds the serialization and structures for the new fee range
specifiers in closing_signed as added upstream at
https://github.com/lightningnetwork/lightning-rfc/pull/847

3 years agoImprove TLV serialization macro callability very slightly
Matt Corallo [Mon, 5 Jul 2021 23:18:41 +0000 (23:18 +0000)]
Improve TLV serialization macro callability very slightly

This allows decode_tlv_stream!() to be called with either a mutable
reference to a stream or a stream itself and allows
encode_tlv_stream!() to be called with an excess , at the end of
the parameter list.

3 years agoAdd new `ChannelError` category to send `warning` messages
Matt Corallo [Mon, 26 Jul 2021 20:01:36 +0000 (20:01 +0000)]
Add new `ChannelError` category to send `warning` messages

We don't actually yet support `warning` messages as there are
issues left to resolve in the spec PR, but there's nothing to stop
us adding an internal enum variant for sending a warning message
before we actually support doing so.

3 years agoAdd #[allow(unused_mut)] on reorg_test as older rustc requires mut
Matt Corallo [Mon, 9 Aug 2021 22:03:53 +0000 (22:03 +0000)]
Add #[allow(unused_mut)] on reorg_test as older rustc requires mut

3 years agoMerge pull request #985 from TheBlueMatt/2021-06-auto-chan-fee-updates
Matt Corallo [Fri, 13 Aug 2021 23:00:33 +0000 (23:00 +0000)]
Merge pull request #985 from TheBlueMatt/2021-06-auto-chan-fee-updates

Automatically Update fees on outbound channels

3 years agoLimit inbound fee updates by dust exposure instead of our estimator 2021-06-auto-chan-fee-updates
Matt Corallo [Wed, 30 Jun 2021 03:16:01 +0000 (03:16 +0000)]
Limit inbound fee updates by dust exposure instead of our estimator

Inbound fee udpates are rather broken in lightning as they can
impact the non-fundee despite the funder paying the fee, but only
in the dust exposure it places on the fundee.

At least lnd is fairly aggressively high in their (non-anchor) fee
estimation, running the risk of force-closure. Further, because we
relied on a fee estimator we don't have full control over, we
were assuming our users' fees are particularly conservative, and
thus were at a lot of risk to force-closures.

This converts our fee limiting to use an absurd upper bound,
focusing on whether we are over-exposed to in-flight dust when we
receive an update_fee.

3 years agoLog when we change HTLC state while sending a commitment transaction
Matt Corallo [Tue, 13 Jul 2021 16:07:01 +0000 (16:07 +0000)]
Log when we change HTLC state while sending a commitment transaction

3 years agoFix handling of inbound uncommitted feerate updates
Matt Corallo [Mon, 12 Jul 2021 15:39:27 +0000 (15:39 +0000)]
Fix handling of inbound uncommitted feerate updates

If we receive an update_fee but do not receive a commitment_signed,
we should not persist the pending fee update to disk or hold on to
it after our peer disconnects.

In order to make the code the most readable, we add a state enum
which matches the relevant states from InboundHTLCState, allowing
for more simple code comparison between inbound HTLC handling and
update_fee handling.

3 years agoFix re-sending commitment updates with an outbound fee update
Matt Corallo [Wed, 30 Jun 2021 18:12:51 +0000 (18:12 +0000)]
Fix re-sending commitment updates with an outbound fee update

When we send an update_fee to our counterparty on an outbound
channel, if we need to re-send a commitment update after
reconnection, the update_fee must be present in the re-sent
commitment update messages. However, wewere always setting the
update_fee field in the commitment update to None, causing us to
generate invalid commitment signatures and get channel
force-closures.

This fixes the issue by correctly detecting when an update_fee
needs to be re-sent, doing so when required.

3 years agoAdd more logging during chanmon_consistency runs
Matt Corallo [Tue, 13 Jul 2021 02:23:41 +0000 (02:23 +0000)]
Add more logging during chanmon_consistency runs

3 years agoAdd fuzz coverage of (potential) fee update messages
Matt Corallo [Wed, 30 Jun 2021 03:09:04 +0000 (03:09 +0000)]
Add fuzz coverage of (potential) fee update messages

3 years agoAutomatically update fees on outbound channels as fees change
Matt Corallo [Mon, 28 Jun 2021 03:41:44 +0000 (03:41 +0000)]
Automatically update fees on outbound channels as fees change

Previously we'd been expecting to implement anchor outputs before
shipping 0.1, thus reworking our channel fee update process
entirely and leaving it as a future task. However, due to the
difficulty of working with on-chain anchor pools, we are now likely
to ship 0.1 without requiring anchor outputs.

In either case, there isn't a lot of reason to require that users
call an explicit "prevailing feerates have changed" function now
that we have a timer method which is called regularly. Further, we
really should be the ones deciding on the channel feerate in terms
of the users' FeeEstimator, instead of requiring users implement a
second fee-providing interface by calling an update_fee method.

Finally, there is no reason for an update_fee method to be
channel-specific, as we should be updating all (outbound) channel
fees at once.

Thus, we move the update_fee handling to the background, calling it
on the regular 1-minute timer. We also update the regular 1-minute
timer to fire on startup as well as every minute to ensure we get
fee updates even on mobile clients that are rarely, if ever, open
for more than one minute.

3 years agoSet cfg=fuzzing when building fuzz crate in CI
Matt Corallo [Mon, 5 Jul 2021 18:13:16 +0000 (18:13 +0000)]
Set cfg=fuzzing when building fuzz crate in CI

We will likely drop the fuzztarget feature soon, and should thus be
setting cfg=fuzzing explicitly anyway.

3 years agoAdd standard derives for ConfirmationTarget
Matt Corallo [Sun, 4 Jul 2021 14:51:21 +0000 (14:51 +0000)]
Add standard derives for ConfirmationTarget

3 years agoMerge pull request #1009 from ariard/2021-07-add-forward-dust-limit
Matt Corallo [Tue, 10 Aug 2021 22:11:18 +0000 (22:11 +0000)]
Merge pull request #1009 from ariard/2021-07-add-forward-dust-limit

Add new config setting `max_balance_dust_htlc_msat`

3 years agoAdd test_max_balance_dust_htlc
Antoine Riard [Wed, 28 Jul 2021 23:59:11 +0000 (19:59 -0400)]
Add test_max_balance_dust_htlc

3 years agoEnforce `max_balance_dust_htlc_msat` at HTLC reception/forward
Antoine Riard [Wed, 28 Jul 2021 23:55:11 +0000 (19:55 -0400)]
Enforce `max_balance_dust_htlc_msat` at HTLC reception/forward

At `update_add_htlc()`/`send_htlc()`, we verify that the inbound/
outbound dust or the sum of both, on either sides of the link isn't
above new config setting `max_balance_dust_htlc_msat`.

A dust HTLC is hence defined as a trimmed-to-dust one, i.e including
the fee cost to publish its claiming transaction.

3 years agoModify pending inbound/outbound getters to access dust balances
Antoine Riard [Wed, 28 Jul 2021 23:54:20 +0000 (19:54 -0400)]
Modify pending inbound/outbound getters to access dust balances

3 years agoAdd new config setting `max_balance_dust_htlc_msat`
Antoine Riard [Wed, 28 Jul 2021 23:51:02 +0000 (19:51 -0400)]
Add new config setting `max_balance_dust_htlc_msat`

Trimmed-to-dust HTLCs are at risk of being burnt as miner fees
at anytime during their lifetime due to the broadcast of either
holder commitment transaction or counterparty's one.

To hedge against this risk, we introduce a new config setting
`max_balance_dust_htlc_msat`, with the initial value of
5_000_000 msat.

3 years agoMerge pull request #1025 from TheBlueMatt/2021-07-detect-htlcs-on-local-commitment
Matt Corallo [Tue, 10 Aug 2021 15:10:45 +0000 (15:10 +0000)]
Merge pull request #1025 from TheBlueMatt/2021-07-detect-htlcs-on-local-commitment

3 years agoMerge pull request #1038 from valentinewallace/2021-08-keysend-docs
Matt Corallo [Tue, 10 Aug 2021 00:56:25 +0000 (00:56 +0000)]
Merge pull request #1038 from valentinewallace/2021-08-keysend-docs

3 years agoAdd requirement of payment secret for multi path payments
Valentine Wallace [Fri, 6 Aug 2021 22:18:36 +0000 (18:18 -0400)]
Add requirement of payment secret for multi path payments

in send_payment_internal

3 years agoMerge pull request #1019 from jkczyz/2021-07-shutdown-pubkey
Matt Corallo [Mon, 9 Aug 2021 21:41:02 +0000 (21:41 +0000)]
Merge pull request #1019 from jkczyz/2021-07-shutdown-pubkey

Fetch shutdown script based on `commit_upfront_shutdown_pubkey`

3 years agoAdd APIError::IncompatibleShutdownScript
Jeffrey Czyz [Mon, 2 Aug 2021 03:31:07 +0000 (22:31 -0500)]
Add APIError::IncompatibleShutdownScript

3 years agoImplement Display for ShutdownScript
Jeffrey Czyz [Sat, 31 Jul 2021 04:27:58 +0000 (23:27 -0500)]
Implement Display for ShutdownScript

3 years agoPass InitFeatures by reference to Channel
Jeffrey Czyz [Sun, 1 Aug 2021 21:36:07 +0000 (16:36 -0500)]
Pass InitFeatures by reference to Channel

3 years agoRemove unreachable BroadcastChannelUpdate
Jeffrey Czyz [Mon, 9 Aug 2021 20:15:12 +0000 (15:15 -0500)]
Remove unreachable BroadcastChannelUpdate

When handling shutdown messages, Channel cannot move to
ChannelState::ShutdownComplete. Remove the code in ChannelManager that
adds a MessageSendEvent::BroadcastChannelUpdate in this case since it is
unreachable.

3 years agoGenerate shutdown script at channel close
Jeffrey Czyz [Mon, 26 Jul 2021 18:04:44 +0000 (14:04 -0400)]
Generate shutdown script at channel close

When a shutdown script is omitted from open_channel or accept_channel,
it must be provided when sending shutdown. Generate the shutdown script
at channel closing time in this case rather at channel opening.

This requires producing a ChannelMonitorUpdate with the shutdown script
since it is no longer known at ChannelMonitor creation.

3 years agoAdd features to NodeCfg and use in create_network
Jeffrey Czyz [Sat, 7 Aug 2021 06:02:11 +0000 (01:02 -0500)]
Add features to NodeCfg and use in create_network

3 years agoConnect nodes in remaining tests
Jeffrey Czyz [Sat, 31 Jul 2021 14:32:27 +0000 (09:32 -0500)]
Connect nodes in remaining tests

Similar to 2745bd5ac776c48950bcb630338538d31a9615d0, this ensures that
ChannelManager knows about the features its peers.

3 years agoSupport all shutdown scripts defined in BOLT 2
Jeffrey Czyz [Mon, 26 Jul 2021 16:31:24 +0000 (12:31 -0400)]
Support all shutdown scripts defined in BOLT 2

KeysInterface::get_shutdown_pubkey is used to form P2WPKH shutdown
scripts. However, BOLT 2 allows for a wider variety of scripts. Refactor
KeysInterface to allow any supported script while still maintaining
serialization backwards compatibility with P2WPKH script pubkeys stored
simply as the PublicKey.

Add an optional TLV field to Channel and ChannelMonitor to support the
new format, but continue to serialize the legacy PublicKey format.

3 years agoUse ShutdownScript to check scripts from peers
Jeffrey Czyz [Wed, 28 Jul 2021 19:04:10 +0000 (14:04 -0500)]
Use ShutdownScript to check scripts from peers

3 years agoAdd ShutdownScript for BOLT 2 acceptable scripts
Jeffrey Czyz [Thu, 22 Jul 2021 01:12:14 +0000 (20:12 -0500)]
Add ShutdownScript for BOLT 2 acceptable scripts

BOLT 2 enumerates the script formats that may be used for a shutdown
script. KeysInterface::get_shutdown_pubkey returns a PublicKey used to
form one of the acceptable formats (P2WPKH). Add a ShutdownScript
abstraction to encapsulate all accept formats and be backwards
compatible with P2WPKH scripts serialized as the corresponding
PublicKey.

3 years agoClean up and add shutdown script functional tests
Jeffrey Czyz [Thu, 29 Jul 2021 17:41:03 +0000 (12:41 -0500)]
Clean up and add shutdown script functional tests

3 years agoMerge pull request #1035 from TheBlueMatt/2021-08-faster-pings
Matt Corallo [Mon, 9 Aug 2021 18:52:25 +0000 (18:52 +0000)]
Merge pull request #1035 from TheBlueMatt/2021-08-faster-pings

Suggest faster ping in `PeerManager::timer_tick_occurred` docs

3 years agoHandle being asleep for more than double our ping time gracefully 2021-08-faster-pings
Matt Corallo [Sat, 7 Aug 2021 20:45:01 +0000 (20:45 +0000)]
Handle being asleep for more than double our ping time gracefully

If we've been asleep for double our ping time, for whatever reason,
disconnect all open sockets.

3 years agoUpdate lightning-background-processor to ping every five seconds
Matt Corallo [Thu, 5 Aug 2021 17:04:18 +0000 (17:04 +0000)]
Update lightning-background-processor to ping every five seconds

This updates lightning-background-processor calls to
PeerManager::timer_tick_occurred to match the new suggested rate in
the documentation.

3 years agoSuggest faster ping in `PeerManager::timer_tick_occurred` docs
Matt Corallo [Wed, 4 Aug 2021 16:21:36 +0000 (16:21 +0000)]
Suggest faster ping in `PeerManager::timer_tick_occurred` docs

This clarifies the docs for `PeerManager::timer_tick_occurred` to
note that the call rate is entirely up to the user, and also
suggests a faster ping rate of "once every five to ten seconds"
instead of "every 30 seconds". There isn't a lot of reason to want
to ping less often, and faster ping means we detect disconnects
sooner, which is important.

3 years agoCorrectly detect missing HTLCs when a local commitment tx was broadcast 2021-07-detect-htlcs-on-local-commitment
Matt Corallo [Sat, 31 Jul 2021 03:34:16 +0000 (03:34 +0000)]
Correctly detect missing HTLCs when a local commitment tx was broadcast

If we forward an HTLC to our counterparty, but we force-closed the
channel before our counterparty provides us an updated commitment
transaction, we'll end up with a commitment transaction that does
not contain the HTLC which we attempted to forward. In this case,
we need to wait `ANTI_REORG_DELAY` blocks and then fail back the
HTLC as there is no way for us to learn the preimage and the
confirmed commitment transaction paid us the value of the HTLC.

However, check_spend_holder_transaction did not do this - it
instead only looked for dust HTLCs in the confirmed commitment
transaction, paying no attention to what other HTLCs may exist that
are missed.

This will eventually lead to channel force-closure as the channel
on which we received the inbound HTLC to forward will be closed in
time for the initial sender to claim the HTLC on-chain.

3 years agoDRY HTLC failure code in check_spend_counterparty_transaction
Matt Corallo [Sat, 31 Jul 2021 03:31:10 +0000 (03:31 +0000)]
DRY HTLC failure code in check_spend_counterparty_transaction

This extracts the HTLC-not-in-broadcasted-commitment-transaction
code from check_spend_counterparty_transaction and moves it to a
global macro, DRYing up the two very similar codepaths (fixing
some minor logging inconsistencies) in the process.

This macro will be used for local commitment transaction HTLC
failure as well in the next commit.

This commit has no functional change outside of logging.

3 years agoUpdate keysend docs
Valentine Wallace [Fri, 6 Aug 2021 22:17:58 +0000 (18:17 -0400)]
Update keysend docs

3 years agoMerge pull request #1029 from TheBlueMatt/2021-07-log-channel-close
Matt Corallo [Thu, 5 Aug 2021 21:05:43 +0000 (21:05 +0000)]
Merge pull request #1029 from TheBlueMatt/2021-07-log-channel-close

Log when a channel is closed on startup due to stale ChannelManager

3 years agoMake BackgroundProcessor `#[must_use]` to avoid dropping immediately 2021-07-log-channel-close
Matt Corallo [Sun, 1 Aug 2021 02:42:42 +0000 (02:42 +0000)]
Make BackgroundProcessor `#[must_use]` to avoid dropping immediately

It is easy for users to have a bug where they drop a
`BackgroundProcessor` immediately, causing it to start and then
immediately stop. Instead, add a `#[must_use]` tag to provide a
compiler warning for such instances.

3 years agoLog when a channel is closed on startup due to stale ChannelManager
Matt Corallo [Sun, 1 Aug 2021 02:13:36 +0000 (02:13 +0000)]
Log when a channel is closed on startup due to stale ChannelManager

This is one of the riskiest parts of our API from the perspective
of accidental force-closes - if users delay persisting the
ChannelManager much at all after a ChannelMonitor we may hit a
force-close after restart.

The fact that we don't log at all when this happens is criminal.

3 years agoAdd additional TLV serialization type of (default_value, N)
Matt Corallo [Fri, 16 Jul 2021 18:10:37 +0000 (18:10 +0000)]
Add additional TLV serialization type of (default_value, N)

This allows TLV serialization macros to read non-Option-wrapped
types but allow them to be missing, filling them in with the
provided default value as needed.

3 years agoMerge pull request #1004 from TheBlueMatt/2021-07-forward-event
Matt Corallo [Wed, 4 Aug 2021 22:58:14 +0000 (22:58 +0000)]
Merge pull request #1004 from TheBlueMatt/2021-07-forward-event

Add a `PaymentForwarded` Event

3 years agoChange return value of `claim_funds` to ignore duplicate claims 2021-07-forward-event
Matt Corallo [Tue, 3 Aug 2021 16:49:31 +0000 (16:49 +0000)]
Change return value of `claim_funds` to ignore duplicate claims

While we should never reach `ClaimFundsFromHop::DuplicateClaim` in
most cases, if we do, it likely indicates the HTLC was timed out
some time ago and is no longer available to be claimed. Thus, it
does not make sense to imply that we `claimed_any_htlcs`.

3 years agoGenerate a PaymentForwarded event when a forwarded HTLC is claimed
Matt Corallo [Fri, 16 Jul 2021 02:16:50 +0000 (02:16 +0000)]
Generate a PaymentForwarded event when a forwarded HTLC is claimed

It is useful for accounting and informational reasons for users to
be informed when a payment has been successfully forwarded. Thus,
when an HTLC which represents a forwarded leg is claimed, we
generate a new `PaymentForwarded` event.

This requires some additional plumbing to return HTLC values from
`OnchainEvent`s. Further, when we have to go on-chain to claim the
inbound side of the payment, we do not inform the user of the fee
reward, as we cannot calculate it until we see what is confirmed
on-chain.

Substantial code structure rewrites by:
Valentine Wallace <vwallace@protonmail.com>

3 years agoMerge pull request #1022 from TheBlueMatt/2021-07-to-remote-reorg
Matt Corallo [Wed, 4 Aug 2021 03:08:53 +0000 (03:08 +0000)]
Merge pull request #1022 from TheBlueMatt/2021-07-to-remote-reorg

Fix to_remote SpendableOutputs generation in rare reorg cases

3 years agoFix to_remote SpendableOutputs generation in rare reorg cases 2021-07-to-remote-reorg
Matt Corallo [Thu, 29 Jul 2021 19:49:09 +0000 (19:49 +0000)]
Fix to_remote SpendableOutputs generation in rare reorg cases

If we first see a local commitment transaction, and then a reorg
causes the confirmed channel close transaction to instead be a
remote commitment transaction, we would fail a spurious `if else`
check, resulting in us not generating the correct `SpendableOutput`
event for the to_remote output now confirmed on chain.

This resolves the incorrect logic and adds a regression test.

3 years agoMerge pull request #1028 from lightning-signer/2021-08-no-std
Matt Corallo [Tue, 3 Aug 2021 17:06:59 +0000 (17:06 +0000)]
Merge pull request #1028 from lightning-signer/2021-08-no-std

Actual no_std support

3 years agoRename no_std feature to no-std
Devrandom [Tue, 3 Aug 2021 07:38:44 +0000 (09:38 +0200)]
Rename no_std feature to no-std

matches rust-bitcoin

3 years agoMerge pull request #1033 from TheBlueMatt/2021-07-fix-beta
Matt Corallo [Tue, 3 Aug 2021 14:41:35 +0000 (14:41 +0000)]
Merge pull request #1033 from TheBlueMatt/2021-07-fix-beta

Fix lightning-persister tests for upcoming rustc changes

3 years agoActual no_std support
Devrandom [Sun, 1 Aug 2021 16:22:06 +0000 (18:22 +0200)]
Actual no_std support

3 years agoCheck IO errors in test using `raw_os_error()` instead of `kind()` 2021-07-fix-beta
Matt Corallo [Mon, 2 Aug 2021 15:04:40 +0000 (15:04 +0000)]
Check IO errors in test using `raw_os_error()` instead of `kind()`

std::io::ErrorKind is a `#[non_exhaustive]` enum as more specific
error types are to be added in the future. It was unclear in the
docs until very recently, however, that this is to be done by
re-defining `ErrorKind::Other` errors to new enum variants. Thus,
our tests which check explicitly for `ErrorKind::Other` as a
result of trying to access a directory as a file were incorrect.
Sadly, these generated no meaningful feedback from rustc at all,
except that they're suddenly failing in rustc beta!

After some back-and-forth, it seems rustc is moving forward
breaking existing code in future versions, so we move to the
"correct" check here, which is to check the raw IO error.

See rust-lang/rust#86442 and rust-lang/rust#85746 for more info.

3 years agoMerge pull request #1032 from jkczyz/2021-08-clippy
Matt Corallo [Mon, 2 Aug 2021 16:28:14 +0000 (16:28 +0000)]
Merge pull request #1032 from jkczyz/2021-08-clippy

3 years agoFail linter on #[warn(clippy::try_err)]
Jeffrey Czyz [Mon, 2 Aug 2021 15:30:01 +0000 (10:30 -0500)]
Fail linter on #[warn(clippy::try_err)]

Some heavily used macros are using ? directly on an Err. Using a return
is easier to read and removes hundreds of linter warnings.

https://rust-lang.github.io/rust-clippy/master/index.html#try_err

3 years agoFix #[warn(clippy::try_err)] in ser_macros.rs
Jeffrey Czyz [Mon, 2 Aug 2021 14:29:49 +0000 (09:29 -0500)]
Fix #[warn(clippy::try_err)] in ser_macros.rs

3 years agoAdd CI runs on rustc beta on Windows and MacOS
Matt Corallo [Mon, 2 Aug 2021 14:52:02 +0000 (14:52 +0000)]
Add CI runs on rustc beta on Windows and MacOS

This should catch any platform-specific behavior changes in rustc
before they land in stable.

3 years agoMerge pull request #1012 from TheBlueMatt/2021-07-bump-deps
Matt Corallo [Sat, 31 Jul 2021 20:42:59 +0000 (20:42 +0000)]
Merge pull request #1012 from TheBlueMatt/2021-07-bump-deps

Bump dependencies to bitcoin 0.27 and bech32 0.8

3 years agoAdd a `#[macro_use]` on the `alloc` import for `format!()` 2021-07-bump-deps
Matt Corallo [Thu, 22 Jul 2021 15:18:22 +0000 (15:18 +0000)]
Add a `#[macro_use]` on the `alloc` import for `format!()`

3 years agoFix no_std warnings due to unused includes
Matt Corallo [Thu, 22 Jul 2021 15:13:37 +0000 (15:13 +0000)]
Fix no_std warnings due to unused includes

3 years agoDrop MSRV for no_std to 1.47 as that's what Ubuntu LTS ships with
Matt Corallo [Thu, 22 Jul 2021 15:01:03 +0000 (15:01 +0000)]
Drop MSRV for no_std to 1.47 as that's what Ubuntu LTS ships with

...but disable it for now given core2 is broken (it claims an MSRV
of 1.47 but does not build).

3 years agoBump dependencies to bitcoin 0.27 and bech32 0.8
Matt Corallo [Thu, 22 Jul 2021 14:31:37 +0000 (14:31 +0000)]
Bump dependencies to bitcoin 0.27 and bech32 0.8

3 years agoMerge pull request #1024 from TheBlueMatt/2021-07-always-connect-in-tests
Matt Corallo [Fri, 30 Jul 2021 20:53:30 +0000 (20:53 +0000)]
Merge pull request #1024 from TheBlueMatt/2021-07-always-connect-in-tests

Connect peers on startup in tests

3 years agoConnect peers on startup in tests 2021-07-always-connect-in-tests
Matt Corallo [Fri, 30 Jul 2021 18:21:12 +0000 (18:21 +0000)]
Connect peers on startup in tests

This avoids `ChannelManager` ever being confused by the fact that
it received a message from a peer which it didn't think it was
connected to.

3 years agoMerge pull request #1021 from TheBlueMatt/2021-07-broken-beta
Matt Corallo [Thu, 29 Jul 2021 18:06:05 +0000 (18:06 +0000)]
Merge pull request #1021 from TheBlueMatt/2021-07-broken-beta

Disable fast-fail to let CI actually run even though beta is broken

3 years agoMerge pull request #1007 from jkczyz/2021-07-stop-drop-shutem-down
Matt Corallo [Thu, 29 Jul 2021 17:49:05 +0000 (17:49 +0000)]
Merge pull request #1007 from jkczyz/2021-07-stop-drop-shutem-down

Stop BackgroundProcessor's thread on drop

3 years agoDisable fast-fail to let CI actually run even though beta is broken 2021-07-broken-beta
Matt Corallo [Thu, 29 Jul 2021 17:40:14 +0000 (17:40 +0000)]
Disable fast-fail to let CI actually run even though beta is broken

3 years agoMerge pull request #1020 from TheBlueMatt/2021-07-log-features-more
Matt Corallo [Wed, 28 Jul 2021 21:58:31 +0000 (21:58 +0000)]
Merge pull request #1020 from TheBlueMatt/2021-07-log-features-more

Macroize feature printing to ensure we don't miss new flags

3 years agoAdd join method to BackgroundProcessor
Jeffrey Czyz [Mon, 19 Jul 2021 17:50:56 +0000 (12:50 -0500)]
Add join method to BackgroundProcessor

The previous commit wraps the background thread's JoinHandle in an
Option. Providing a dedicated method to join hides this implementation
detail from users.

3 years agoMacroize feature printing to ensure we don't miss new flags 2021-07-log-features-more
Matt Corallo [Wed, 28 Jul 2021 21:06:49 +0000 (21:06 +0000)]
Macroize feature printing to ensure we don't miss new flags

3 years agoTest preimages are learned instantly in test_onchain_to_onchain_claim
Matt Corallo [Fri, 16 Jul 2021 00:21:52 +0000 (00:21 +0000)]
Test preimages are learned instantly in test_onchain_to_onchain_claim

test_onchain_to_onchain_claim was connecting additional blocks in
order to reach HTLC timeout and broadcast an HTLC-Timeout
transaction, resulting in it not testing whether HTLC preimages are
learned instantly in response to HTLC-Success transactions.

3 years agoIgnore unknown Events serialized with an odd type value.
Matt Corallo [Thu, 15 Jul 2021 16:30:52 +0000 (16:30 +0000)]
Ignore unknown Events serialized with an odd type value.

This should provide some additional future extensibility, allowing
for new informational events which can be safely ignored to be
ignored by older versions.

3 years agoDrop single-use macro from check_spend_holder_transaction
Matt Corallo [Thu, 15 Jul 2021 16:00:15 +0000 (16:00 +0000)]
Drop single-use macro from check_spend_holder_transaction

The wait_threshold_conf!() macro in check_spend_holder_transaction
was only used once, making it a good candidate for inlining at the
callsite. Further, it incorrectly always logged that we were
failing HTLCs from the "latest" commitment transaction, when it is
sometimes actually failing HTLCs from the previous commitment
transaction.

3 years agoMerge pull request #977 from TheBlueMatt/2021-06-fix-double-claim-close
Matt Corallo [Wed, 28 Jul 2021 01:24:27 +0000 (01:24 +0000)]
Merge pull request #977 from TheBlueMatt/2021-06-fix-double-claim-close

Handle double-HTLC-claims without failing the backwards channel

3 years agoFail channel if we can't sign a new commitment tx during HTLC claim 2021-06-fix-double-claim-close
Matt Corallo [Thu, 15 Jul 2021 22:26:51 +0000 (22:26 +0000)]
Fail channel if we can't sign a new commitment tx during HTLC claim

Previously, we could fail to generate a new commitment transaction
but it simply indicated we had gone to doule-claim an HTLC. Now
that double-claims are returned instead as Ok(None), we should
handle the error case and fail the channel, as the only way to hit
the error case is if key derivation failed or the user refused to
sign the new commitment transaction.

This also resolves an issue where we wouldn't inform our
ChannelMonitor of the new payment preimage in case we failed to
fetch a signature for the new commitment transaction.

3 years agoSimplify call graph of get_update_fulfill_htlc since it can't Err.
Matt Corallo [Thu, 15 Jul 2021 21:56:42 +0000 (21:56 +0000)]
Simplify call graph of get_update_fulfill_htlc since it can't Err.

3 years agoHandle double-HTLC-claims without failing the backwards channel
Matt Corallo [Tue, 29 Jun 2021 21:05:45 +0000 (21:05 +0000)]
Handle double-HTLC-claims without failing the backwards channel

When receiving an update_fulfill_htlc message, we immediately
forward the claim backwards along the payment path before waiting
for a full commitment_signed dance. This is great, but can cause
duplicative claims if a node sends an update_fulfill_htlc message,
disconnects, reconnects, and then has to re-send its
update_fulfill_htlc message again.

While there was code to handle this, it treated it as a channel
error on the inbound channel, which is incorrect - this is an
expected, albeit incredibly rare, condition. Instead, we handle
these double-claims correctly, simply ignoring them.

With debug_assertions enabled, we also check that the previous
close of the same HTLC was a fulfill, and that we are not moving
from a HTLC failure to an HTLC claim after its too late.

A test is also added, which hits all three failure cases in
`Channel::get_update_fulfill_htlc`.

Found by the chanmon_consistency fuzzer.

3 years agoMerge pull request #967 from valentinewallace/2021-06-keysend
Matt Corallo [Wed, 28 Jul 2021 00:32:27 +0000 (00:32 +0000)]
Merge pull request #967 from valentinewallace/2021-06-keysend

Keysend

3 years agoClarify decode_update_add_htlc_onion comment
Valentine Wallace [Mon, 19 Jul 2021 22:37:55 +0000 (18:37 -0400)]
Clarify decode_update_add_htlc_onion comment

Clearer phrasing

3 years agotests: make PaymentSecret optional in pass_along path
Valentine Wallace [Thu, 8 Jul 2021 16:44:39 +0000 (12:44 -0400)]
tests: make PaymentSecret optional in pass_along path

and use it to make more keysend tests

3 years agoImplement utilities for keysending to private nodes
Valentine Wallace [Fri, 25 Jun 2021 23:43:55 +0000 (19:43 -0400)]
Implement utilities for keysending to private nodes

3 years agoImplement sending keysend payments (to public nodes)
Valentine Wallace [Wed, 23 Jun 2021 19:15:16 +0000 (15:15 -0400)]
Implement sending keysend payments (to public nodes)

3 years agotest utils: add optional PaymentPreimage param to pass_along_path
Valentine Wallace [Fri, 25 Jun 2021 20:36:18 +0000 (16:36 -0400)]
test utils: add optional PaymentPreimage param to pass_along_path

This will allow keysend tests to assert that the PaymentReceived payment preimage is
as expected in upcoming commits.

3 years agoImplement receiving keysend payments
Valentine Wallace [Sun, 4 Jul 2021 21:42:26 +0000 (17:42 -0400)]
Implement receiving keysend payments

3 years agoRefactor PaymentReceived event for keysend receives
Valentine Wallace [Wed, 30 Jun 2021 22:35:36 +0000 (18:35 -0400)]
Refactor PaymentReceived event for keysend receives

3 years agoAdd PendingHTLCRouting variant for receiving keysend payments
Valentine Wallace [Wed, 30 Jun 2021 18:05:53 +0000 (14:05 -0400)]
Add PendingHTLCRouting variant for receiving keysend payments

3 years agoFix indentation in decode_update_add_htlc_onion
Valentine Wallace [Wed, 30 Jun 2021 17:50:09 +0000 (13:50 -0400)]
Fix indentation in decode_update_add_htlc_onion

3 years agoAdvertise keysend feature
Valentine Wallace [Fri, 14 May 2021 20:34:56 +0000 (16:34 -0400)]
Advertise keysend feature

C-Lightning requires us to advertise this feature before they'll
attempt a keysend payment to us.

3 years agoParse keysend TLV field in onion.
Valentine Wallace [Thu, 13 May 2021 19:38:31 +0000 (15:38 -0400)]
Parse keysend TLV field in onion.

This doesn't yet use the field, but it will be used in upcoming commits.

3 years agoMerge pull request #998 from TheBlueMatt/2021-07-fix-chan-reserve-msat-sat
Matt Corallo [Mon, 26 Jul 2021 16:03:22 +0000 (16:03 +0000)]
Merge pull request #998 from TheBlueMatt/2021-07-fix-chan-reserve-msat-sat

Fix channel reserve calculation on the sending side

3 years agoMerge pull request #986 from TheBlueMatt/2021-07-route-lasthop-value
Matt Corallo [Mon, 26 Jul 2021 16:02:41 +0000 (16:02 +0000)]
Merge pull request #986 from TheBlueMatt/2021-07-route-lasthop-value

[router] Use the invoice value for last-hop hint channel capacity

3 years agoMerge pull request #1008 from lightning-signer/2021-07-sync-no-std
Matt Corallo [Thu, 22 Jul 2021 14:17:09 +0000 (14:17 +0000)]
Merge pull request #1008 from lightning-signer/2021-07-sync-no-std

Dummy sync implementation for no_std

3 years agoMerge pull request #1010 from sr-gi/enforce_signature_length
Matt Corallo [Tue, 20 Jul 2021 23:25:40 +0000 (23:25 +0000)]
Merge pull request #1010 from sr-gi/enforce_signature_length

3 years agoTest no_std instead of just hashbrown
Devrandom [Mon, 19 Jul 2021 17:28:06 +0000 (19:28 +0200)]
Test no_std instead of just hashbrown

3 years agoImplement dummy Mutex, Condvar and RwLock
Devrandom [Mon, 19 Jul 2021 14:13:00 +0000 (16:13 +0200)]
Implement dummy Mutex, Condvar and RwLock