Commit graph

8468 commits

Author SHA1 Message Date
Valentine Wallace
708e8b538d
Tests: DRY failing a blinded HTLC backwards
Blinded HTLCs are always failed back with the same error, so DRY the test code
that fails them backwards. This util will also be used for async payments
testing in upcoming commits.
2025-01-24 12:39:33 -05:00
valentinewallace
a706159fe3
Merge pull request #2933 from wpaulino/enable-decode-htlc-onion-until-committed
Enable decoding HTLC onions when fully committed
2025-01-24 11:46:53 -05:00
Elias Rohrer
8307cc6763
Merge pull request #3531 from valentinewallace/2025-01-fix-buggy-route-err 2025-01-24 16:36:28 +01:00
Matt Corallo
8257cc361c
Merge pull request #3457 from arik-so/min_relay_fee_fix
Fix min relay fee to be 1s/vB
2025-01-23 22:31:25 +00:00
Valentine Wallace
e479317860
Unify session_priv removal on PaymentSendFailure
When an outbound payment fails while paying to a route, we need to remove the
session_privs for each failed path in the outbound payment.

Previously we were sometimes removing in pay_route_internal and sometimes in
handle_pay_route_err, so refactor this so we always remove in
handle_pay_route_err.
2025-01-23 17:20:04 -05:00
Arik Sosman
8fd2dee01c
Test fee rate bumping
Create some tests for various `feerate_bump` scenarios and ensure
among other thigns that there are no underflows.
2025-01-23 12:22:28 -08:00
Arik Sosman
54a5cd6736
Fix incremental relay fee to be 1s/vB
Bitcoin Core relay policy does not require 16s/vB, which it was
previously set to.
2025-01-23 12:22:28 -08:00
Arik Sosman
da769eeb70
Consider dust threshold for fee rate determination
Previously, the `feerate_bump` method did not enforce the dust
threshold, which could result in us thinking we had raised the fee
rate without actually having done so. Instead,
`compute_package_output` blindly accepted the updated fee rate while
enforcing a non-dust output value, resulting in repeated broadcast
attempts of an identical transaction.
2025-01-23 12:22:27 -08:00
Elias Rohrer
bd85a29fe3
Merge pull request #3555 from tnull/2025-01-add-fuzz-cfg-lints
Add `check-cfg` lint to `fuzz` to quiet warnings
2025-01-23 10:50:59 +01:00
Elias Rohrer
8cee3bb69d
Add check-cfg lint to fuzz to quiet warnings
Previously, the fuzzer would complain about unknown `cfg` flags. Here,
we add them to the list of allowed flags to quiet the many warnings.
2025-01-22 15:27:56 +01:00
valentinewallace
3d2b4de339
Merge pull request #3552 from TheBlueMatt/2025-01-3323-followups
`utils` cleanups
2025-01-21 13:14:12 -05:00
Arik Sosman
2aabf786e4
Rename min relay fee to incremental relay fee 2025-01-21 06:14:15 -08:00
Matt Corallo
bc7631fe39 Clean up some spurious test_utils/transaction_utils variables
PR #3323 introduced some extra variables to avoid `rustfmt` making
a total mess of our code, but introduced a few that don't make
`rustfmt` do dumb things, which we remove here.
2025-01-20 19:24:58 +00:00
Matt Corallo
8e9ad555ab Import types we use in test_utils
`test_utils` is ancient and didn't import common types like
`ChannelMonitor` for some reason. Here we do that, cleaning up
some code.
2025-01-20 19:24:34 +00:00
Matt Corallo
86308e19e0
Merge pull request #3323 from tnull/2024-09-rustfmt-util
`rustfmt`: Run on `util/*` (2/2)
2025-01-20 19:10:45 +00:00
Elias Rohrer
5d6eaec9ff
rustfmt: Drop remaining util files from exclusion list 2025-01-20 10:54:55 +01:00
Elias Rohrer
ce50c41791
rustfmt: Drop util/mod.rs from exclusion list 2025-01-20 10:54:55 +01:00
Elias Rohrer
50356381c5
rustfmt: Run on util/mod.rs 2025-01-20 10:54:55 +01:00
Elias Rohrer
e2aca6ba74
rustfmt: Drop util/wakers.rs from exclusion list 2025-01-20 10:54:55 +01:00
Elias Rohrer
c349d7997e
rustfmt: Run on util/wakers.rs 2025-01-20 10:54:54 +01:00
Elias Rohrer
8e8c925577
rustfmt: Drop util/transaction_utils.rs from exclusion list 2025-01-20 10:54:54 +01:00
Elias Rohrer
b9fc8ba9aa
rustfmt: Run on util/transaction_utils.rs 2025-01-20 10:54:54 +01:00
Elias Rohrer
2be14b3ef5
rustfmt: Prepare util/transaction_utils.rs 2025-01-20 10:54:54 +01:00
Elias Rohrer
f2bc902507
rustfmt: Drop util/time.rs from exclusion list 2025-01-20 10:54:54 +01:00
Elias Rohrer
5a2731640d
rustfmt: Run on util/time.rs 2025-01-20 10:54:54 +01:00
Elias Rohrer
767646cdad
rustfmt: Drop util/test_utils.rs from exclusion list 2025-01-20 10:54:54 +01:00
Elias Rohrer
12fc953b27
rustfmt: Run on util/test_utils.rs 2025-01-20 10:54:53 +01:00
Elias Rohrer
14da64bdd8
rustfmt: Prepare util/test_utils.rs
.. we pull out `Mutex` field initialization into dedicated variables as
they might otherwise land on the same line when formatting, which might
lead to lockorder violation false-positives when compiled with the
`backtrace` feature.
2025-01-20 10:54:53 +01:00
Elias Rohrer
8f335e0ee6
rustfmt: Drop util/test_channel_signer.rs from exclusion list 2025-01-20 10:54:53 +01:00
Elias Rohrer
fe53ac9dca
rustfmt: Run on util/test_channel_signer.rs 2025-01-20 10:54:52 +01:00
Elias Rohrer
f4f95353db
rustfmt: Drop util/ser_macros.rs from exclusion list 2025-01-20 10:54:40 +01:00
Elias Rohrer
1cc309dd8b
rustfmt: Run on util/ser_macros.rs 2025-01-20 10:54:40 +01:00
Elias Rohrer
4568db8995
rustfmt: Prepare util/ser_macros.rs 2025-01-20 10:54:40 +01:00
Elias Rohrer
74d57dce0f
rustfmt: Drop util/ser.rs from exclusion list 2025-01-20 10:54:39 +01:00
Elias Rohrer
d436cf88e0
rustfmt: Run on util/ser.rs 2025-01-20 10:54:39 +01:00
Elias Rohrer
a8a516263a
rustfmt: Drop util/scid_utils.rs from exclusion list 2025-01-20 10:54:39 +01:00
Elias Rohrer
0fc48771eb
rustfmt: Run on util/scid_utils.rs 2025-01-20 10:54:39 +01:00
Matt Corallo
aa2c6fed24
Merge pull request #3408 from valentinewallace/2024-11-async-receive-offer-utils
Add static invoice creation utils to `ChannelManager`
2025-01-17 15:12:14 +00:00
Wilmer Paulino
d8d9dc7d78
Enable decoding new incoming HTLC onions when fully committed
This commit ensures all new incoming HTLCs going forward will have their
onion decoded when they become fully committed to decide how we should
proceed with each one. As a result, we'll obtain `HTLCHandlingFailed`
events for _any_ failed HTLC that comes across a channel.

