]> git.bitcoin.ninja Git - rust-lightning/log
rust-lightning
3 years agoAdd ChannelClosed generation at cooperative/force-close/error processing
Antoine Riard [Tue, 13 Jul 2021 16:56:40 +0000 (12:56 -0400)]
Add ChannelClosed generation at cooperative/force-close/error processing

When we detect a channel `is_shutdown()` or call on it
`force_shutdown()`, we notify the user with a Event::ChannelClosed
informing about the id and closure reason in a best effort.

3 years agoExtend MsgHandleErrInternal with a new chan_id field Option<[u8; 32]>
Antoine Riard [Tue, 13 Jul 2021 16:55:32 +0000 (12:55 -0400)]
Extend MsgHandleErrInternal with a new chan_id field Option<[u8; 32]>

This field is used in next commit to generate appropriate
ChannelClosed event at `handle_error()` processing.

3 years agoAdd Event::ChannelClosed generation at channel shutdown
Antoine Riard [Tue, 13 Jul 2021 17:04:54 +0000 (13:04 -0400)]
Add Event::ChannelClosed generation at channel shutdown

3 years agoMerge pull request #1053 from valentinewallace/2021-08-dedup-payment-sent
Matt Corallo [Fri, 17 Sep 2021 20:59:29 +0000 (20:59 +0000)]
Merge pull request #1053 from valentinewallace/2021-08-dedup-payment-sent

Deduplicate PaymentSent events for MPP payments

3 years agoAdd all_paths_failed field to PaymentFailed
Valentine Wallace [Fri, 17 Sep 2021 01:09:46 +0000 (21:09 -0400)]
Add all_paths_failed field to PaymentFailed

see field docs for details

3 years agoPrevent duplicate PaymentSent events
Valentine Wallace [Fri, 20 Aug 2021 00:44:45 +0000 (20:44 -0400)]
Prevent duplicate PaymentSent events

by removing all pending outbound payments associated with the same
MPP payment after the preimage is received

3 years agoAdd MPP ID to pending_outbound_htlcs
Valentine Wallace [Thu, 19 Aug 2021 23:56:53 +0000 (19:56 -0400)]
Add MPP ID to pending_outbound_htlcs

We'll use this to correlate MPP shards in upcoming commits

3 years agoImplement Readable/Writeable for HashSet
Valentine Wallace [Mon, 13 Sep 2021 00:46:11 +0000 (20:46 -0400)]
Implement Readable/Writeable for HashSet

To be used in upcoming commits for MPP ID storage

3 years agoAdd MppId field to HTLCSource as a way to correlate mpp payment paths
Valentine Wallace [Thu, 19 Aug 2021 20:45:55 +0000 (16:45 -0400)]
Add MppId field to HTLCSource as a way to correlate mpp payment paths

3 years agotest utils: refactor fail_payment_along_route for mpp
Valentine Wallace [Wed, 1 Sep 2021 21:30:11 +0000 (17:30 -0400)]
test utils: refactor fail_payment_along_route for mpp

3 years agoMerge pull request #1070 from TheBlueMatt/2021-09-fix-bindings-ignore
Matt Corallo [Fri, 17 Sep 2021 17:26:54 +0000 (17:26 +0000)]
Merge pull request #1070 from TheBlueMatt/2021-09-fix-bindings-ignore

Move CounterpartyForwardingInfo from channel to channelmanager

3 years agoMerge pull request #1066 from valentinewallace/2021-08-fix-double-temp-failure
Matt Corallo [Wed, 15 Sep 2021 20:51:37 +0000 (20:51 +0000)]
Merge pull request #1066 from valentinewallace/2021-08-fix-double-temp-failure

Allow multiple calls to `monitor_update_failed`

3 years agoAllow multiple monitor_update_failed calls
Valentine Wallace [Fri, 3 Sep 2021 21:24:01 +0000 (17:24 -0400)]
Allow multiple monitor_update_failed calls

