]> git.bitcoin.ninja Git - rust-lightning/log
rust-lightning
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 #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

3 years agoEnforces sig_rec length in message_signing
Sergi Delgado Segura [Tue, 20 Jul 2021 09:05:47 +0000 (11:05 +0200)]
Enforces sig_rec length in message_signing

3 years agoCollect all lightning std::sync imports under crate::sync
Devrandom [Mon, 19 Jul 2021 13:01:58 +0000 (15:01 +0200)]
Collect all lightning std::sync imports under crate::sync

in preparation for no-std sync dummies

3 years agoStop BackgroundProcessor's thread on drop
Jeffrey Czyz [Sun, 18 Jul 2021 18:11:01 +0000 (13:11 -0500)]
Stop BackgroundProcessor's thread on drop

Without stopping the thread when BackgroundProcessor is dropped, it will
run free. In the context of language bindings, it is difficult to know
how long references held by the thread should live. Implement Drop to
stop the thread just as is done when explicitly calling stop().

3 years agoCorrectly assert BackgroundProcessor error
Jeffrey Czyz [Sun, 18 Jul 2021 17:59:27 +0000 (12:59 -0500)]
Correctly assert BackgroundProcessor error

The specific error from the ChannelManager persister is not asserted for
in test_persist_error. Rather, any error will do. Update the test to use
BackgroundProcessor::stop and assert for the expected value.

3 years agoMerge pull request #1003 from jkczyz/2021-known-features-mask
Matt Corallo [Thu, 15 Jul 2021 20:14:35 +0000 (20:14 +0000)]
Merge pull request #1003 from jkczyz/2021-known-features-mask

Expand tests for Features::to_context

3 years agoMerge pull request #1002 from valentinewallace/2021-07-fix-features-index-bounds
Matt Corallo [Thu, 15 Jul 2021 12:59:45 +0000 (12:59 +0000)]
Merge pull request #1002 from valentinewallace/2021-07-fix-features-index-bounds

3 years agoTest index-out-of-bounds in Features::to_context
Jeffrey Czyz [Wed, 14 Jul 2021 23:18:33 +0000 (16:18 -0700)]
Test index-out-of-bounds in Features::to_context

When there are fewer known `from` feature bytes than known `to` feature
bytes, an index-out-of-bounds error can occur if the `from` features
have unknown features set in a byte past the greatest known `from`
feature byte.

3 years agoRemove unnecessary feature test-only methods
Jeffrey Czyz [Wed, 14 Jul 2021 23:15:00 +0000 (16:15 -0700)]
Remove unnecessary feature test-only methods

3 years agoFix crash due to index-out-of-bounds in feature translation
Valentine Wallace [Wed, 14 Jul 2021 20:23:38 +0000 (16:23 -0400)]
Fix crash due to index-out-of-bounds in feature translation

This was reported by a user when trying to send a payment using the LDK
sample (specifically during route generation when translating a Features
from one context to another)

The problem was we didn't check T::KNOWN_FEATURE_MASK vec length before
indexing into it, due likely to the assumption that known feature vec
lengths are the same across contexts, when they may not be

3 years agoSupport pending update_fail_htlcs in reconnect_nodes test util
Matt Corallo [Wed, 14 Jul 2021 18:19:45 +0000 (18:19 +0000)]
Support pending update_fail_htlcs in reconnect_nodes test util

3 years agoFix channel reserve calculation on the sending side 2021-07-fix-chan-reserve-msat-sat
Matt Corallo [Sun, 4 Jul 2021 14:46:17 +0000 (14:46 +0000)]
Fix channel reserve calculation on the sending side

As the variable name implies holder_selected_chan_reserve_msat is
intended to be in millisatoshis, but is instead calculated in
satoshis.

We fix that error here and update the relevant tests to more
accurately calculate the expected reserve value and test both
success and failure cases.

Bug discovered by chanmon_consistency fuzz target.

3 years agoMerge pull request #990 from TheBlueMatt/2021-07-0.0.99 v0.0.99
Matt Corallo [Fri, 9 Jul 2021 17:29:38 +0000 (17:29 +0000)]
Merge pull request #990 from TheBlueMatt/2021-07-0.0.99

Cut 0.0.99

3 years agoBump most crate versions to 0.0.99 and lightning-invoice to 0.7.0 2021-07-0.0.99
Matt Corallo [Fri, 9 Jul 2021 14:03:46 +0000 (14:03 +0000)]
Bump most crate versions to 0.0.99 and lightning-invoice to 0.7.0

3 years agoAdd documentation for all PRs slated to land for 0.0.99
Matt Corallo [Thu, 8 Jul 2021 19:18:49 +0000 (19:18 +0000)]
Add documentation for all PRs slated to land for 0.0.99

3 years agoMerge pull request #975 from TheBlueMatt/2021-06-fix-fee-calc
Matt Corallo [Fri, 9 Jul 2021 02:11:57 +0000 (02:11 +0000)]
Merge pull request #975 from TheBlueMatt/2021-06-fix-fee-calc

