Commit Graph

631 Commits

Author SHA1 Message Date
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
Matt Corallo
498f233145
Merge pull request #2204 from jkczyz/2023-04-custom-feature-bits
Support for custom feature bits
2023-05-18 19:28:19 +00:00
Matt Corallo
5c89d01905
Merge pull request #2288 from wpaulino/rust-bitcoin-30-prereqs 2023-05-15 18:42:38 +00:00
benthecarman
29b392a96d
Support broadcasting multiple transactions at once 2023-05-12 23:29:38 -05:00
henghonglee
21b0818be7 Score's FeeParams as passed-in params on Routefinding functions
This PR aims to create a "stateless" scorer. Instead of passing
in fee params at construction-time, we want to parametrize the
scorer with an associated "parameter" type, which is then
passed to the router function itself, and allows passing
different parameters per route-finding call.
2023-05-10 12:53:42 -07:00
Jeffrey Czyz
3ce87a3ddb
Check unknown features compared to handlers
Each message handler provides which features it supports. A custom
message handler may support unknown features. Therefore, these features
should be checked against instead of the features known by LDK.
Additionally, fail the connection if the peer requires features unknown
to the handler. The peer should already fail the connection in the
latter case.
2023-05-10 14:04:59 -05:00
Wilmer Paulino
17a74fcfc7
Use helper to create dummy blocks
`rust-bitcoin v0.30.0` introduces concrete variants for data members of
block `Header`s. To avoid having to update these across every use, we
introduce new helpers to create dummy blocks and headers, such that the
update process is a bit more straight-forward.
2023-05-10 11:39:49 -07:00
Matt Corallo
0ecb4b093a
Merge pull request #2258 from valentinewallace/2023-04-blinded-pathfinding-groundwork-2
Prefactor `PaymentParameters` for blinded recipients
2023-05-08 23:17:42 +00:00
Duncan Dean
2ace882d39
Add & generate dual-funding message fuzzing 2023-05-05 11:40:53 +02:00
Duncan Dean
adc1b55a6f
Add message structs required for dual-funded channels
This is the first of a set of PRs to enable the experimental dual-funded
channels feature using interactive transaction construction. This allows
both the channel initiator and channel acceptor to contribute funds
towards the channel.
2023-05-05 11:40:49 +02:00
Valentine Wallace
cea78f585a
Error if clear hints are provided for blinded PaymentParams 2023-05-04 10:50:53 -04:00
Arik Sosman
6cb9919f0c
Move keysinterface.rs to a directory-level module called sign. 2023-05-02 21:48:08 -07:00
Matt Corallo
ec3de62bc7
Merge pull request #2249 from TheBlueMatt/2023-04-less-pm-bounds
Trivial PeerManager cleanups
2023-05-03 01:41:17 +00:00
Matt Corallo
101c09f9bf
Merge pull request #2213 from benthecarman/error-sign-provider-addrs
Allow get_shutdown_scriptpubkey and get_destination_script to return an Error
2023-05-02 17:48:05 +00:00
benthecarman
0b8bdbf968
Allow get_shutdown_scriptpubkey and get_destination_script to return an error 2023-05-02 02:39:54 -05:00
Matt Corallo
524981ddf4 Move the CustomMessageHandler into the MessageHandler struct
`PeerManager` takes a `MessageHandler` struct which contains all
the known message handlers for it to pass messages to. It then,
separately, takes a `CustomMessageHandler`. This makes no sense, we
should simply include the `CustomMessageHandler` in the
`MessageHandler` struct for consistency.
2023-04-30 04:03:55 +00:00
Matt Corallo
c89fd38f2a
Merge pull request #2220 from TheBlueMatt/2023-04-dont-ban-cln
Don't remove nodes if there's no channel_update for a temp failure
2023-04-24 21:15:08 +00:00
Matt Corallo
67ad6c40f0 Don't remove nodes if there's no channel_update for a temp failure
Previously, we were requiring any `UPDATE` onion errors to include
a `channel_update`, as the spec mandates[1]. If we see an onion
error which is missing one we treat it as a misbehaving node that
isn't behaving according to the spec and simply remove the node.

Sadly, it appears at least some versions of CLN are such nodes, and
opt to not include `channel_update` at all if they're returning a
`temporary_channel_failure`. This causes us to completely remove
CLN nodes from our graph after they fail to forward our HTLC.

While CLN is violating the spec here, there's not a lot of reason
to not allow it, so we go ahead and do so here, treating it simply
as any other failure by letting the scorer handle it.

[1] The spec says `Please note that the channel_update field is
mandatory in messages whose failure_code includes the UPDATE flag`
however doesn't repeat it in the requirements section so its not
crazy that someone missed it when implementing.
2023-04-24 18:52:05 +00:00
Matt Corallo
607727fae7
Merge pull request #2146 from valentinewallace/2023-03-blinded-pathfinding-groundwork
Blinded pathfinding groundwork
2023-04-24 16:46:15 +00:00
Valentine Wallace
64c26c8a79
Add blinded path {metadata} fields to Path, but disallow paying blinded paths for now 2023-04-21 15:35:04 -04:00
Valentine Wallace
d5b05e54c3
Replace Vec<RouteHop> with new Path struct
This lays groundwork for adding blinded path info to Path
2023-04-21 11:48:27 -04:00
Wilmer Paulino
2c5bd1c56f
Implement EntropySource for InMemorySigner
This allows the `InMemorySigner` to produce its own randomness, which we
plan to use when generating signatures in future work.

We can no longer derive `Clone` due to the `AtomicCounter`, so we opt to
implement it manually.
2023-04-20 12:14:19 -07:00
Valentine Wallace
e691e5077d
Update docs and method names for blinded payment paths 2023-04-20 10:14:17 -04:00
Valentine Wallace
efed905a4f
Move blinded_path and its utils into a new module 2023-04-20 10:14:15 -04:00
Matt Corallo
dddb2e28c1 Replace PaymentSecret with RecipientOnionFields in the pub API
This moves the public payment sending API from passing an explicit
`PaymentSecret` to a new `RecipientOnionFields` struct (which
currently only contains the `PaymentSecret`). This gives us
substantial additional flexibility as we look at add both
`PaymentMetadata`, a new (well, year-or-two-old) BOLT11 invoice
extension to provide additional data sent to the recipient.

In the future, we should also add the ability to add custom TLV
entries in the `RecipientOnionFields` struct.
2023-04-05 16:28:14 +00:00
Elias Rohrer
9873c7dad8
Add ChannelPending event emitted upon funding_signed
Currently, users don't have good way of being notified when channel open
negotiations have succeeded and new channels are pending confirmation on
chain. To this end, we add a new `ChannelPending` event that is emitted
when send or receive a `funding_signed` message, i.e., at the last
moment before waiting for the confirmation period.

We track whether the event had previously been emitted in `Channel` and
remove it from `internal_funding_created` entirely. Hence, we now
only emit the event after ChannelMonitorUpdate completion, or upon
channel reestablish. This mitigates a race condition where where we
wouldn't persist the event *and* wouldn't regenerate it on restart,
therefore potentially losing it, if async CMU wouldn't complete before
ChannelManager persistence.
2023-04-03 19:04:32 +02:00
Wilmer Paulino
ca9ca75f08
Move events.rs into its own top-level module
This is largely motivated by some follow-up work for anchors that will
introduce an event handler for `BumpTransaction` events, which we can
now include in this new top-level `events` module.
2023-03-22 11:49:33 -07:00