without requiring calls to channel_monitor_updated in between.

Found by the fuzzer

3 years agoUpdate fuzz README with latest instructions
Valentine Wallace [Thu, 26 Aug 2021 19:03:09 +0000 (15:03 -0400)]
Update fuzz README with latest instructions

3 years agoMerge pull request #1074 from p2pderivatives/add-node-id-to-custom-msg-cb
Matt Corallo [Wed, 15 Sep 2021 18:54:15 +0000 (18:54 +0000)]
Merge pull request #1074 from p2pderivatives/add-node-id-to-custom-msg-cb

Add node id to custom message callback

3 years agoMerge pull request #1034 from TheBlueMatt/2021-07-maturing-claims
Matt Corallo [Wed, 15 Sep 2021 18:44:04 +0000 (18:44 +0000)]
Merge pull request #1034 from TheBlueMatt/2021-07-maturing-claims

Expose in-flight claim balances

3 years agoMerge pull request #1043 from jkczyz/2021-07-network-update-handler
Matt Corallo [Wed, 15 Sep 2021 18:13:20 +0000 (18:13 +0000)]
Merge pull request #1043 from jkczyz/2021-07-network-update-handler

Handle network updates from failed payments in BackgroundProcessor

3 years agoExpand `ANTI_REORG_DELAY` docs to say its a library-wide assumption 2021-07-maturing-claims
Matt Corallo [Sun, 29 Aug 2021 19:01:05 +0000 (19:01 +0000)]
Expand `ANTI_REORG_DELAY` docs to say its a library-wide assumption

3 years agoAdd an accessor to `ChainMonitor` to get the claimable balances
Matt Corallo [Wed, 25 Aug 2021 20:13:01 +0000 (20:13 +0000)]
Add an accessor to `ChainMonitor` to get the claimable balances

The common user desire is to get the set of claimable balances for
all non-closed channels. In order to do so, they really want to
just ask their `ChainMonitor` for the set of balances, which they
can do here by passing the `ChannelManager::list_channels` output
to `ChainMonitor::get_claimable_balances`.

3 years agoExpose the amount of funds available for claim in ChannelMonitor
Matt Corallo [Wed, 4 Aug 2021 16:10:38 +0000 (16:10 +0000)]
Expose the amount of funds available for claim in ChannelMonitor

In general, we should always allow users to query for how much is
currently in-flight being claimed on-chain at any time.

This does so by examining the confirmed claims on-chain and
breaking down what is left to be claimed into a new
`ClaimableBalance` enum.

Fixes #995.

3 years agoFix indentation in ChannelMonitor
Matt Corallo [Wed, 25 Aug 2021 19:36:43 +0000 (19:36 +0000)]
Fix indentation in ChannelMonitor

3 years agoTrack how our HTLCs are resolved on-chain persistently
Matt Corallo [Wed, 4 Aug 2021 15:16:43 +0000 (15:16 +0000)]
Track how our HTLCs are resolved on-chain persistently

This tracks how any HTLC outputs in broadcast commitment
transactions are resolved on-chain, storing the result of the HTLC
resolution persistently in the ChannelMonitor.

This can be used to determine which outputs may still be available
for claiming on-chain.

3 years agoTrack the tx which spends our funding output in ChannelMonitor
Matt Corallo [Wed, 4 Aug 2021 15:14:56 +0000 (15:14 +0000)]
Track the tx which spends our funding output in ChannelMonitor

This allows us to easily look up how our channel was closed and
track which balances may be spendable on-chain.

3 years agoRename CounterpartyCommitmentTransaction to Params as it is static
Matt Corallo [Tue, 27 Jul 2021 19:30:27 +0000 (19:30 +0000)]
Rename CounterpartyCommitmentTransaction to Params as it is static

3 years agoDrop unused CounterpartyCommitmentTransaction::per_htlc HashMap
Matt Corallo [Tue, 27 Jul 2021 19:27:43 +0000 (19:27 +0000)]
Drop unused CounterpartyCommitmentTransaction::per_htlc HashMap