Make the base fee configurable in ChannelConfig

3 years agoChange serialization backwards compat in Channel to use new version 2021-06-fix-fee-calc
Matt Corallo [Tue, 6 Jul 2021 00:27:35 +0000 (00:27 +0000)]
Change serialization backwards compat in Channel to use new version

Instead of interpreting the backwards compatibility data in Channel
serialization, use the serialization version bump present in 0.0.99
as the flag to indicate if a channel should be read in backwards
compatibility.

3 years agoAdd a note clarifying the API guarantees of create_channel
Matt Corallo [Sat, 26 Jun 2021 16:21:34 +0000 (16:21 +0000)]
Add a note clarifying the API guarantees of create_channel

3 years agoOptionally reject HTLC forwards over priv chans with a new config
Matt Corallo [Sat, 26 Jun 2021 14:15:30 +0000 (14:15 +0000)]
Optionally reject HTLC forwards over priv chans with a new config

Private nodes should never wish to forward HTLCs at all, which we
support here by disabling forwards out over private channels by
default. As private nodes should not have any public channels, this
suffices, without allowing users to disable forwarding over
channels announced in the routing graph already.

Closes #969

3 years agoUpdate full_stack_target demo input to match new, fewer, fee gets
Matt Corallo [Sat, 3 Jul 2021 01:13:14 +0000 (01:13 +0000)]
Update full_stack_target demo input to match new, fewer, fee gets

3 years agoMake the base fee configurable in ChannelConfig
Matt Corallo [Mon, 21 Jun 2021 20:20:29 +0000 (20:20 +0000)]
Make the base fee configurable in ChannelConfig

Currently the base fee we apply is always the expected cost to
claim an HTLC on-chain in case of closure. This results in
significantly higher than market rate fees [1], and doesn't really
match the actual forwarding trust model anyway - as long as
channel counterparties are honest, our HTLCs shouldn't end up
on-chain no matter what the HTLC sender/recipient do.

While some users may wish to use a feerate that implies they will
not lose funds even if they go to chain (assuming no flood-and-loot
style attacks), they should do so by calculating fees themselves;
since they're already charging well above market-rate,
over-estimating some won't have a large impact.

Worse, we current re-calculate fees at forward-time, not based on
the fee we set in the channel_update. This means that the fees
others expect to pay us (and which they calculate their route based
on), is not what we actually want to charge, and that any attempt
to forward through us is inherently race-y.

This commit adds a configuration knob to set the base fee
explicitly, defaulting to 1 sat, which appears to be market-rate
today.

[1] Note that due to an msat-vs-sat bug we currently actually
    charge 1000x *less* than the calculated cost.

3 years agoUpdate ChannelConfig serialization to be TLV-based
Matt Corallo [Mon, 21 Jun 2021 19:55:45 +0000 (19:55 +0000)]
Update ChannelConfig serialization to be TLV-based

This was missed prior to 0.0.98, so requires a
backwards-compatibility wrapper inside the `Channel` serialization
logic, but it's not very complicated to do so.

3 years agoMerge pull request #988 from TheBlueMatt/2021-07-chan-details-usability
Matt Corallo [Thu, 8 Jul 2021 17:25:53 +0000 (17:25 +0000)]
Merge pull request #988 from TheBlueMatt/2021-07-chan-details-usability

Improve ChannelDetails readability significantly.

3 years agoImprove ChannelDetails readability significantly. 2021-07-chan-details-usability
Matt Corallo [Tue, 6 Jul 2021 23:41:27 +0000 (23:41 +0000)]
Improve ChannelDetails readability significantly.

After the merge of #984, Jeff pointed out that `ChannelDetails` has
become a bit of a "bag of variables", and that a few of the variable
names in #984 were more confusing than necessary in context.

This addresses several issues by:
 * Splitting counterparty parameters into a separate
   `ChannelCounterpartyParameters` struct,
 * using the name `unspendable_punishment_reserve` for both outbound
   and inbound channel reserves, differentiating them based on their
   position in the counterparty parameters struct or not,
 * Using the name `force_close_spend_delay` instead of
   `spend_csv_on_our_commitment_funds` to better communicate what
   is occurring.

3 years agoMerge pull request #961 from TheBlueMatt/2021-06-workaround-broken-cln
Matt Corallo [Thu, 8 Jul 2021 14:51:47 +0000 (14:51 +0000)]
Merge pull request #961 from TheBlueMatt/2021-06-workaround-broken-cln

Use the query start block for ReplyChannelRange response messages

3 years agoUse the query start block for ReplyChannelRange response messages 2021-06-workaround-broken-cln
Matt Corallo [Sat, 19 Jun 2021 15:48:23 +0000 (15:48 +0000)]
Use the query start block for ReplyChannelRange response messages

C-Lightning versions prior to 0.10 (incorrectly) enforce that the
reply_channel_range first_blocknum field is set to at least the
value they sent in their query_channel_range message. Sending a 0
results in them responding with an Error message, closing open
channels spuriously.

