Commit graph

5721 commits

Author SHA1 Message Date
Valentine Wallace
2e685ffb24
Remove UserConfig::accept_mpp_keysend
This option was added to force users to opt into breaking compat with
< 0.0.116, so it should be fine to remove for the 0.1 release. Otherwise,
receiving to static invoices would always require flipping this on.
2024-12-04 15:57:20 -05:00
Matt Corallo
726dd5cad3
Merge pull request #3429 from andrei-21/feature/channelmonitor-goodies
Clean channelmonitor.rs code
2024-12-04 14:58:05 +00:00
Matt Corallo
1386bef048
Merge pull request #3431 from tnull/2024-11-drop-logging-features
Drop log-limiting features
2024-12-03 17:54:20 +00:00
Elias Rohrer
f6af8e346e
Drop log-limiting features
Previously, LDK offered two ways to limit log outputs:
filtering during runtime client-side by matching on any given `Record`'s `Level` value,
as well as at compile time through the `max_level_*` feature flags.

It turns out the latter approach was always broken when used outside of
the `lightning` crate. Here, we therefore simply drop the feature-based
filtering.
2024-12-03 17:26:49 +01:00
Matt Corallo
e1e8ce00c8
Merge pull request #3420 from TheBlueMatt/2024-11-live-success-prob
Add the ability to fetch a probability from live liquidity bounds
2024-12-03 16:10:22 +00:00
Matt Corallo
d3efe5cbb7 Add a fallback-allowed param to historical success prob estimator
`historical_estimated_payment_success_probability` exposes the
historical success probability estimator publicly, but only allows
fetching data from channels where we have sufficient information.

In the previous commit,
`live_estimated_payment_success_probability` was added to enable
querying the live bounds success probability estimator.

Sadly, while the historical success probability estimator falls
back to the live probability estimator, it does so with a different
final parameter to `success_probability`, making
`live_estimated_payment_success_probability` not useful for
calculating the actual historical model output when we have
insufficient data.

Instead, here, we add a new parameter to
`historical_estimated_payment_success_probability` which
determines whether it will return fallback data from the live
model instead.
2024-12-02 16:45:50 +00:00
Matt Corallo
b1770ba8f6 Add the ability to fetch a probability from live liquidity bounds
We already expose the estimated success probability from the
historical liquidity bounds from
`historical_estimated_payment_success_probability`, but we don't
do that for the live liquidity bounds.

Here we add a `live_estimated_payment_success_probability` which
exposes the probability result from the live liquidity bounds as
well.
2024-12-02 16:45:50 +00:00
Andrei
8ebda06c4e Turn IrrevocablyResolvedHTLC comment into a Rust comment 2024-12-02 00:00:00 +00:00
Andrei
fa731ae832 Fix ISO 4712 typo to ISO 4217 2024-11-28 00:00:00 +00:00
Andrei
553e6c7ec6 Clean channelmonitor.rs code
* Replace deprecated `u64::max_value()`
* Use `Option::is_some()`
* Use `Iterator::any()` instead of `Iterator::find()`
2024-11-27 00:00:00 +00:00
Matt Corallo
12920d8ca4
Merge pull request #3417 from dunxen/2024-11-removenextfundingtxidpersist
Remove `next_funding_txid` tlv from `Channel` read/write
2024-11-26 22:32:40 +00:00
valentinewallace
70ace8184c
Merge pull request #3345 from tankyleo/onion-channel-updates
Stop sending `channel_update` in onion failures
2024-11-26 14:24:10 -05:00
Matt Morehouse
857d36344d
Correct return value for apply_post_close_monitor_update
A recent change accidentally inverted the returned monitor update for
the case where an update is applied after the channel has been closed.
This commit corrects that mistake.
2024-11-26 10:35:44 -06:00
Duncan Dean
7177acb576
Remove next_funding_txid tlv from channel read/write
We want to remove this before release so that we can work on a way to
not persist this but rather get it from other persisted data and just
free up the TLV.