3 years agoStore to-self value in the current commitment tx in ChannelMonitor
Matt Corallo [Tue, 27 Jul 2021 15:52:21 +0000 (15:52 +0000)]
Store to-self value in the current commitment tx in ChannelMonitor

3 years agoUpdate NetworkGraph in BackgroundProcessor
Jeffrey Czyz [Wed, 15 Sep 2021 02:38:00 +0000 (21:38 -0500)]
Update NetworkGraph in BackgroundProcessor

Decorate the user-supplied EventHandler with NetGraphMsgHandler in
the BackgroundProcessor. The resulting handler will intercept
PaymentFailed events in order to update the NetworkGraph in the
background before delegating to the user's event handler.

3 years agoExpand and format BackgroundProcessor docs
Jeffrey Czyz [Thu, 19 Aug 2021 16:21:42 +0000 (11:21 -0500)]
Expand and format BackgroundProcessor docs

3 years agoEventHandler for applying NetworkUpdate
Jeffrey Czyz [Thu, 12 Aug 2021 21:02:42 +0000 (16:02 -0500)]
EventHandler for applying NetworkUpdate

PaymentFailed events contain an optional NetworkUpdate describing
changes to the NetworkGraph as conveyed by a node along a failed payment
path according to BOLT 4. An EventHandler should apply the update to the
graph so that future routing decisions can account for it.

Implement EventHandler for NetGraphMsgHandler to update NetworkGraph.
Previously, NetGraphMsgHandler::handle_htlc_fail_channel_update
implemented this behavior.

3 years agoRefactor PaymentFailureNetworkUpdate event
Jeffrey Czyz [Thu, 12 Aug 2021 20:30:53 +0000 (15:30 -0500)]
Refactor PaymentFailureNetworkUpdate event

MessageSendEvent::PaymentFailureNetworkUpdate served as a hack to pass
an HTLCFailChannelUpdate from ChannelManager to NetGraphMsgHandler via
PeerManager. Instead, remove the event entirely and move the contained
data (renamed NetworkUpdate) to Event::PaymentFailed to be processed by
an event handler.

3 years agoAdd node id to custom message callback
Tibo-lg [Tue, 14 Sep 2021 06:40:10 +0000 (15:40 +0900)]
Add node id to custom message callback

3 years agoMove CounterpartyForwardingInfo from channel to channelmanager 2021-09-fix-bindings-ignore
Matt Corallo [Mon, 6 Sep 2021 03:25:27 +0000 (03:25 +0000)]
Move CounterpartyForwardingInfo from channel to channelmanager

CounterpartyForwardingInfo is public (previously exposed with a
`pub use`), and used inside of ChannelCounterparty in
channelmanager.rs. However, it is defined in channel.rs, away from
where it is used.

This would be fine, except that the bindings generator is somewhat
confused by this - it doesn't currently support interpreting
`pub use` as a struct to expose, instead ignoring it.

Fixes https://github.com/lightningdevkit/ldk-garbagecollected/issues/44

3 years agoMerge pull request #1072 from TheBlueMatt/2021-09-tighter-max_fee-constant
Matt Corallo [Mon, 13 Sep 2021 16:42:36 +0000 (16:42 +0000)]
Merge pull request #1072 from TheBlueMatt/2021-09-tighter-max_fee-constant

Reduce our stated max closing-transaction fee to be the true value

3 years agoMerge pull request #1073 from gilescope/less-deps
Matt Corallo [Mon, 13 Sep 2021 04:22:26 +0000 (04:22 +0000)]
Merge pull request #1073 from gilescope/less-deps

3 years agoNot needed now. We refer to std::futures.
Giles Cope [Sat, 11 Sep 2021 19:11:10 +0000 (20:11 +0100)]
Not needed now. We refer to std::futures.

3 years agoFail with PERM|8 (permanent_channel_failure)
Jeffrey Czyz [Wed, 25 Aug 2021 01:24:23 +0000 (20:24 -0500)]
Fail with PERM|8 (permanent_channel_failure)

