Commit graph

5397 commits

Author SHA1 Message Date
Valentine Wallace
d574de95f5
Include invreq in payment onion when retrying async payments
While in the last commit we began including invoice requests in async payment
onions on initial send, further work is needed to include them on retry. Here
we begin storing invreqs in our retry data, and pass them along for inclusion
in the onion on payment retry.

Per BOLTs PR 1149, when paying a static invoice we need to include our original
invoice request in the HTLC onion since the recipient wouldn't have received it
previously.
2024-10-30 16:17:57 -04:00
Valentine Wallace
925a0cb38b
Include invreq in payment onion when sending async payments
Past commits have set us up to include invoice requests in outbound async
payment onions. Here we actually pull the invoice request from where it's
stored in outbound_payments and pass it into the correct utility for inclusion
in the onion on initial send.

Per BOLTs PR 1149, when paying a static invoice we need to include our original
invoice request in the HTLC onion since the recipient wouldn't have received it
previously.
2024-10-30 16:17:55 -04:00
Valentine Wallace
520ae0b1f4
Store invreqs in StaticInvoiceReceived outbound payments
When transitioning outbound payments from AwaitingInvoice to
StaticInvoiceReceived, include the invreq in the new state's outbound payment
storage for future inclusion in an async payment onion.

Per BOLTs PR 1149, when paying a static invoice we need to include our original
invoice request in the HTLC onion since the recipient wouldn't have received it
previously.
2024-10-30 16:17:51 -04:00
Valentine Wallace
fead88faed
Support including invreqs when paying to a route
Add a new invoice request parameter to outbound_payments and channelmanager
send-to-route internal utils. As of this commit the invreq will always be
passed in as None, to be updated in future commits.

Per BOLTs PR 1149, when paying a static invoice we need to include our original
invoice request in the HTLC onion since the recipient wouldn't have received it
previously.
2024-10-30 16:17:41 -04:00
Valentine Wallace
6a424536ac
Support including invreqs when building payment onions
Add a new invoice request parameter to onion_utils::create_payment_onion. As of
this commit it will always be passed in as None, to be updated in future
commits.

Per BOLTs PR 1149, when paying a static invoice we need to include our original
invoice request in the HTLC onion since the recipient wouldn't have received it
previously.
2024-10-30 16:17:32 -04:00
Valentine Wallace
9b3e30707e
Support including invreqs when building onion payloads
Add a new invoice request parameter to onion_utils::build_onion_payloads.
As of this commit it will always be passed in as None, to be updated in future
commits.

Per BOLTs PR 1149, when paying a static invoice we need to include our original
invoice request in the HTLC onion since the recipient wouldn't have received it
previously.
2024-10-30 16:17:20 -04:00
Valentine Wallace
a80af56af7
Support encoding invreqs in outbound onion payloads
Per BOLTs PR 1149, when paying a static invoice we need to include our original
invoice request in the HTLC onion since the recipient wouldn't have received it
previously.