Note that the "added in 0.0.124" comment was incorrect as it was
actually added in #3137 but the comment was stale so it's safe to remove.
2024-11-25 09:19:05 +02:00
Matt Corallo
aba57bbc07 Make test_durable_preimages_on_closed_channel more robust
Makes `test_durable_preimages_on_closed_channel` more robust
against changes to the order in which transactions are broadcast.
2024-11-24 13:56:07 +00:00
Duncan Dean
85d58ba484
Remove unused muts in channel tests 2024-11-20 14:04:17 +02:00
Duncan Dean
c762c6b5e4
Fix docs to indicate OpenChannelRequest is NOT persisted across restarts 2024-11-20 14:04:15 +02:00
Duncan Dean
2deb41aa5c
Add manual testing for accepting dual-funded channels 2024-11-20 14:04:14 +02:00
Duncan Dean
c3896b55ad
Temporarily allow some unused dual-funding code 2024-11-20 14:04:12 +02:00
Duncan Dean
f793bf8ad6
Add option_dual_fund feature 2024-11-20 14:01:42 +02:00
Duncan Dean
c79b49d5f3
Handle re-establishment next_funding_txid 2024-11-20 14:01:03 +02:00
Duncan Dean
982e25de0e
Handle initial commitment_signed for V2 channels 2024-11-20 14:01:02 +02:00
Duncan Dean
684b3b7244
Introduce InteractiveTxSigningSession for signing interactively constructed txs 2024-11-20 13:57:05 +02:00
Duncan Dean
24ba5848d5
Implement support for accepting V2 channels 2024-11-20 13:57:03 +02:00
Duncan Dean
f71bbb9643
Add features in InteractiveTxConstructor requried for V2 chan accept
1. InteractiveTxConstructorArgs is introduced to act as a single, more
   readable input to InteractiveTxConstructor::new().
2. Various documentation updates.
2024-11-18 15:19:00 +02:00
Duncan Dean
b0dc394505
Remove unused Channel::dual_funding_channel_context
For now this is unneeded as we do not provide any inputs as channel
acceptor and we do not allow creating outbound channels yet. It will
be re-added when that functionality is introduced.
2024-11-18 15:19:00 +02:00
Duncan Dean
bb81598cba
Add interactive tx constructor to all V2-related channel structs
Here we add the `interactive_tx_constructor` field to the `Channel`,
`OutboundV2Channel`, and `InboundV2Channel` structs.
2024-11-18 15:19:00 +02:00
Duncan Dean
7e23afc9a8
Remove dual_funding cfg attributes
We'll only gate public API related to contributing toward an inbound or opening
a dual funded channel.
2024-11-18 15:18:39 +02:00
Duncan Dean
899d5f5ef3
Add dual-funding spec links 2024-11-18 12:43:32 +02:00
Matt Corallo
8da30df223
Merge pull request #3405 from jkczyz/2024-11-bolt11-invoice-utils-follow-up 2024-11-14 21:55:54 +00:00
Matt Corallo
1c5b4c129b
Merge pull request #3355 from TheBlueMatt/2024-10-mon-ids-after-close 2024-11-14 21:53:52 +00:00
Matt Corallo
4582b201ea Avoid startup PeerState entries for peers with unfunded channels
If a peer creates a channel with us which never reaches the funding
stage (or never gets any commitment updates after creation), we'll
avoid inserting the `update_id` into
`closed_channel_monitor_update_ids` at runtime to avoid keeping a
`PeerState` entry around for no reason. However, on startup we
still create a `ChannelMonitorUpdate` with a `ChannelForceClosed`
update step to ensure the `ChannelMonitor` is locked and shut down.

This is pretty redundant, and results in a bunch of on-startup
`ChannelMonitorUpdate`s for any old but non-archived
`ChannelMonitor`s. Instead, here, we check if a `ChannelMonitor`
already saw a `ChannelForceClosed` update step before we generate
the on-startup `ChannelMonitorUpdate`.

This also allows us to skip the `closed_channel_monitor_update_ids`
insertion as we can be confident we'll never have a
`ChannelMonitorUpdate` for this channel at all.
2024-11-14 20:00:23 +00:00
Gursharan Singh
4322b19e61
Merge pull request #3368 from TheBlueMatt/2024-10-decayed-non-null
Don't interpret decayed data as we've failed to send tiny values
2024-11-12 18:50:46 -08:00
Matt Corallo
c99d3d785d Stop using a constant for monitor update_ids after closure
Because `ChannelManager` doesn't have a corresponding `Channel`
after the channels are closed, we'd always used an `update_id` of
`u64::MAX` for any `ChannelMonitorUpdate`s we need to build after
the channel is closed.

This completely breaks the abstraction of `update_id`s and leaks
into persistence logic - because we might have more than one
`ChannelMonitorUpdate` with the same (`u64::MAX`) value, suddenly
instead of being able to safely use `update_id` as IDs, the
`MonitorUpdatingPersister` has to have special logic to handle
this.