Further, C-Lightning versions prior to 0.10 require that the
reply_channel_range first_blocknum is either the same block implied
as the last block of the previous reply_channel_range or one
greater. This is not only a creative interpretation of the spec,
but a perfectly reasonable implementation might still receive an
Error message in the case of replies split by an empty block.

This code is extracted and modified from a previous version of
the original query_channel_range PR in commit
44ba52ccf10bb0362ed2964b66ec2ae51e388161. The original commit is by
`bmancini55 <bmancini@gmail.com>`.

3 years agoMerge pull request #949 from TheBlueMatt/2021-06-send-priv-update
Matt Corallo [Wed, 7 Jul 2021 20:17:10 +0000 (20:17 +0000)]
Merge pull request #949 from TheBlueMatt/2021-06-send-priv-update

Send channel_update messages to direct peers on private channels

3 years agoIgnore our own gossip if it is sent to us from our counterparty 2021-06-send-priv-update
Matt Corallo [Wed, 30 Jun 2021 00:27:24 +0000 (00:27 +0000)]
Ignore our own gossip if it is sent to us from our counterparty

If our channel party sends us our own channel_update message, we'll
erroneously use the information in that message to update our view
of the forwarding parameters our counterparty requires of us,
ultimately generating invoices with bogus forwarding information.

This fixes that behavior by checking the channel_update's
directionality before handling it.

3 years agoFix spelling in ChannelManager comment
Matt Corallo [Mon, 14 Jun 2021 15:14:18 +0000 (15:14 +0000)]
Fix spelling in ChannelManager comment

3 years agoSend channel_update messages to direct peers on private channels
Matt Corallo [Sat, 12 Jun 2021 21:58:50 +0000 (21:58 +0000)]
Send channel_update messages to direct peers on private channels

If we are a public node and have a private channel, our
counterparty needs to know the fees which we will charge to forward
payments to them. Without sending them a channel_update, they have
no way to learn that information, resulting in the channel being
effectively useless for outbound-from-us payments.

This commit fixes our lack of channel_update messages to private
channel counterparties, ensuring we always send them a
channel_update after the channel funding is confirmed.

3 years agoMerge pull request #984 from TheBlueMatt/2021-06-more-chan-data
Matt Corallo [Tue, 6 Jul 2021 00:53:12 +0000 (00:53 +0000)]
Merge pull request #984 from TheBlueMatt/2021-06-more-chan-data

Expose More Information about Channels and structs

3 years agoTweak documentation in `BestBlock` to be a bit more clear 2021-06-more-chan-data
Matt Corallo [Mon, 5 Jul 2021 18:31:32 +0000 (18:31 +0000)]
Tweak documentation in `BestBlock` to be a bit more clear

3 years agoExpose the current best chain tip from ChannelManager + Monitors
Matt Corallo [Sat, 3 Jul 2021 01:58:30 +0000 (01:58 +0000)]
Expose the current best chain tip from ChannelManager + Monitors

Fixes #979

3 years agoExpand the fields exposed to users in `ChannelDetails`
Matt Corallo [Fri, 2 Jul 2021 23:54:57 +0000 (23:54 +0000)]
Expand the fields exposed to users in `ChannelDetails`

This adds four new fields in `ChannelDetails`:
1. holder_selected_ and counterparty_selected_channel_reserve_delay
   are useful to determine what amount of the channel is
   unavailable for payments.
2. confirmations_required is useful when awaiting funding
   confirmation to determine how long you will need to wait.
3. to_self_delay is useful to determine how long it will take to
   receive funds after a force-close.

Fixes #983.

3 years agoDrop Channel HTLC transaction building thin wrapper function
Matt Corallo [Sun, 4 Jul 2021 14:13:10 +0000 (14:13 +0000)]
Drop Channel HTLC transaction building thin wrapper function

3 years agoMake channel fields which are from accept_channel Optional
Matt Corallo [Sat, 3 Jul 2021 15:27:12 +0000 (15:27 +0000)]
Make channel fields which are from accept_channel Optional

These fields are set with a dummy value, which we should generally
be avoiding since Rust gives us a nice `Option` type to use
instead.

Further, we stop rejecting channel_update messages outright when
the htlc_maximum_msat field includes the reserve values, which
nodes could reasonably do without it meriting a channel closure.

3 years ago[router] Use the invoice value for last-hop hint channel capacity 2021-07-route-lasthop-value
Matt Corallo [Mon, 5 Jul 2021 18:10:34 +0000 (18:10 +0000)]
[router] Use the invoice value for last-hop hint channel capacity

If an invoice contains route hints, we should assume the channel
capacity is sufficient to route the invoice's value.

3 years agoMerge pull request #958 from TheBlueMatt/2021-06-fix-router-panic
Matt Corallo [Mon, 5 Jul 2021 00:01:43 +0000 (00:01 +0000)]
Merge pull request #958 from TheBlueMatt/2021-06-fix-router-panic

Fix panic in router given to bogus last-hop hints