This affects the htlc_fail_async_shutdown test.

3 years agoRemove test_invalid_channel_announcement
Jeffrey Czyz [Wed, 25 Aug 2021 00:41:35 +0000 (19:41 -0500)]
Remove test_invalid_channel_announcement

It doesn't seem to be testing anything useful that isn't covered
elsewhere.

3 years agoAdd a read-only view of NetworkGraph
Jeffrey Czyz [Mon, 16 Aug 2021 23:40:19 +0000 (18:40 -0500)]
Add a read-only view of NetworkGraph

Hide the internal locking of NetworkGraph by providing a read-only
view. This way the locking order is handled internally.

3 years agoRemove RwLock from around NetworkGraph
Jeffrey Czyz [Tue, 10 Aug 2021 14:47:27 +0000 (09:47 -0500)]
Remove RwLock from around NetworkGraph

Now that NetworkGraph uses interior mutability, the RwLock used around
it in NetGraphMsgHandler is no longer needed. This allows for shared
ownership without a lock.

3 years agoIndividually lock NetworkGraph fields
Jeffrey Czyz [Tue, 10 Aug 2021 03:24:41 +0000 (22:24 -0500)]
Individually lock NetworkGraph fields

In preparation for giving NetworkGraph shared ownership, wrap individual
fields in RwLock. This allows removing the outer RwLock used in
NetGraphMsgHandler.

3 years agoPass Event by reference to EventHandler
Jeffrey Czyz [Tue, 17 Aug 2021 16:12:18 +0000 (11:12 -0500)]
Pass Event by reference to EventHandler

Passing an Event by reference rather and by move gives more flexibility
for composing event handlers without needing to clone events.

3 years agoReduce our stated max closing-transaction fee to be the true value 2021-09-tighter-max_fee-constant
Matt Corallo [Thu, 9 Sep 2021 01:09:41 +0000 (01:09 +0000)]
Reduce our stated max closing-transaction fee to be the true value

When communicating the maximum fee we're willing to accept on a
cooperative closing transaction to our peer, we currently tell them
we'll accept `u64::max_value()` if they're the ones who have to pay
it. Spec-wise this is fine - they aren't allowed to try to claim
our balance, and we don't care how much of their own funds they
want to spend on transaction fees.

However, the Eclair folks prefer to check all values on the wire
do not exceed 21 million BTC, which seems like generally good
practice to avoid overflows and such issues. Thus, our close
messages are rejected by Eclair.

Here we simply relax our stated maximum to be the real value - our
counterparty's current balance in satoshis.

Fixes #1071

3 years agoMerge pull request #1064 from lightning-signer/2021-08-closing-tx-phase2
Matt Corallo [Thu, 9 Sep 2021 19:31:47 +0000 (19:31 +0000)]
Merge pull request #1064 from lightning-signer/2021-08-closing-tx-phase2

3 years agoUse ClosingTransaction in BaseSign
Devrandom [Wed, 1 Sep 2021 12:56:50 +0000 (14:56 +0200)]
Use ClosingTransaction in BaseSign

3 years agoIntroduce ClosingTransaction
Devrandom [Wed, 1 Sep 2021 12:38:01 +0000 (14:38 +0200)]
Introduce ClosingTransaction

3 years agoMerge pull request #1047 from TheBlueMatt/2021-08-985-followups
Matt Corallo [Thu, 9 Sep 2021 09:23:08 +0000 (09:23 +0000)]
Merge pull request #1047 from TheBlueMatt/2021-08-985-followups

3 years agoAdd further comments around fee update handling in channel 2021-08-985-followups
Matt Corallo [Mon, 16 Aug 2021 18:02:59 +0000 (18:02 +0000)]
Add further comments around fee update handling in channel

These were suggested to clarify behavior in post-merge review of #985.

