Commit graph

672 commits

Author SHA1 Message Date
optout
649129ddab Add Splicing (and Quiescence) wire message definitions 2023-11-07 12:13:58 +01: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
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
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
Wilmer Paulino
27fba2dcc0
Only account for fee spike buffer multiple on non-anchor channels
Anchor outputs channels are no longer susceptible to fee spikes as they
now mostly target the dynamic minimum mempool fee and can contribute the
remainder of fees when closing.
2023-10-20 11:04:42 -07:00
Wilmer Paulino
37a3a03f12
Run chanmon_consistency_test with anchor outputs channels 2023-10-20 11:04:39 -07:00
Matt Corallo
be8797e17a
Merge pull request #2660 from benthecarman/flexible-fee-rate
More flexible fee rate estimates
2023-10-20 17:37:17 +00:00
benthecarman
dd15ab0394
More flexible fee rate estimates 2023-10-20 11:53:52 -05:00
Jeffrey Czyz
6dc42235ba
Allow sending onion messages to 1-hop blinded path
This allows for specifying the introduction node as the message
recipient.
2023-10-18 18:31:27 -05:00
Jeffrey Czyz
8b442fe4eb
Enqueue onion messages in handlers
When constructing onion messages to send initially (opposed to replying
to one from a handler), the user must construct an OnionMessagePath first
before calling OnionMessener::send_onion_message. Additionally, having a
reference to OnionMessener isn't always desirable. For instance, in an
upcoming commit, ChannelManager will implement OffersMessageHandler,
which OnionMessenger needs a reference to. If ChannelManager had a
reference to OnionMessenger, too, there would be a dependency cycle.

Instead, modify OffersMessageHandler and CustomOnionMessageHandler's
interfaces to include a method for releasing pending onion messages.
That way, ChannelManager may, for instance, construct and enqueue an
InvoiceRequest for sending without needing a reference to
OnionMessenger.

Additionally, OnionMessenger has responsibility for path finding just as
it does when replying to messages from a handler. It performs this when
extracting messages from the handlers before returning the next message
to send to a peer.
2023-10-18 18:31:16 -05:00
Jeffrey Czyz
840efd5334
Generalize CustomOnionMessageContents trait
Rename CustomOnionMessageContents to OnionMessageContents and use it as
a trait bound on messages passed to OnionMessenger methods. This allows
using the trait in an upcoming commit as a bound on the contents of
PendingOnionMessage.

Also, make ParsedOnionMessageContent implement OnionMessageContents so
that Payload can be bounded by OnionMessageContents directly, but used
when either reading a ParsedOnionMessageContent or writing a specific
type of OnionMessageContents (e.g., OffersMessage).
2023-10-18 18:15:05 -05:00
Jeffrey Czyz
81c6147a9e
Generalize respond_with_onion_message
OnionMessenger can send onion message responses from its handlers using
respond_with_onion_message, which finds a path to the destination and
enqueues the response for sending. Generalize this as it can be used not
only for responses but for initial sends as well.
2023-10-18 17:09:27 -05:00
Jeffrey Czyz
54f96ef944
Use ChainHash instead of BlockHash as applicable
ChainHash is more appropriate for places where an arbitrary BlockHash is
not desirable. This type was introduced in later versions of the bitcoin
crate, thus BlockHash was used instead.

Using ChainHash also makes it easier to check if ChannelManager is
compatible with an Offer.
2023-10-16 13:29:53 -05:00
Matt Corallo
34f36d5ffe Drop various bounds on types passed to MonitorUpdatingPersister
The new `MonitorUpdatingPersister` has a few redundant type bounds
(re-specified on functions after having been specified on the
struct itself), which we remove here.

Further, it requires a `Deref<FeeEstimator>` which is `Clone`able.
This is generally fine in rust, but annoying in bindings, so we
simply elide it in favor if a `&Deref<FeeEstimator>`.
2023-10-01 00:05:01 +00:00
Matt Corallo
c7c4226e99 Revert "Remove AvailableBalances::balance_msat"
While removing the `balance_msat` field absolutely makes sense -
it is, at best, confusing - we really need a solid replacement for
it before we can do so. While one such replacement is in progress,
it is not complete and we'd like to not block our current release
on its completion.

This reverts commit ef5be580f5.
2023-09-29 18:32:25 +00:00
Matt Corallo
23c5308bcb Drop the ChannelMonitorUpdateStatus::PermanentFailure variant
When a `ChannelMonitorUpdate` fails to apply, it generally means
we cannot reach our storage backend. This, in general, is a
critical issue, but is often only a transient issue.