We use an experimental TLV type for this new onion payload field, since the
spec is still not merged in the BOLTs.
2024-10-30 16:17:12 -04:00
Valentine Wallace
639446ad63
Stop taking &self in outbound_payments' create_inbound_payment
The method doesn't actually use its &self parameter, and this makes it more
obvious that we aren't going to deadlock by calling the method if the
outbound_payments lock is already acquired.
2024-10-30 16:14:03 -04:00
Valentine Wallace
2ff6524da4
Prefix AsyncPaymentsMessageHandler methods with handle_*
"Release" is overloaded in the trait's release_pending_messages method, since
the latter releases pending async payments onion messages to the peer manager,
vs the release_held_htlc method handles the release_held_htlc onion message by
attempting to send an HTLC to the recipient.
2024-10-30 16:14:03 -04:00
Valentine Wallace
88d689a323
Update docs for PaymentFailureReason::RouteNotFound
Since we started using this error in send_payment_for_bolt12_invoice, this
error type is no longer only used on retry but also on initial send.
2024-10-30 16:13:59 -04:00
Valentine Wallace
3945bf86f9
Add new PaymentFailureReason::BlindedPathCreationFailed
RouteNotFound did not fit here because that error is reserved for failing to
find a route for a payment, whereas here we are failing to create a blinded
path back to ourselves..
2024-10-30 16:13:56 -04:00
Matt Corallo
206ab82c02
Merge pull request #3007 from arik-so/arik/trampoline/2024-04-trampoline-blinded-hop-serialization
Serialize blinded Trampoline hops
2024-10-23 21:52:10 +00:00
Arik Sosman
d111981e13
Test non-legacy blinded Trampoline payloads. 2024-10-23 13:06:35 -07:00
Arik Sosman
9c9a31cd35
Add non-legacy blinded Trampoline payloads. 2024-10-23 13:06:35 -07:00
Arik Sosman
f6b3004659
Test blinded Trampoline payload serialization. 2024-10-23 13:06:35 -07:00
Arik Sosman
477216e7b1
Serialize blinded path forwards in Trampoline onions. 2024-10-23 13:06:35 -07:00
Matt Corallo
3c868dd311
Merge pull request #3142 from TheBlueMatt/2024-06-robust-updates
Reliably deliver gossip messages from our `ChannelMessageHandler`
2024-10-23 00:12:03 +00:00
Matt Corallo
b2bcfca30e
Merge pull request #3376 from yellowred/yellowred/monitor_update_name_pub
Make monitor update name public
2024-10-22 17:13:05 +00:00
olegkubrakov
01529dcba6 Make monitor update name public
These structs are meant for MonitoringUpdatingPersister implementation, but some
external implementations may still reuse them, so going to make them public.
2024-10-22 10:03:51 -07:00
G8XSU
2e118415e0
Implement to_lower_hex() Display/Debug for OfferId. 2024-10-21 15:41:42 -07:00
G8XSU
c75730a55f
Implement to_lower_hex() Display/Debug for PaymentId. 2024-10-21 15:40:02 -07:00
Matt Corallo
260322ea72
Merge pull request #3370 from dunxen/2024-10-dry-funding-created-signed
DRY `funding_created()` and `funding_signed()` for V1 channels
2024-10-21 19:25:18 +00:00
Duncan Dean
2db1aa27b6
DRY funding_created() and funding_signed() for V1 channels
There is a decent amount of shared code in these two methods so we make
an attempt to share that code here by introducing the
`InitialRemoteCommitmentReceiver` trait. This trait will also come in
handy when we need similar commitment_signed handling behaviour for
dual-funded channels.
2024-10-21 16:25:22 +02:00
Matt Corallo
1e0f43f108
Merge pull request #3356 from jkczyz/2024-10-inflight-scoring
Don't over-penalize channels with inflight HTLCs
2024-10-19 13:41:11 +00:00
Jeffrey Czyz
0305000850
Use total_inflight_amount_msat for probability fns
Rename parameters used when calculating success probability to make it
clear that the total mount in-flight should be used rather than the
payment amount.
2024-10-18 18:28:40 -05:00
Jeffrey Czyz
572fab7591
Correct comments in avoids_saturating_channels 2024-10-18 18:28:40 -05:00
Jeffrey Czyz
7fa6770a7a
Correct base_penalty_amount_multiplier_msat docs
Commit df52da7b31 modified
ProbabilisticScorer to apply some penalty amount multipliers to the
total amount flowing over the channel. However, the commit updated the
docs for base_penalty_amount_multiplier_msat even though that behavior
didn't change. This commit reverts those docs.
2024-10-18 18:28:40 -05:00
Jeffrey Czyz
866588c20f
Don't over-penalize channels with inflight HTLCs
Commit df52da7b31 modified
ProbabilisticScorer to apply some penalty amount multipliers (e.g.,
liquidity_penalty_amount_multiplier_msat) to the total amount flowing
over the channel (i.e., including inflight HTLCs), not just the payment
in question. This led to over-penalizing in-use channels. Instead, only
apply the total amount when calculating success probability.
2024-10-18 18:28:40 -05:00
Gursharan Singh
608209ef19
Merge pull request #3359 from TheBlueMatt/2024-10-less-types-re-export
Remove deprecated re-exports
2024-10-18 14:35:49 -07:00
Matt Corallo
c5be7aa285
Merge pull request #3297 from TheBlueMatt/2024-09-cleanup-package
Cleanup `PackageTemplate`a bit
2024-10-18 17:44:29 +00:00
Matt Corallo
20db790c53 Add a test for the fee-bump rate of timeout HTLC claims on cp txn
In a previous commit we updated the fee-bump-rate of claims against
HTLC timeouts on counterparty commitment transactions so that
instead of immediately attempting to bump every block we consider
the fact that we actually have at least `MIN_CLTV_EXPIRY_DELTA`
blocks to do so, and bumping at the appropriate rate given that.