3 years agoUpdate docs for pending_update_fee and holding_cell_update_fee
Matt Corallo [Mon, 16 Aug 2021 17:47:36 +0000 (17:47 +0000)]
Update docs for pending_update_fee and holding_cell_update_fee

The docs were left stale after the logic was updated in #985 as
pointed out in post-merge review.

3 years agoFactor out low-level build_closing_transaction
Devrandom [Tue, 31 Aug 2021 13:23:48 +0000 (15:23 +0200)]
Factor out low-level build_closing_transaction

3 years agoMerge pull request #1055 from lightning-signer/2021-08-anchor-tx
Matt Corallo [Thu, 2 Sep 2021 21:54:11 +0000 (21:54 +0000)]
Merge pull request #1055 from lightning-signer/2021-08-anchor-tx

3 years agoAdd anchor outputs pair in CommitmentTransaction
Devrandom [Sun, 22 Aug 2021 09:08:28 +0000 (11:08 +0200)]
Add anchor outputs pair in CommitmentTransaction

The anchor ouputs pair is added if there are pending HTLCs. Or a
a per-party anchor is added if the party has a pending balance.

3 years agoMerge pull request #1057 from TheBlueMatt/2021-08-invoice-fails
Matt Corallo [Tue, 31 Aug 2021 22:11:22 +0000 (22:11 +0000)]
Merge pull request #1057 from TheBlueMatt/2021-08-invoice-fails

Fix and modernize lightning-invoice API

3 years agoRequire payment secrets when building and reading invoices 2021-08-invoice-fails
Matt Corallo [Fri, 27 Aug 2021 02:21:32 +0000 (02:21 +0000)]
Require payment secrets when building and reading invoices

3 years agoUse new BOLT 11 test vectors with payment_secrets and feature flags
Matt Corallo [Tue, 24 Aug 2021 23:22:55 +0000 (23:22 +0000)]
Use new BOLT 11 test vectors with payment_secrets and feature flags

This pulls the BOLT 11 test vectors from
https://github.com/lightningnetwork/lightning-rfc/pull/898,
tweaking our tests to properly handle them.

3 years ago[invoice] Ignore InvalidLength fields
Matt Corallo [Tue, 24 Aug 2021 23:15:07 +0000 (23:15 +0000)]
[invoice] Ignore InvalidLength fields

BOLT 11 states that a reader "MUST skip over...`p`, `h`, `s` or `n`
fields that do NOT have data_lengths of 52, 52, 52 or 53,
respectively." Here we do so by simply ignoring any invalid-length
field.

3 years agoImplement core::hash::Hash more incl invoice::RawTaggedField
Matt Corallo [Tue, 24 Aug 2021 21:00:17 +0000 (21:00 +0000)]
Implement core::hash::Hash more incl invoice::RawTaggedField

3 years agoCheck if invoices contain unknown required features
Matt Corallo [Sun, 22 Aug 2021 19:54:08 +0000 (19:54 +0000)]
Check if invoices contain unknown required features

This adds the final missing BOLT 11 failure test, checking for
unknown required feature flags before accepting an invoice.

3 years agoConvert the invoice creation API to millisats and req it for parse
Matt Corallo [Sun, 22 Aug 2021 19:42:29 +0000 (19:42 +0000)]
Convert the invoice creation API to millisats and req it for parse

The BOLT 11 invalid invoice test vectors suggest failing to parse
invoices which have an amount which is not a whole number of
millisatoshis. lightning-invoice, however, happily parses such
invoices. While we could continue to parse them, failing them makes
for one less check on the user code side, so we might as well.

In order to keep the invoice creation less likely to fail, we also
switch the Builder amount-setting function to use millisatoshis.

3 years ago[invoice] Fix non-recoverable sig handling and bogus SI prefix err
Matt Corallo [Sun, 22 Aug 2021 19:36:01 +0000 (19:36 +0000)]
[invoice] Fix non-recoverable sig handling and bogus SI prefix err

