Commit graph

6212 commits

Author SHA1 Message Date
Valentine Wallace
1926c82b9e
Include counterparty skimmed fees in PaymentClaimed event. 2023-11-07 15:08:55 -05:00
Matt Corallo
50eba2624f
Merge pull request #2699 from mhrheaume/mhr/temporary_channel_id
Added `temporary_channel_id` to `create_channel`.
2023-11-05 05:35:40 +00:00
Matthew Rheaume
bf395070dd Added temporary_channel_id to create_channel.
By default, LDK will generate the initial temporary channel ID for you.
However, in certain cases, it's desirable to have a temporary channel ID
specified by the caller in case of any pre-negotiation that needs to
happen between peers prior to the channel open message. For example, LND
has a `FundingShim` API that allows for advanced funding flows based on
the temporary channel ID of the channel.

This patch adds support for optionally specifying the temporary channel
ID of the channel through the `create_channel` API.
2023-11-03 17:44:50 -07:00
Matt Corallo
281a0aead7
Merge pull request #2558 from waterson/pr-2554
Handle retrying sign_counterparty_commitment failures
2023-11-02 19:04:05 +00:00
Elias Rohrer
d795e247b7
Merge pull request #2641 from alexanderwiederin/2585-preflight-test-coverage
#2585 Preflight Test Coverage
2023-11-02 09:50:21 +01:00
Chris Waterson
014a336e59 Add basic async signer tests
Adds a `get_signer` method to the context so that a test can get ahold of the
channel signer. Adds a `set_available` method on the `TestChannelSigner` to
allow a test to enable and disable the signer: when disabled some of the
signer's methods will return `Err` which will typically activate the error
handling case. Adds a `set_channel_signer_available` function on the test
`Node` class to make it easy to enable and disable a specific signer.

Adds a new `async_signer_tests` module:

* Check for asynchronous handling of `funding_created` and `funding_signed`.
* Check that we correctly resume processing after awaiting an asynchronous
  signature for a `commitment_signed` event.
* Verify correct handling during peer disconnect.
* Verify correct handling for inbound zero-conf.
2023-11-01 15:24:20 -07:00
Matt Corallo
4278afc9aa Handle retrying sign_counterparty_commitment inb funding failures
If sign_counterparty_commitment fails (i.e. because the signer is
temporarily disconnected), this really indicates that we should
retry the message sending which required the signature later,
rather than force-closing the channel (which probably won't even
work if the signer is missing).

This commit adds retrying of inbound funding_created signing
failures, regenerating the `FundingSigned` message, attempting to
re-sign, and sending it to our peers if we succeed.
2023-11-01 15:24:20 -07:00
Matt Corallo
8d01309555 Handle retrying sign_counterparty_commitment outb funding failures
If sign_counterparty_commitment fails (i.e. because the signer is
temporarily disconnected), this really indicates that we should
retry the message sending which required the signature later,
rather than force-closing the channel (which probably won't even
work if the signer is missing).

This commit adds retrying of outbound funding_created signing
failures, regenerating the `FundingCreated` message, attempting to
re-sign, and sending it to our peers if we succeed.
2023-11-01 15:24:20 -07:00
Matt Corallo
f36afcbae3 Handle retrying sign_counterparty_commitment failures
If sign_counterparty_commitment fails (i.e. because the signer is
temporarily disconnected), this really indicates that we should
retry the message sending which required the signature later,
rather than force-closing the channel (which probably won't even
work if the signer is missing).

This commit adds initial retrying of failures, specifically
regenerating commitment updates, attempting to re-sign the
`CommitmentSigned` message, and sending it to our peers if we
succed.
2023-11-01 15:24:14 -07:00
Matt Corallo
0e3f6b6029 Handle sign_counterparty_commitment failing during inb funding
If sign_counterparty_commitment fails (i.e. because the signer is
temporarily disconnected), this really indicates that we should
retry the message sending which required the signature later,
rather than force-closing the channel (which probably won't even
work if the signer is missing).

Here we add initial handling of sign_counterparty_commitment
failing during inbound channel funding, setting a flag in
`ChannelContext` which indicates we should retry sending the
`funding_signed` later. We don't yet add any ability to do that
retry.
2023-11-01 14:41:08 -07:00
Matt Corallo
d86f73b8d5 Handle sign_counterparty_commitment failing during outb funding
If sign_counterparty_commitment fails (i.e. because the signer is
temporarily disconnected), this really indicates that we should
retry the message sending which required the signature later,
rather than force-closing the channel (which probably won't even
work if the signer is missing).