Here we test that by adding an extra check to an existing test
that we do not bump in the very next block after the HTLC timeout
claim was initially broadcasted.
2024-10-18 16:23:27 +00:00
Matt Corallo
6ae33dc1e0 Set correct counterparty_spendable_height for outb local HTLCs
For outbound HTLCs, the counterparty can spend the output
immediately. This fixes the `counterparty_spendable_height` in the
`PackageTemplate` claiming outbound HTLCs on local commitment
transactions, which was previously spuriously set to the HTLC
timeout (at which point *we* can claim the HTLC).
2024-10-18 16:23:27 +00:00
Matt Corallo
b5b38603fd Stop exporting lightning::ln::features
Now that the module only contains some implementations of
serialization for the `lightning_types::features` structs, there's
no reason for it to be public.
2024-10-17 19:39:12 +00:00
Matt Corallo
f4b23115f6 Add a test of gossip message buffer limiting in PeerManager
This adds a simple test that the gossip message buffer in
`PeerManager` is limited, including the new behavior of bypassing
the limit when the broadcast comes from the
`ChannelMessageHandler`.
2024-10-17 19:09:15 +00:00
Matt Corallo
21904ffcb5 Add a constructor for the test SocketDescriptor and hang_writes
In testing, its useful to be able to tell the `SocketDescriptor` to
pretend the system network buffer is full, which we add here by
creating a new `hang_writes` flag. In order to simplify
constructing, we also add a new constructor which existing tests
are moved to.
2024-10-17 19:09:15 +00:00
Matt Corallo
bcad2571ac Fix the establish_connection utility method for a 2nd connection
The `establish_connection` method should work for more than one
connection per `PeerManager`, which we fix here.
2024-10-17 19:09:15 +00:00
Matt Corallo
1b711ed15f Reliably deliver gossip messages from our ChannelMessageHandler
When our `ChannelMessageHandler` creates gossip broadcast
`MessageSendEvent`s, we generally want these to be reliably
delivered to all our peers, even if there's not much buffer space
available.

Here we do this by passing an extra flag to `forward_broadcast_msg`
which indicates where the message came from, then ignoring the
buffer-full criteria when the flag is set.
2024-10-17 19:09:15 +00:00
Matt Corallo
d557334e31 Rename soonest_conf_deadline to counterparty_spendable_height
This renames the field in `PackageTemplate` which describes the
height at which a counterparty can make a claim to an output to
match its actual use.

Previously it had been set based on when a counterparty can claim
an output but also used for other purposes. In the previous commit
we cleaned up its use for fee-bumping-rate, so here we can rename
it as it is now only used as the `counteraprty_spendable_height`.
2024-10-17 18:34:33 +00:00
Matt Corallo
be915872c5 Clean up PackageTemplate::get_height_timer to consider type
`PackageTemplate::get_height_timer` is used to decide when to next
bump our feerate on claims which need to make it on chain within
some window. It does so by comparing the current height with some
deadline and increasing the bump rate as the deadline approaches.