This adds two additional tests from the BOLT 11 invalid invoice
tests, fixing the two errors that broke them. It fixes a panic on
the "nonrecoverable signature" test and makes the error variant
more sensible on the bogus SI prefix test.

3 years ago[invoice] Add the BOLT 11 failure unit tests that we already pass
Matt Corallo [Sun, 22 Aug 2021 19:35:15 +0000 (19:35 +0000)]
[invoice] Add the BOLT 11 failure unit tests that we already pass

3 years agoMerge pull request #1040 from abhik-99/Issue#945
Matt Corallo [Tue, 31 Aug 2021 17:50:14 +0000 (17:50 +0000)]
Merge pull request #1040 from abhik-99/Issue#945

Multi-Hop Route Hint now considered. Added in unit tests for same.

3 years agoMulti-Hop Route Hint as per Bolt 12 now considered
abhik-99 [Mon, 9 Aug 2021 15:06:51 +0000 (20:36 +0530)]
Multi-Hop Route Hint as per Bolt 12 now considered

Bolt 12 details the process of picking up route hints from payee
using the lightning invoice. This PR brings the changes to use
multiple route hints from payee picked from the invoice.

The route hints are processed in the following manner:-
 - `get_route()` receives the hints in `last_hops`.
 - Every `RouteHintHop` in `RouteHint` is processed based on
   feasiblity of channel capacity and fees.
 - If a `RouteHintHop` then preceeding `RouteHintHop`s are not
   processed.
 - A direct route is checked from `first_hops_targets` to the
   first `RouteHintHop` if the respective `RouteHint` is
   processed from the payee's end till the first `RouteHintHop`.

`partial_route_hint_test`, `ignores_empty_last_hops_test`,
`multi_hint_last_hops_test` and `last_hops_with_public_channel_test`
test usage of partial route hints for building optimal route,
processing empty route hint hops, complete usage of private route
hints and presence of public channels in route hints respectively.

Resolves: #945

3 years agoMerge pull request #1039 from lightning-signer/2021-08-more-enforcement
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

3 years agoAdd get_anchor_script
Antoine Riard [Tue, 26 May 2020 07:55:03 +0000 (09:55 +0200)]
Add get_anchor_script

This is a script builder to generate anchor output ones. They can be
satisfied either by a signature for the committed funding pubkey or anyone
after CSV delay expiration.

This is used at anchor output addition while generating commitment transaction.

3 years agoAllow BaseSign validation functions to return an Err
Devrandom [Fri, 20 Aug 2021 19:57:18 +0000 (21:57 +0200)]
Allow BaseSign validation functions to return an Err

3 years agoImprove documentation for validate_holder_commitment and sign_counterparty_commitment
Devrandom [Thu, 19 Aug 2021 07:51:45 +0000 (09:51 +0200)]
Improve documentation for validate_holder_commitment and sign_counterparty_commitment

3 years agoAlways use KeysInterface.read_chan_signer for de-serializing EnforcingSigner in tests
Devrandom [Tue, 17 Aug 2021 11:04:29 +0000 (13:04 +0200)]
Always use KeysInterface.read_chan_signer for de-serializing EnforcingSigner in tests

3 years agoEnforce signing counterparty commitment only after revocation
Devrandom [Mon, 9 Aug 2021 14:48:06 +0000 (16:48 +0200)]
Enforce signing counterparty commitment only after revocation

3 years agoEnforce that revocation can only occur after we validated a new commitment
Devrandom [Mon, 9 Aug 2021 10:09:39 +0000 (12:09 +0200)]
Enforce that revocation can only occur after we validated a new commitment

3 years agoIntroduce EnforcementState for EnforcingSigner
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

3 years agoMerge pull request #1060 from JosephGoulden/function_test_utils_logs
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

3 years agoRemove DynamicOutputP2WPKH ref in logger
Antoine Riard [Tue, 3 Aug 2021 23:20:06 +0000 (19:20 -0400)]
Remove DynamicOutputP2WPKH ref in logger