Sadly, users see the failure variant and return it on any I/O
error, resulting in channel force-closures due to transient issues.

Users don't generally expect force-closes in most cases, and
luckily with async `ChannelMonitorUpdate`s supported we don't take
any risk by "delaying" the `ChannelMonitorUpdate` indefinitely.

Thus, here we drop the `PermanentFailure` variant entirely, making
all failures instead be "the update is in progress, but won't ever
complete", which is equivalent if we do not close the channel
automatically.
2023-09-21 19:04:05 +00:00
Matt Corallo
36af1f06fa
Merge pull request #2534 from tnull/2023-08-upstream-preflight-probing
Upstream and fix preflight probing
2023-09-18 16:41:57 +00:00
Elias Rohrer
c6a1a12aca
Include maybe_announced field in RouteHop
When sending preflight probes, we want to exclude last hops that are
possibly announced. To this end, we here include a new field in
`RouteHop` that will be `true` when we either def. know the hop to be
announced, or, if there exist public channels between the hop's
counterparties that this hop might refer to (i.e., be an alias for).
2023-09-18 15:08:27 +02:00
Matt Corallo
daf79f515f
Merge pull request #2413 from valentinewallace/2023-07-route-blinding
Route blinding MVP
2023-09-13 20:51:59 +00:00
Valentine Wallace
154841b234
Parameterize InboundPayload reads with NodeSigner
This will be used in the next commit to deserialize encrypted TLVs for
receiving to 1-hop blinded paths.
2023-09-12 18:11:59 -04:00
Matt Corallo
32e5903ef2 Restrict ChannelManager persist in fuzzing to when we're told to
In the `chanmon_consistency` fuzz, we currently "persist" the
`ChannelManager` on each loop iteration. With the new logic in the
past few commits to reduce the frequency of `ChannelManager`
persistences, this behavior now leaves a gap in our test coverage -
missing persistence notifications.

In order to cath (common-case) persistence misses, we update the
`chanmon_consistency` fuzzer to no longer persist the
`ChannelManager` unless the waker was woken and signaled to
persist, possibly reloading with a previous `ChannelManager` if we
were not signaled.
2023-09-12 21:28:30 +00:00
Matt Corallo
5c3fa553a1 Remove largely useless checks in chanmon_consistency fuzzer
When reloading nodes A or C, the chanmon_consistency fuzzer
currently calls `get_and_clear_pending_msg_events` on the node,
potentially causing additional `ChannelMonitor` or `ChannelManager`
updates, just to check that no unexpected messages are generated.

There's not much reason to do so, the fuzzer could always swap for
a different command to call the same method, and the additional
checking requires some weird monitor persistence introspection.

Here we simplify the fuzzer by simply removing this logic.
2023-09-12 19:06:34 +00:00
Antonio Yang
b1bedcfbec Rename SocketAddress from NetAddress 2023-09-08 20:42:06 +08:00
Elias Rohrer
b5e959460f
Merge pull request #2134 from jbesraa/add_fromstr_to_netaddress
implement fromstr trait to netaddress
2023-09-07 14:16:25 +02:00
Elias Rohrer
61cf75265e
Have Route hold RouteParameters 2023-09-06 19:35:38 +02:00
Elias Rohrer
266a3aa915
Have get_route take RouteParameters 2023-09-06 19:35:37 +02:00
jbesraa
4f45cdcad6 Implement from_str trait for NetAddress
- Add fuzz test for `NetAddress` `from_str` function
2023-09-06 19:25:30 +03:00
jbesraa
b2d3b94b17 Move zbase32 implementation to base32 file 2023-09-06 15:07:25 +03:00
jbesraa
d736ca8595 Add RFC4648 base32 encode and decode functions 2023-09-06 15:07:25 +03:00
Chris Waterson
e38916d838 Rename EnforcingSigner to TestChannelSigner
Since the advent of VLS, EnforcingSigner is only used now for testing.
2023-08-28 09:48:35 -07:00
optout
e99e6ab562
Use new ChannelId type 2023-08-26 01:30:40 +02:00
valentinewallace
0b196ebae6
Merge pull request #2432 from jkczyz/2023-07-bolt12-node-signer
Support signing BOLT 12 messages in `NodeSigner`
2023-08-22 16:22:16 -04:00
Jeffrey Czyz
39012e3595
Support signing BOLT 12 invoices in NodeSigner
BOLT 12 messages need to be signed in the following scenarios:
- constructing an InvoiceRequest after scanning an Offer,
- constructing an Invoice after scanning a Refund, and
- constructing an Invoice when handling an InvoiceRequest.

