Matt Corallo [Mon, 30 Aug 2021 02:43:01 +0000 (02:43 +0000)]
Merge pull request #1039 from lightning-signer/2021-08-more-enforcement
Introduce EnforcementState, validate release of revocation secret
Devrandom [Fri, 20 Aug 2021 19:57:18 +0000 (21:57 +0200)]
Allow BaseSign validation functions to return an Err
Devrandom [Thu, 19 Aug 2021 07:51:45 +0000 (09:51 +0200)]
Improve documentation for validate_holder_commitment and sign_counterparty_commitment
Devrandom [Tue, 17 Aug 2021 11:04:29 +0000 (13:04 +0200)]
Always use KeysInterface.read_chan_signer for de-serializing EnforcingSigner in tests
Devrandom [Mon, 9 Aug 2021 14:48:06 +0000 (16:48 +0200)]
Enforce signing counterparty commitment only after revocation
Devrandom [Mon, 9 Aug 2021 10:09:39 +0000 (12:09 +0200)]
Enforce that revocation can only occur after we validated a new commitment
Devrandom [Mon, 9 Aug 2021 08:56:15 +0000 (10:56 +0200)]
Introduce EnforcementState for EnforcingSigner
as we add more enforcement state variables, we want to keep track of them under a single structure
Matt Corallo [Fri, 27 Aug 2021 02:37:00 +0000 (02:37 +0000)]
Merge pull request #1060 from JosephGoulden/function_test_utils_logs
tests: use origin node logger instead of creating new TestLogger
Matt Corallo [Wed, 25 Aug 2021 17:22:20 +0000 (17:22 +0000)]
Merge pull request #1031 from p2pderivatives/dlc-version-generic
Dlc version generic
Jeffrey Czyz [Wed, 18 Aug 2021 15:41:01 +0000 (10:41 -0500)]
Remove wire::MessageType in favor of u16
With custom messages, wire::Type was introduced. wire::MessageType is a
bit redundant, so use u16 instead and move is_even to wire::Message.
Tibo-lg [Thu, 5 Aug 2021 05:51:17 +0000 (14:51 +0900)]
Add custom message handler to peer manager
Matt Corallo [Tue, 24 Aug 2021 18:57:51 +0000 (18:57 +0000)]
Merge pull request #1037 from sr-gi/add-txid-convert
Adds Txid to lighting-block-sync::convert
Joseph Goulden [Tue, 24 Aug 2021 15:53:29 +0000 (16:53 +0100)]
tests: use origin node logger instead of creating new TestLogger in functional_test_utils
Sergi Delgado Segura [Fri, 6 Aug 2021 14:13:37 +0000 (16:13 +0200)]
Adds Txid to lighting-block-sync::convert
Matt Corallo [Fri, 20 Aug 2021 18:06:58 +0000 (18:06 +0000)]
Merge pull request #1051 from JosephGoulden/fix_ping_disconnect
fix: peer is disconnected for not responding to ping
Joseph Goulden [Fri, 20 Aug 2021 14:48:40 +0000 (15:48 +0100)]
test: increase ping timeout when running in debug mode
Matt Corallo [Wed, 18 Aug 2021 19:10:54 +0000 (19:10 +0000)]
Merge pull request #1049 from TheBlueMatt/2021-08-nightly-warnings
Fix trailing semicolon warnings on latest rustc nightly
Matt Corallo [Wed, 18 Aug 2021 00:33:56 +0000 (00:33 +0000)]
Fix trailing semicolon warnings on latest rustc nightly
Latest rustc nightly compiles are filled with warnings like the
following, which we fix here:
```
warning: trailing semicolon in macro used in expression position
--> lightning/src/util/macro_logger.rs:163:114
|
163 | $logger.log(&$crate::util::logger::Record::new($lvl, format_args!($($arg)+), module_path!(), file!(), line!()));
| ^
|
::: lightning/src/chain/chainmonitor.rs:165:9
|
165 | log_debug!(self.logger, "New best block {} at height {} provided via block_connected", header.block_hash(), height);
| -------------------------------------------------------------------------------------------------------------------- in this macro invocation
|
= note: `#[warn(semicolon_in_expressions_from_macros)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #79813 <https://github.com/rust-lang/rust/issues/79813>
= note: this warning originates in the macro `log_internal` (in Nightly builds, run with -Z macro-backtrace for more info)
```
Matt Corallo [Wed, 18 Aug 2021 00:31:28 +0000 (00:31 +0000)]
Merge pull request #1048 from TheBlueMatt/2021-08-no-net-print
Remove explicit print in lightning-net-tokio, reduce redundant block connection logging
Matt Corallo [Tue, 17 Aug 2021 19:47:50 +0000 (19:47 +0000)]
Clarify docs on ShutdownScript::new_witness_program somewhat
This is especially important for C or other language bindings
clients as the `version` field may be exported as a `u8`.
Matt Corallo [Tue, 17 Aug 2021 00:46:21 +0000 (00:46 +0000)]
Log chain calls in ChainMonitor, reducing logs in ChannelMonitor
For users with many ChannelMonitors, we log a large volume per
block simply because each ChannelMonitor lots several times per
block. Instead, we move to log only once at the TRACE level per
block call in ChannelMonitors, relying instead on a DEBUG level
log in ChainMonitor before we call any ChannelMonitor functions.
For most users, this will reduce redundant logging and also log at
the DEBUG level for block events, which is appropriate.
Fixes #980.
Matt Corallo [Tue, 17 Aug 2021 00:04:34 +0000 (00:04 +0000)]
Stop printing to stderr in lightning-net-tokio for disconnections
It isn't exactly a critical error situation when we disconnect a
socket, so we shouldn't be printing to stderr, entirely bypassing
user logging, when it happens. We do still print to stderr if we
fail to write the first message to the socket, but this should
never happen unless the user has a reasonably-configured system
with at least one packet in bytes available for the socket buffer.
Matt Corallo [Tue, 17 Aug 2021 00:03:31 +0000 (00:03 +0000)]
Ensure we always at least log at TRACE when a peer disconnects
Matt Corallo [Tue, 17 Aug 2021 18:55:26 +0000 (18:55 +0000)]
Merge pull request #1044 from TheBlueMatt/0.0.100
Cut 0.0.100
Matt Corallo [Sat, 14 Aug 2021 03:46:08 +0000 (03:46 +0000)]
Update versions to 0.0.100 and lightning-invoice to 0.8
Matt Corallo [Sat, 14 Aug 2021 03:42:51 +0000 (03:42 +0000)]
Update CHANGELOG for 0.0.100
Matt Corallo [Tue, 17 Aug 2021 17:53:21 +0000 (17:53 +0000)]
Merge pull request #1011 from TheBlueMatt/2021-07-new-closing-fee
Clean up existing and add range-based closing_signed negotiation
Matt Corallo [Fri, 13 Aug 2021 23:01:31 +0000 (23:01 +0000)]
Add relatively simple tests of the legacy and target closing fee
This doesn't exhaustively test closing fee negotiation at all, but
ensures that it is at least basically able to come to consensus and
sign cooperative closing transactions.
Matt Corallo [Fri, 13 Aug 2021 18:46:50 +0000 (18:46 +0000)]
Slightly clarify the closing_signed error msg on fee mismatch
Matt Corallo [Mon, 26 Jul 2021 22:50:49 +0000 (22:50 +0000)]
Add a test for shutdown negotiaion funder restart and timeout
Matt Corallo [Mon, 26 Jul 2021 20:43:05 +0000 (20:43 +0000)]
Force-close if finish closing_signed negotiation takes a full minute
Matt Corallo [Mon, 26 Jul 2021 18:59:03 +0000 (18:59 +0000)]
Move shutdown-related tests into a new module
Because ln::functional_tests if over 9000 LoC long, its useful to
move tests into new modules as we can. Here we move all
cooperative shutdown related tests into a new module entitled
`shutdown_tests`
Matt Corallo [Tue, 20 Jul 2021 03:19:01 +0000 (03:19 +0000)]
Clean up existing and add range-based closing_signed negotiation
This adds the new range-based closing_signed negotiation specified
in https://github.com/lightningnetwork/lightning-rfc/pull/847 as
well as cleans up the existing closing_signed negotiation to unify
the new codepaths and the old ones.
Note that because the new range-based closing_signed negotiation
allows the channel fundee to ultimately select the fee out of a
range specified by the funder, which we, of course, always select
the highest allowed amount from. Thus, we've added an extra round
of closing_signed in the common case as we will not simply accept
the first fee we see, always preferring to make the funder pay as
much as they're willing to.
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.
Matt Corallo [Mon, 16 Aug 2021 18:30:36 +0000 (18:30 +0000)]
Merge pull request #1045 from TheBlueMatt/2021-08-chanmon-ser-upgradability
Make `ChannelMonitor` serialization slightly more upgradable
Matt Corallo [Wed, 28 Jul 2021 20:24:20 +0000 (20:24 +0000)]
Migrate OnchainEvent serialization to be MaybeReadable.
This adds a new TLV-based enum serialization macro entitled
`impl_writeable_tlv_based_enum_upgradable`. As the name implies,
the new macro allows us to ignore odd-numbered variant entries.
Because the new macro implements only `MaybeReadable` and not
`Readable`, it is not applicable in many contexts, here only being
added for the two `OnchainEvent` structs.
Matt Corallo [Wed, 28 Jul 2021 20:18:10 +0000 (20:18 +0000)]
Implement `VecReadWrapper` for `MaybeReadable`
This makes it much simpler to deal with `MaybeReadable` types in
`Vec`s in TLVs as we can transparently deal with them as `vec`,
with the wrapper doing the Right Thing.
This requires we implement `MaybeReadable` for all `Readable` which
has some downstream implications, but nothing too bad.
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."
Matt Corallo [Tue, 6 Jul 2021 23:51:11 +0000 (23:51 +0000)]
Log shutdown including which side of the channel initiated shutdown
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
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.
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.
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
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
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.
Matt Corallo [Tue, 13 Jul 2021 16:07:01 +0000 (16:07 +0000)]
Log when we change HTLC state while sending a commitment transaction
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.
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.
Matt Corallo [Tue, 13 Jul 2021 02:23:41 +0000 (02:23 +0000)]
Add more logging during chanmon_consistency runs
Matt Corallo [Wed, 30 Jun 2021 03:09:04 +0000 (03:09 +0000)]
Add fuzz coverage of (potential) fee update messages
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.
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.
Matt Corallo [Sun, 4 Jul 2021 14:51:21 +0000 (14:51 +0000)]
Add standard derives for ConfirmationTarget
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`
Antoine Riard [Wed, 28 Jul 2021 23:59:11 +0000 (19:59 -0400)]
Add test_max_balance_dust_htlc
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.
Antoine Riard [Wed, 28 Jul 2021 23:54:20 +0000 (19:54 -0400)]
Modify pending inbound/outbound getters to access dust balances
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.
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
Matt Corallo [Tue, 10 Aug 2021 00:56:25 +0000 (00:56 +0000)]
Merge pull request #1038 from valentinewallace/2021-08-keysend-docs
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
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`
Jeffrey Czyz [Mon, 2 Aug 2021 03:31:07 +0000 (22:31 -0500)]
Add APIError::IncompatibleShutdownScript
Jeffrey Czyz [Sat, 31 Jul 2021 04:27:58 +0000 (23:27 -0500)]
Implement Display for ShutdownScript
Jeffrey Czyz [Sun, 1 Aug 2021 21:36:07 +0000 (16:36 -0500)]
Pass InitFeatures by reference to Channel
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.
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.
Jeffrey Czyz [Sat, 7 Aug 2021 06:02:11 +0000 (01:02 -0500)]
Add features to NodeCfg and use in create_network
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.
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.
Jeffrey Czyz [Wed, 28 Jul 2021 19:04:10 +0000 (14:04 -0500)]
Use ShutdownScript to check scripts from peers
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.
Jeffrey Czyz [Thu, 29 Jul 2021 17:41:03 +0000 (12:41 -0500)]
Clean up and add shutdown script functional tests
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
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.
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.
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.
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.
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.
Valentine Wallace [Fri, 6 Aug 2021 22:17:58 +0000 (18:17 -0400)]
Update keysend docs
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
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.
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.
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.
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
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`.
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>
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
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.
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
Devrandom [Tue, 3 Aug 2021 07:38:44 +0000 (09:38 +0200)]
Rename no_std feature to no-std
matches rust-bitcoin
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
Devrandom [Sun, 1 Aug 2021 16:22:06 +0000 (18:22 +0200)]
Actual no_std support
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.
Matt Corallo [Mon, 2 Aug 2021 16:28:14 +0000 (16:28 +0000)]
Merge pull request #1032 from jkczyz/2021-08-clippy
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
Jeffrey Czyz [Mon, 2 Aug 2021 14:29:49 +0000 (09:29 -0500)]
Fix #[warn(clippy::try_err)] in ser_macros.rs
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.
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
Matt Corallo [Thu, 22 Jul 2021 15:18:22 +0000 (15:18 +0000)]
Add a `#[macro_use]` on the `alloc` import for `format!()`