3 years agoMerge pull request #1031 from p2pderivatives/dlc-version-generic
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

3 years agoRemove wire::MessageType in favor of u16
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.

3 years agoAdd custom message handler to peer manager
Tibo-lg [Thu, 5 Aug 2021 05:51:17 +0000 (14:51 +0900)]
Add custom message handler to peer manager

3 years agoMerge pull request #1037 from sr-gi/add-txid-convert
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

3 years agoDon't initialise Vecs being read with VecReadWrapper explicitly
Matt Corallo [Sun, 1 Aug 2021 02:34:08 +0000 (02:34 +0000)]
Don't initialise Vecs being read with VecReadWrapper explicitly

This simplifies the tlv serialization read macro somewhat by
allowing callsites to simply read into an `Option<Vec>` instead of
needing to read into an `Option<VecReadWrapper>` when using
`vec_type`.

3 years agotests: use origin node logger instead of creating new TestLogger in functional_test_utils
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

3 years agoAdds Txid to lighting-block-sync::convert
Sergi Delgado Segura [Fri, 6 Aug 2021 14:13:37 +0000 (16:13 +0200)]
Adds Txid to lighting-block-sync::convert

3 years ago[invoice] Update doctest example invoices to real LDK invoices
Matt Corallo [Sun, 22 Aug 2021 22:11:34 +0000 (22:11 +0000)]
[invoice] Update doctest example invoices to real LDK invoices

This swaps out our doctest example invoices for real LDK-generated
invoices on a real LDK node.

3 years agoMerge pull request #1051 from JosephGoulden/fix_ping_disconnect
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

3 years agotest: increase ping timeout when running in debug mode
Joseph Goulden [Fri, 20 Aug 2021 14:48:40 +0000 (15:48 +0100)]
test: increase ping timeout when running in debug mode

3 years agoMerge pull request #1049 from TheBlueMatt/2021-08-nightly-warnings
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

3 years agoFix trailing semicolon warnings on latest rustc nightly 2021-08-nightly-warnings
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)
```

3 years agoMerge pull request #1048 from TheBlueMatt/2021-08-no-net-print
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

3 years agoClarify docs on ShutdownScript::new_witness_program somewhat 2021-08-no-net-print
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`.

3 years agoLog chain calls in ChainMonitor, reducing logs in ChannelMonitor
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.

3 years agoStop printing to stderr in lightning-net-tokio for disconnections
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.

3 years agoEnsure we always at least log at TRACE when a peer disconnects
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

3 years agoMerge pull request #1044 from TheBlueMatt/0.0.100 v0.0.100
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

3 years agoUpdate versions to 0.0.100 and lightning-invoice to 0.8 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

3 years agoUpdate CHANGELOG for 0.0.100
Matt Corallo [Sat, 14 Aug 2021 03:42:51 +0000 (03:42 +0000)]
Update CHANGELOG for 0.0.100

3 years agoMerge pull request #1011 from TheBlueMatt/2021-07-new-closing-fee
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

3 years agoAdd relatively simple tests of the legacy and target closing fee 2021-07-new-closing-fee
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.

3 years agoSlightly clarify the closing_signed error msg on fee mismatch
Matt Corallo [Fri, 13 Aug 2021 18:46:50 +0000 (18:46 +0000)]
Slightly clarify the closing_signed error msg on fee mismatch

3 years agoAdd a test for shutdown negotiaion funder restart and timeout
Matt Corallo [Mon, 26 Jul 2021 22:50:49 +0000 (22:50 +0000)]
Add a test for shutdown negotiaion funder restart and timeout

3 years agoForce-close if finish closing_signed negotiation takes a full minute
Matt Corallo [Mon, 26 Jul 2021 20:43:05 +0000 (20:43 +0000)]
Force-close if finish closing_signed negotiation takes a full minute

3 years agoMove shutdown-related tests into a new module
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`

3 years agoClean up existing and add range-based closing_signed negotiation
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.

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.