Worse, because we don't have a unique ID with which to refer to
post-close `ChannelMonitorUpdate`s we cannot track when they
complete async persistence. This means we cannot properly support
async persist for forwarded payments where the inbound edge has hit
the chain prior to the preimage coming to us.

Here we rectify this by using consistent `update_id`s even after a
channel has closed. In order to do so we have to keep some state
for all channels for which the `ChannelMonitor` has not been
archived (after which point we can be confident we will not need to
update them). While this violates our long-standing policy of
having no state at all in `ChannelManager`s for closed channels,
its only a `(ChannelId, u64)` pair per channel, so shouldn't be
problematic for any of our users (as they already store a whole
honkin `ChannelMonitor` for these channels anyway).

While limited changes are made to the connection-count-limiting
logic, reviewers should carefully analyze the interactions the new
map created here has with that logic.
2024-11-13 01:24:06 +00:00
Matt Corallo
3f36890912 Prefer to use MonitorUpdateRegeneratedOnStartup where possible
In the next commit we'll drop the magic `u64::MAX`
`ChannelMonitorUpdate::update_id` value used when we don't know the
`ChannelMonitor`'s `latest_update_id` (i.e. when the channel is
closed). In order to do so, we will store further information about
`ChannelMonitor`s in the per-peer structure, keyed by the
counterparty's node ID, which will be used when applying
`ChannelMonitorUpdate`s to closed channels.

By taking advantage of the change in the previous commit, that
information is now reliably available when we generate the
`ChannelMonitorUpdate` (when claiming HTLCs), but in order to
ensure it is available when applying the `ChannelMonitorUpdate` we
need to use `BackgroundEvent::MonitorUpdateRegeneratedOnStartup`
instead of
`BackgroundEvent::ClosedMonitorUpdateRegeneratedOnStartup` where
possible.

Here we do this, leaving `ClosedMonitorUpdateRegeneratedOnStartup`
only used to ensure very old channels (created in 0.0.118 or
earlier) which are not in the `ChannelManager` are force-closed on
startup.
2024-11-13 01:24:06 +00:00
Matt Corallo
6f023f8f08 Req the counterparty node id when claiming against a closed chan
Currently we store in-flight `ChannelMonitorUpdate`s in the
per-peer structure in `ChannelManager`. This is nice and simple as
we're generally updating it when we're updating other per-peer
data, so we already have the relevant lock(s) and map entries.

Sadly, when we're claiming an HTLC against a closed channel, we
didn't have the `counterparty_node_id` available until it was
added in 0.0.124 (and now we only have it for HTLCs which were
forwarded in 0.0.124). This means we can't look up the per-peer
structure when claiming old HTLCs, making it difficult to track the
new `ChannelMonitorUpdate` as in-flight.

While we could transition the in-flight `ChannelMonitorUpdate`
tracking to a new global map indexed by `OutPoint`, doing so would
result in a major lock which would be highly contended across
channels with different peers.

Instead, as we move towards tracking in-flight
`ChannelMonitorUpdate`s for closed channels we'll keep our existing
storage, leaving only the `counterparty_node_id` issue to contend
with.

Here we simply accept the issue, requiring that
`counterparty_node_id` be available when claiming HTLCs against a
closed channel. On startup, we explicitly check for any forwarded
HTLCs which came from a closed channel where the forward happened
prior to 0.0.124, failing to deserialize, or logging an warning if
the channel is still open (implying things may work out, but panics
may occur if the channel closes prior to HTLC resolution).

While this is a somewhat dissapointing resolution, LDK nodes which
forward HTLCs are generally fairly well-upgraded, so it is not
anticipated to be an issue in practice.
2024-11-13 01:24:06 +00:00
Matt Corallo
70add1448b
Merge pull request #3264 from jkczyz/2024-08-remove-user-provided-payer-id
Disallow user-provided `payer_signing_pubkey`
2024-11-12 20:23:45 +00:00
Jeffrey Czyz
20ef217985
Expand Bolt11InvoiceParameters docs for no-std use 2024-11-12 12:28:52 -06:00
Jeffrey Czyz
e9051f84f2
Explain no-std Bolt11Invoice::duration_since_epoch 2024-11-12 12:24:52 -06:00
Matt Corallo
8e941426cf Add a lightning-dns-resolver crate which answers bLIP 32 queries
When a lightning node wishes to send payments to a BIP 353 human
readable name (using BOLT 12), it first has to resolve that name to
a DNS TXT record. bLIP 32 defines a way to do so over onion
messages, and this completes our implementation thereof by adding
the server side.