Extend the NodeSigner trait to support signing BOLT 12 invoices such
that it can be used in the latter contexts. The method could be used
in an OffersMessageHandler.
2023-08-21 19:14:29 -05:00
Jeffrey Czyz
1811ebff32
TaggedHash for BOLT 12 signing function
The function used to sign BOLT 12 messages only takes a message digest.
This doesn't allow signers to independently verify the message before
signing nor does it allow them to derive the necessary signing keys, if
needed.

Introduce a TaggedHash wrapper for a message digest, which each unsigned
BOLT 12 message type constructs upon initialization. Change the signing
function to take AsRef<TaggedHash>, which each unsigned type implements.
This allows the signing function to take any unsigned message and obtain
its tagged hash.
2023-08-21 19:14:27 -05:00
Willem Van Lint
ef5be580f5 Remove AvailableBalances::balance_msat
The ChannelMonitor::get_claimable_balances method provides a more
straightforward approach to the balance of a channel, which satisfies
most use cases. The computation of AvailableBalances::balance_msat is
complex and originally had a different purpose that is not applicable
anymore.
2023-08-15 11:42:00 -07:00
Matt Corallo
4b24135738
Merge pull request #2128 from valentinewallace/2023-03-route-blinding-groundwork
Route blinding groundwork
2023-08-08 19:59:05 +00:00
Valentine Wallace
02a6d895a5
Receive payment onions as new InboundPayload instead of OnionHopData
To support route blinding, we want to split OnionHopData into two separate
structs, one for inbound onions and one for outbound onions. This is because
blinded payloads change the fields present in the onion hop data struct based
on whether we're sending vs receiving (outbound onions include encrypted blobs,
inbound onions can decrypt those blobs and contain the decrypted fields
themselves).

In upcoming commits, we'll add variants for blinded payloads to the new
InboundPayload enum.
2023-08-02 12:54:34 -07:00
Valentine Wallace
a35b92c8c8
Fuzz test blinded payment pathfinding 2023-07-25 16:32:33 -07:00
Valentine Wallace
9bf4b6ed90
Router fuzz: macroize first/last hops construction and pathfinding call
For reuse in fuzzing blinded payment pathfinding, and to ensure fuzz input
values are fetched in the same order in both match arms.
2023-07-25 16:32:30 -07:00
Matt Corallo
d2c20ecc2d Pass InFlightHltcs to the scorer by ownership rather than ref
Given we build `InFlightHtlcs` per route-fetch call, there's no
reason to pass them out by reference rather than simply giving the
user the full object. This also allows them to tweak the in-flight
set before fetching a route.
2023-07-20 19:49:43 +00:00
Matt Corallo
baf9731a21
Merge pull request #2415 from wpaulino/update-fee-anchors
Add min mempool estimate for feerate updates on anchor channels
2023-07-17 19:45:51 +00:00
Wilmer Paulino
db3d58c586
Add new ConfirmationTarget variant for min mempool feerates
Now that we support channels with anchor outputs, we add a new
ConfirmationTarget variant that, for now, will only apply to such
channels. This new variant should target estimating the minimum feerate
required to be accepted into most node mempools across the network.
2023-07-14 14:49:52 -07:00
Jeffrey Czyz
3234136f57
Qualify the BOLT 12 semantic error
To avoid a naming conflict in bindings with BOLT 11 semantic error,
qualify the BOLT 12 semantic error type.
2023-07-14 15:04:43 -05:00
Jeffrey Czyz
5627d7cc1f
Qualify the BOLT 12 parse error
To avoid a naming conflict in bindings with BOLT 11 parse error, qualify
the BOLT 12 parse error type.
2023-07-14 15:04:43 -05:00
Jeffrey Czyz
d94227cc13
Qualify the BOLT 12 unsigned invoice type
A previous commit qualified the BOLT 12 invoice type, so any related
types should be similarly qualified, if public.
2023-07-14 15:04:43 -05:00
Jeffrey Czyz
f8c9b092fd
Qualify the BOLT 12 invoice type
To avoid a naming conflict in bindings with BOLT 11 invoices, qualify
the BOLT 12 invoice type.
2023-07-14 15:04:43 -05:00
Matt Corallo
6ebb6d182e
Merge pull request #2354 from alecchendev/2023-06-bump-default-dust-exp
Bump dust exposure threshold
2023-07-08 02:15:10 +00:00
Alec Chen
b040335712
Use multiplier in dust exposure threshold calculation
This commit makes use of the added enum to calculate the dust
exposure threshold based on the current fee rate. This also updates
tests to ensure it works as intended.
2023-07-07 14:30:51 -05:00