Here we add initial handling of sign_counterparty_commitment
failing during outbound channel funding, setting a new flag in
`ChannelContext` which indicates we should retry sending the
`funding_created` later. We don't yet add any ability to do that
retry.
2023-11-01 14:41:02 -07:00
Matt Corallo
1da29290e7 Handling for sign_counterparty_commitment failing during normal op
If sign_counterparty_commitment fails (i.e. because the signer is
temporarily disconnected), this really indicates that we should
retry the message sending later, rather than force-closing the
channel (which probably won't even work if the signer is missing).

Here we add initial handling of sign_counterparty_commitment
failing during normal channel operation, setting a new flag in
`ChannelContext` which indicates we should retry sending the
commitment update later. We don't yet add any ability to do that
retry.
2023-11-01 14:29:59 -07:00
valentinewallace
415cbf088e
Merge pull request #2682 from jkczyz/2023-09-bolt12-test-vectors
BOLT 12 Offer test vectors
2023-11-01 14:34:29 -04:00
alexanderwiederin
a38bdbe7bc
add preflight probes test coverage 2023-11-01 19:33:12 +01:00
Matt Corallo
d0f0d9c19f
Merge pull request #2686 from jkczyz/2023-10-onion-message-fuzz
Re-add one-hop onion message fuzzing test
2023-11-01 17:42:29 +00:00
valentinewallace
1f399b0984
Merge pull request #2668 from TheBlueMatt/2023-10-fix-doc
Update docs on `MonitorEvent::HolderForceClosed`
2023-10-30 16:21:36 -04:00
valentinewallace
44e87b86f2
Merge pull request #2693 from Evanfeenstra/next-hop-pubkey-secp-mode
next_hop_pubkey secp Verification only
2023-10-30 12:49:42 -04:00
Matt Corallo
b6f3d0a5fa
Merge pull request #2669 from benthecarman/trace-sync-progress
Remove channel monitor sync in progress log
2023-10-30 16:00:19 +00:00
Matt Corallo
b3e7aac4a7
Merge pull request #2689 from benthecarman/no-std-offer-expire
Add `is_expired_no_std` to Offer
2023-10-29 19:38:26 +00:00
Matt Corallo
8f308f98dd
Merge pull request #2613 from wvanlint/batch_funding_fix_up
Refactor ShutdownResult type and construction
2023-10-29 17:58:56 +00:00
Evan Feenstra
c70961e9ca next_hop_pubkey secp Verification only 2023-10-28 08:11:21 -07:00
benthecarman
5ddd8a7559
Add is_expired_no_std to Offer & Refund
This was available for OfferContents but not an Offer so dependent
projects could not access it.
2023-10-26 20:58:04 -05:00
Jeffrey Czyz
bb1a4f5556
Re-add one-hop onion message fuzzing test
Revert fuzz test removal in 6dc42235ba.
The test originally checked that OnionMessenger would fail for one-hop
blinded paths. The commit added support for such paths, but changing the
checks was not sufficient since the node was not connected to the
introduction node of the reply path. This is required in order to work
with the trivial TestMessageRouter. Fix this by explicitly connecting
the nodes.
2023-10-25 18:13:10 -05:00
Jeffrey Czyz
c0bf030ad2
Wrap long onion_message fuzz strings
Some editors like vim slow to a crawl when scrolling over long strings
when syntax highlighting is turned on. Limit the length in fuzz strings
to avoid this.
2023-10-25 18:12:44 -05:00
Jeffrey Czyz
e469492d95
BOLT 12 test vectors for offer parsing
One discrepancy from the spec still needs to be resolved:

https://github.com/lightning/bolts/pull/798/files#r1334851959
2023-10-24 15:45:35 -05:00
Jeffrey Czyz
452a30e746
Separate and describe BOLT 12 test vectors 2023-10-24 14:19:21 -05:00
Jeffrey Czyz
5fc4abc5cd
Move bech32 parsing tests to the parse module
Additional BOLT 12 tests specific to Offer were added, which will live
in the offer module. Thus, it makes sense to move the bech32 tests to
the parse module.
2023-10-24 13:09:15 -05:00
Matt Corallo
d2242f604d
Merge pull request #2678 from TheBlueMatt/2023-10-0.0.118
Cut 0.0.118
2023-10-24 01:26:30 +00:00
Matt Corallo
b664875c1b Bump crate versions to lightning 0.0.118, invoice 0.26 2023-10-23 23:41:11 +00:00
Matt Corallo
2587f70925 0.0.118 release notes 2023-10-23 23:41:11 +00:00
Matt Corallo
d0795d8904
Merge pull request #2679 from TheBlueMatt/2023-10-116-bindings-1
Small bindings tweaks for 0.0.118
2023-10-23 22:58:15 +00:00
Matt Corallo
35eb38df14 Fix CI on rustc 1.50 and below
rustc doesn't allow `--features` with `-p`, so we simply skip the
steps that rely on it.
2023-10-23 19:50:12 +00:00
Matt Corallo
49a5fdf6aa Use a tuple, not a struct, for PendingOnionMessage in bindings
Bindings aren't currently able to handle a struct with a generic
which is actually exposed - we map all structs concretely to a
single type, whereas having fluctuating types on a struct requires
mapping the inner field to a trait first.

Since this isn't super practical, we make `PendingOnionMessage` a
tuple in bindings, rather than a struct.
2023-10-23 19:42:32 +00:00
Matt Corallo
3f416bc24e
Merge pull request #2676 from TheBlueMatt/2023-10-various-followups
Various Followups to 2039 and 2674
2023-10-23 19:16:29 +00:00
Matt Corallo
32d2d0f1cf Add relevant no-export tags to functions returning builders
Because we can't map move semantics in most languages, we also
can't map our current builders. Thus, we have to mark them
no-export.
2023-10-23 16:50:42 +00:00
Matt Corallo
4918c415af Drop an unnecessary no-export on ParsedOnionMessageContents 2023-10-23 16:50:35 +00:00
Matt Corallo
4443db67f9 Do not compile the Simple* type aliases in c_bindings at all
Because the bindings changes now require further changes to our
type definitions, avoiding building the `Simple*` type aliases
entirely makes the patchset there simpler.
2023-10-21 16:30:41 +00:00
Matt Corallo
bbb8facbe6 Fix (and test) the c_bindings build flag
Rather than only building with the `c_bindings` flag in certain
crates, we go ahead and test all crates with the flag in CI here.
2023-10-21 14:30:21 +00:00
Matt Corallo
d2532dce34 Remove some additional excess words in ConfirmationTarget docs 2023-10-21 14:30:13 +00:00
Matt Corallo
d7668e1d12 Remove a redundant sentence in ConfirmationTarget docs
... and correct direction which causes force-closure in another
sentence.
2023-10-21 14:30:13 +00:00
Matt Corallo
803fb557e8 Drop unused use import. 2023-10-21 14:30:13 +00:00
Matt Corallo
d974a07e96 Avoid a redundant allocation in InvoiceError handling in one case
... by passing an owned `String`, rather than taking an `&str` and
`to_owned()`ing it.
2023-10-21 14:30:13 +00:00
Matt Corallo
50c55dcf32 Use Default::default() for scoring params in tests
In 26c1639ab6 we switched to using
`Default::default()` to initialize `()` for scoring parameters in
tests. A number of `()`s slipped back in recently, which we replace
here.
2023-10-21 14:30:13 +00:00
Matt Corallo
a1a2f2abc8
Merge pull request #2667 from wpaulino/random-htlc-holder-sigs-non-anchors
Use sign_holder_htlc_transaction to sign non-anchors holder HTLCs
2023-10-20 22:55:08 +00:00
Matt Corallo
fba99b73bf
Merge pull request #2674 from wpaulino/consider-anchor-outputs-value-balances
Consider anchor outputs value throughout balance checks and computations
2023-10-20 22:54:08 +00:00
Wilmer Paulino
b06a652e58
Move HTLCDescriptor to sign module
Now that `HTLCDescriptor` is no longer specific to anchors, it doesn't
make sense for it to live in the `bump_transaction` module anymore.
2023-10-20 15:32:16 -07:00
Wilmer Paulino
aae4e7c0ca
Don't sign holder HTLCs along with holder commitments
`sign_holder_commitment_and_htlcs` never really made sense. Unlike
`sign_counterparty_commitment`, the signatures for holder HTLC
transactions may be required much later than the commitment
transaction's. While it was nice for us to only reach the signer once to
obtain all holder signatures, it's not really ideal anymore as we want
our signatures to be random and not reused.

We no longer return all holder HTLC signatures and instead defer to
obtaining them via `EcdsaChannelSigner::sign_holder_htlc_transaction`.
2023-10-20 15:32:15 -07:00
Wilmer Paulino
a9d9d26655
Remove caching of holder HTLC signatures
Since we want our holder HTLC signatures to be randomly generated and
not reused, our existing caches are useless now, so we opt to remove
them.
2023-10-20 15:32:14 -07:00
Wilmer Paulino
03ec74631f
Use sign_holder_htlc_transaction to sign non-anchors holder HTLCs
We want to ensure we use fresh random signatures to prevent certain
classes of transaction replacement attacks at the bitcoin P2P layer.
This was already covered for commitment transactions and zero fee holder
HTLC transactions, but was missing for holder HTLC transactions on
non-anchors channels.

We can easily do this by reusing the existing
`EcdsaChannelSigner::sign_holder_htlc_transaction` method and
circumventing the existing `holder_htlc_sigs/prev_holder_htlc_sigs`
caches, which will be removed in a later commit anyway.
2023-10-20 15:32:13 -07:00
Matt Corallo
ec4395cf6e Apply a default max fee rather than none when paying for BOLT12
If the user declines to specify a `max_total_routing_fee_msat` in
the new BOLT12 payment methods, rather than defaulting to no limit
on the fee we pay at all, we should default to our "usual default",
ie the one calculated in
`RouteParameters::from_payment_params_and_value`.

We do this here, as well as documenting the behavior on the payment
methods.
2023-10-20 18:09:09 +00:00