It operates by simply accepting new messages and spawning tokio
tasks to do DNS lookups using the `dnsse_prover` crate. It also
contains full end-to-end tests of the BIP 353 -> BOLT 12 -> payment
logic using the new server code to do the resolution.

Note that because we now have a workspace crate which sets the
"lightning/dnssec" feature in its `dev-dependencies`, a naive
`cargo test` will test the "dnssec" feature.
2024-11-12 15:53:35 +00:00
Matt Corallo
2bbb3b7083 Use ChannelManager as DNSResolverMessageHandler by default
Now that `ChannelManager` supports using bLIP 32 to resolve BIP 353
Human Readable Names we should encourage users to use that feature
by making the "default" (in various type aliases) to use
`ChannelManager` as the `DNSResolverMessageHandler`.
2024-11-12 15:53:35 +00:00
Matt Corallo
99d00930a4 Support paying Human Readable Names directly from ChannelManager
Now that we have the ability to resolve BIP 353 Human Readable
Names directly and have tracking for outbound payments waiting on
an offer resolution, we can implement full BIP 353 support in
`ChannelManager`.

Users will need one or more known nodes which offer DNS resolution
service over onion messages using bLIP 32, which they pass to
`ChannelManager::pay_for_offer_from_human_readable_name`, as well
as the `HumanReadableName` itself.

From there, `ChannelManager` asks the DNS resolver to provide a
DNSSEC proof, which it verifies, parses into an `Offer`, and then
pays.

For those who wish to support on-chain fallbacks, sadly, this will
not work, and they'll still have to use `OMNameResolver` directly
in order to use their existing `bitcoin:` URI parsing.
2024-11-12 15:53:34 +00:00
Matt Corallo
8d8416b956 Store the source HumanReadableName in InvoiceRequestFields
When we receive a payment to an offer we issued resolved with a
human readable name, it may have been resolved using a wildcard
DNS entry which we want to map to a specific recipient account
locally. To do this, we need the human readable name from the
`InvoiceRequest` in the `PaymentClaim{able,ed}`, which we pipe
through here using `InvoiceRequestFields`.
2024-11-12 15:53:12 +00:00
Matt Corallo
e447b49136 Add support for storing a source HRN in BOLT 12 invoice_requests
When we resolve a Human Readable Name to a BOLT 12 `offer`, we may
end up resolving to a wildcard DNS name covering all possible
`user` parts. In that case, if we just blindly pay the `offer`, the
recipient would have no way to tell which `user` we paid.

Instead, BOLT 12 defines a field to include the HRN resolved in the
`invoice_request`, which we implement here.

We also take this opportunity to remove constant parameters from
the `outbound_payment.rs` interface to `channelmanager.rs`
2024-11-12 15:53:12 +00:00
Matt Corallo
46df35b0ff Add a new AwaitingOffer outbound payment state for BIP 353 2024-11-12 15:53:12 +00:00
Matt Corallo
a39e274e3d Skip the implicit trailing . in HumanReadableName's domain
Domain names implicitly have a trailing `.`, which we require in
bLIP 32 but generally shouldn't be exposing to the user in
`HumanReadableName`s (after all, they're human-readable). Here we
make sure the trailing `.` is dropped in `HumanReadableName`s
before we re-add them when building the bLIP 32 messages.
2024-11-12 15:53:12 +00:00
Matt Corallo
b0bd4371d9
Merge pull request #3383 from valentinewallace/2024-09-blinded-keysend-verify
Verify blinded keysend payments
2024-11-12 15:00:46 +00:00
Jeffrey Czyz
716758f5a3
Fix incorrect expect message 2024-11-11 16:32:28 -06:00
Jeffrey Czyz
c331b67137
Remove NodeSigner::sign_bolt12_invoice_request
Now that invoice requests are signed using transient keys only, remove
the corresponding signing method from NodeSigner since it is never used.
2024-11-11 16:18:11 -06:00
Jeffrey Czyz
5af0cf1c04
Remove PayerSigningPubkeyStrategy
Now that InvoiceRequest::payer_signing_pubkey is always a derived
pubkey, there is no longer a need for PayerSigningPubkeyStrategy.
2024-11-11 16:18:11 -06:00