However, the deadline used is the `counterparty_spendable_height`,
which is the height at which the counterparty might be able to
spend the same output, irrespective of why. This doesn't make sense
for all output types, for example outbound HTLCs are spendable by
our counteraprty immediately (by revealing the preimage), but we
don't need to get our HTLC timeout claims confirmed immedaitely,
as we actually have `MIN_CLTV_EXPIRY` blocks before the inbound
edge of a forwarded HTLC becomes claimable by our (other)
counterparty.

Thus, here, we adapt `get_height_timer` to look at the type of
output being claimed, and adjust the rate at which we bump the fee
according to the real deadline.
2024-10-17 18:34:33 +00:00
Matt Corallo
303a0c9a4e Stop passing current height to PackageTemplate::build_package
Now that we don't store the confirmation height of the inputs
being spent, passing the current height to
`PackageTemplate::build_package` is useless - we only use it to set
the height at which we should next bump the fee, but we just want
it to be "next block", so we might as well use `0` and avoid the
extra argument. Further, in one case we were already passing `0`,
so passing the argument is just confusing as we can't rely on it
being set.

Note that this does remove an assertion that we never merge
packages that were crated at different heights, and in the future
we may wish to do that (as there's no specific reason not to), but
we do not currently change the behavior.
2024-10-17 18:34:33 +00:00
Matt Corallo
8c4794df87 Drop unused PackageTemplate::height_original
This has never been used, and its set to a fixed value of zero for
HTLCs on local commitment transactions making it impossible to rely
on so might as well remove it.
2024-10-17 18:34:33 +00:00
Matt Corallo
4a7b01aea7
Merge pull request #3371 from tnull/2024-10-allow-to-set-payment-and-description-hash
Invoice utils: allow to set both description hash and payment hash
2024-10-17 15:33:22 +00:00
Matt Corallo
a19edbc32d Rename PackageTemplate::timelock counteraprty_spendable_height
This function was very confusing - its used to determine by when
we have to stop aggregating this claim with others as it starts to
be at risk of pinning due to the counterparty's ability to spend
the output.

It is not ever used as a timelock for a transaction, and thus its
name is very confusing.

Instead we rename it `counterparty_spendable_height`.
2024-10-16 21:04:48 +00:00
Matt Corallo
2f549eeb80 Rename claim cleaning match bool for accuracy
We don't actually care if a confirmed transaction claimed other
outputs, only that it claimed a superset of the outputs in the
pending claim we're looking at. Thus, the variable to detect that
is renamed `is_claim_subset_of_tx` instead of `are_sets_equal`.
2024-10-16 21:04:48 +00:00
Elias Rohrer
43fd78b0b9
Invoice utils: allow to set both description hash and payment hash 2024-10-16 17:04:38 +02:00
optout
f22b011f93 Signer extended with method to sign prev funding transaction input 2024-10-15 23:13:14 +02:00
Gursharan Singh
0db051b75a
Merge pull request #3329 from arik-so/monitor_archive_docs_followup
Document monitor archival idempotency requirement (#3276 followup)
2024-10-15 13:54:46 -07:00
Matt Corallo
57dcc7d762 Deprecate the lightning::util::string re-export from types
Like we've done for `features` and `payment`, here we mark the
`lightning::util::string` re-export as deprecated.
2024-10-15 14:33:03 +00:00
Matt Corallo
50b5a6efa7 Drop the Payment{Hash,Preimage,Secret} re-exports in lightning
These re-exports were deprecated in 0.0.124 in favor of the
`lightning::types::payment::*` paths, which we use here.
2024-10-15 14:33:03 +00:00
Matt Corallo
64c12431b7 Drop lightning::ln::features::* type aliases
These were deprecated in 0.0.124, and we drop them here in favor of
`lightning::types::features::*`.
2024-10-13 13:52:56 +00:00