Commit Graph

657 Commits

Author SHA1 Message Date
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
henghonglee
47cb45ed32 Add ChannelShutdownState to ChannelDetails
This commit adds the state of channel shutdown to channeldetails
2023-07-06 10:51:35 +08:00
Wilmer Paulino
82e0df5e4d
Require best block timestamp within ChannelManager::new
This ensures freshly initialized nodes can proceed to create unexpired
invoices without a call to `best_block_updated`, since an invoice's
expiration delta is applied to `highest_seen_timestamp`.
2023-06-27 13:43:14 -07:00
Matt Corallo
ba342de241
Merge pull request #2120 from valentinewallace/2023-03-blinded-pathfinding 2023-06-20 15:51:59 +00:00
Valentine Wallace
3184393df2
Reverse (BlindedPath, BlindedPayInfo) tuple order in offers invoice.
To make it uniform with PaymentParameters' Payee::Blinded::route_hints.
2023-06-16 11:14:53 -04:00
Jeffrey Czyz
c16ecbae92
Fuzz test onion message replies 2023-06-13 13:07:48 -05:00
Jeffrey Czyz
4257f65738
Use different node secrets in onion message fuzzer
When generating onion message fuzz data, the same public key was used
for each node. However, the code now advances the blinded path if the
sender is the introduction node. Use different node secrets for each
node to avoid this. Note that the exercised handling code is for the
sender's immediate peer.
2023-06-13 13:07:48 -05:00
Jeffrey Czyz
c17c2ae3c0
Support onion message replies in OnionMessenger
Modify onion message handlers to return an optional response message for
OnionMessenger to reply with.
2023-06-13 13:07:47 -05:00
Jeffrey Czyz
a71000f35d
MessageRouter trait for OnionMessenger
Add a trait for finding routes for onion messages and parameterize
OnionMessenger with it. This allows OnionMessenger to reply to messages
that it handles via one of its handlers (e.g., OffersMessageHandler).
2023-06-13 13:07:47 -05:00
Jeffrey Czyz
f521e4cceb
OffersMessageHandler trait for OnionMessenger
Add a trait for handling BOLT 12 Offers messages to OnionMessenger and a
skeleton implementation of it for ChannelManager. This allows users to
either provide their own custom handling Offers messages or rely on a
version provided by LDK using stateless verification.
2023-06-13 13:07:47 -05:00
Matt Corallo
f068df03c5
Merge pull request #2312 from TheBlueMatt/2023-05-next-htlc-min-max
Avoid generating unpayable routes due to balance restrictions
2023-06-07 17:03:01 +00:00
Matt Corallo
10e213cf40 Replace send_htlc amount checking with available balances
Now that the `get_available_balances` min/max bounds are exact, we
can stop doing all the explicit checks in `send_htlc` entirely,
instead comparing against the `get_available_balances` bounds and
failing if the amount is out of those bounds.

This breaks support for sending amounts below the dust limit if
there is some amount of dust exposure remaining before we hit our
cap, however we will no longer generate such routes anyway.
2023-06-06 23:57:56 +00:00
Matt Corallo
66c4f454f0 Ensure a 1:1 mapping of value sendable to send success in fuzzing
Now that the value available to send is expected to match the
success or failure of sending exactly, we should assert this in the
`chanmon_consistency` fuzzer.

In the next commit we'll actually rip the checks out of `send_htlc`
which will make this a somewhat less useful test, however fuzzing
on this specific commit can help to reveal bugs.
2023-06-06 23:57:56 +00:00
Matt Corallo
3aa8a1721c Add a next-outbound-HTLC minimum field to chan details and use it
In the coming commits, in order to ensure all routes we generate
are usable, we'll start calculating the next-HTLC minimum for our
channels and using it in the router. Here we set this up by adding
an always-0 field for it in `ChannelDetails` and use it when
routing.
2023-06-06 23:57:55 +00:00
Duncan Dean
e23102f565
Add networks TLV to Init's TLV stream
This was a fairly old introduction to the spec to allow nodes to indicate
to their peers what chains they are interested in (i.e. will open channels
and gossip for).

We don't do any of the handling of this message in this commit and leave
that to the very next commit, so the behaviour is effectively the same
(ignore networks preference).
2023-06-05 09:45:41 +02:00
Matt Corallo
6775b957bc
Merge pull request #2272 from benthecarman/package-broadcast
Support broadcasting multiple transactions at once
2023-05-21 01:53:35 +00:00