Previously, we would evaluate the incoming HTLC within
`can_accept_incoming_htlc` upon receiving it, but not yet committed, so
we'd always have to account for it ourselves manually when checking
certain HTLC limits. With this change, we no longer need to do so as it
will already be accounted for within the pending HTLC stats computation.

We will now start writing channels with the new serialization version
(4), and we will still be able to downgrade back to the commit that
introduced it since reading version 4 is supported.

Note that existing pending inbound HTLCs may already have their
resolution if they were received in a previous version of LDK. We must
support those until we no longer allow downgrading beyond this commit.
2025-01-16 14:31:14 -08:00
Valentine Wallace
b2269f4df8
Fix outbound payments memory leak on buggy router
Prior to this patch, if we attempted to send a payment or probe to a buggy
route, we would error but continue storing the pending outbound payment
forever. Attempts to retry would result in a “duplicate payment” error.

In the case of ChannelManager::send_payment, we would also fail to generate a
PaymentFailed event, even if the user manually called abandon_payment.

This bug is unlikely to have ever been hit in the wild as most users use LDK’s
router. Discovered in the course of adding a new send_to_route API.

Now, we’ll properly generate events and remove the outbound from storage.
2025-01-16 11:01:40 -05:00
Matt Corallo
3fbf97d75f
Merge pull request #3530 from TheBlueMatt/2025-01-0.1-relnotes
Add draft 0.1 release notes
2025-01-15 21:55:04 +00:00
Matt Corallo
2c5a1f67b6
Merge pull request #3544 from valentinewallace/2025-01-fix-build
Fix build for `cfg(async_payments)`
2025-01-15 21:42:15 +00:00
Valentine Wallace
c6f276887f
Outbound payments: pass session privs by reference
We need to stop passing this Vec by value for the next commit so we can pass it
to a different method.
2025-01-15 16:29:53 -05:00
Valentine Wallace
4e3f8d7f18
Fix build for cfg(async_payments)
Static invoices don't have an amount_msats field.
2025-01-15 14:51:20 -05:00
Matt Corallo
5d1b6e0710 Add draft 0.1 release notes 2025-01-15 18:28:58 +00:00
Matt Corallo
6d604c52b2
Merge pull request #3535 from jkczyz/2025-01-invoice-amount
Validate `amount_msats` against invreq amount
2025-01-15 17:55:10 +00:00
Jeffrey Czyz
c2360be049
Add InvoiceRequest::has_amount_msats
When InvoiceRequest::amount_msats returns Some, it may have been
inferred from the Offer::amount and InvoiceRequest::quantity. Add a
method to InvoiceRequest for determining if the amount was explicitly
set.
2025-01-15 11:23:32 -06:00
Ian Slane
99889d27fd
Validate amount_msats against invreq amount
Add a check to ensure that the amount_msats in an invoice matches the
amount_msats specified in the invoice_request or offer (or refund).
Reject the invoice as invalid if there is a mismatch between these
amounts. Otherwise, an invoice may be paid with an amount greater than
the requested amount.

Co-authored-by: Ian Slane <slaneian@gmail.com>
Co-authored-by: Jeffrey Czyz <jkczyz@gmail.com>
2025-01-15 11:23:32 -06:00
Matt Corallo
bcbff6546f
Merge pull request #3533 from tnull/2025-01-allow-setting-process-callback-in-c-bindings
`liquidity`: Allow setting `process_events` callback in `c_bindings`
2025-01-15 14:11:38 +00:00
Elias Rohrer
e05b76af7b
liquidity: Allow setting process_events callback in c_bindings
To trigger message processing, we previously had the user set a callback
to `PeerManager::process_events` via an `Fn()` callback. This is however
not supported by `c_bindings`.

Here, we therefore introduce as `ProcessMesssagesCallback` trait that
can be used via `LiquidityManager::set_process_msgs_callback_fn`, which
is exposed in `c_bindings`.
2025-01-15 09:58:43 +01:00