Commit Graph

8060 Commits

Author SHA1 Message Date
Valentine Wallace
9cc6969314
Verify blinded keysend payment secrets
If we're receiving a keysend to a blinded path, then we created the payment
secret within. Using our inbound_payment_key, we can decrypt the payment secret
bytes to get the payment's min_cltv_expiry_delta and min amount, to verify the
payment is valid. However, if we're receiving an MPP keysend *not* to a blinded
path, then we did not create the payment secret and shouldn't verify it since
it's only used to correlate MPP parts.

Therefore, store whether the payment secret is recipient-generated in our pending
inbound payment data so we know whether to verify it or not.
2024-11-08 17:08:27 -05:00
Valentine Wallace
34c2f25806
Support verifying payment_secrets for inbound static invoice payments
Add a new payment type for this, because normally the payment hash is factored
into the payment secrets we create for invoices, but static invoices don't have
a payment hash since they are paid via keysend.
2024-11-08 10:28:53 -05:00
Valentine Wallace
45f88ee7f9
Add new inbound payment key for spontaneous payments
This key will be used in upcoming commits for encrypting metadata bytes for
spontaneous payments' payment secrets, to be included in the blinded paths of
static invoices for async payments. We need a new type of payment secret for
these payments because they don't have an a prior known payment hash, see the
next commit.
2024-11-08 10:28:53 -05:00
Valentine Wallace
02316d28f1
Remove pending_inbound_payments map from ChannelManager
LDK versions prior to 0.0.104 had stateful inbound payments written in this
map. In 0.0.104, we added support for stateless inbound payments with
deterministically generated payment secrets, and maintained deprecated support
for stateful inbound payments until 0.0.116. After 0.0.116, no further inbound
payments could have been written into this map.
2024-11-08 10:28:29 -05: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
e0838be5e4
Merge pull request #3379 from arik-so/exclude-windows-msrv
Skip MSRV on Windows in CI
2024-10-23 13:53:18 +00: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
Arik Sosman
3d50b1d83b
Skip MSRV on Windows in CI 2024-10-22 13:09:24 -07: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
Matt Corallo
6104eb0c6e
Merge pull request #3377 from G8XSU/hex-impls
Implement to_lower_hex() Display/Debug for PaymentId & OfferId
2024-10-22 13:55:34 +00:00
Gursharan Singh
66e445811b
Merge pull request #3267 from arik-so/rgs_metrics_2024-08
Update RGS stats for August 2024.
2024-10-21 16:15:43 -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
Arik Sosman
2c1e828922
Update processing times for iPhone. 2024-10-21 15:04:27 -07:00
Arik Sosman
160de118a5
Update RGS stats for August 2024. 2024-10-21 15:04:27 -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
81923c7340
Merge pull request #3330 from tnull/2024-09-add-macros-crate
Add `lightning-macros` crate and drop `bdk_macros` dependency
2024-10-17 15:34:18 +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
Elias Rohrer
99ae425cad
Update lightning-transaction-sync to use macros crate 2024-10-17 16:26:42 +02:00
Elias Rohrer
0aed2b9c44
Add lightning-macros crate
Previously, we used the `bdk_macros` dependency for some simple proc
macros in `lightning-transaction-sync`. However, post-1.0 BDK doesn't
further maintain this crate and will at some point probably yank it
together with the old `bdk` crate that was split up.

Here, we create a new crate for utility proc macros and ~~steal~~ add
what we currently use (slightly modified for the latest `syn` version's
API though). In the future we may want to expand this crate, e.g., for
some `maybe_async` macros in the context of an `async KVStore`
implementation.
2024-10-17 16:26:41 +02: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
Matt Corallo
d4e8b4994d
Merge pull request #3316 from optout21/signer_extend
[Splicing] Signer extended with method to sign prev funding transaction input
2024-10-16 18:43:09 +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