Commit graph

2854 commits

Author SHA1 Message Date
Matt Corallo
c86cacd29d
Merge pull request #2625 from tnull/2023-09-moar-tests-n-fixes
Improve test coverage of #2575 router fixes
2023-10-15 20:18:56 +00:00
Vladimir Fomene
33715e87d8
fix: use the update_add_htlc's cltv_expiry for comparison
As noted in BOLT 4, we should be using the update_add_htlc's cltv_expiry,
not the CLTV expiry set by the sender in the onion for this comparison.
See here: 4dcc377209/04-onion-routing.md (L334)
2023-10-13 14:05:21 +03:00
Fedeparma74
7cdb31ae20 Fix deadlock when closing an unavailable channel 2023-10-11 10:50:28 +02:00
valentinewallace
1f1a8dd5c5
Merge pull request #2651 from G8XSU/rm-same-feerate-log
Remove log for not changing feerate when it was equal
2023-10-06 13:18:32 -10:00
Gursharan Singh
2ee554a1c4
Remove log for not changing feerate when it was equal
Log is not required in this case and creates unnecessary log lines at
trace level.
2023-10-05 15:19:36 -10:00
Matt Corallo
eea19de198
Merge pull request #2640 from sr-gi/20231003-expose-from-be-bytes
Makes Features::from_be_bytes public
2023-10-05 23:45:59 +00:00
Sergi Delgado Segura
2b1d6937a8 Makes Features::from_be_bytes public
Downstream projects building Feature<T> are most likely doing so with a
big-endian byte array, however only `from_le_bytes` is exposed.
2023-10-05 15:27:13 -04:00
Matt Corallo
7aefa3131c
Merge pull request #2631 from TheBlueMatt/2023-09-pm-no-refs-reqd
Fix `Simple*PeerManager` to not require refs to the `UtxoLookup`
2023-10-03 17:12:19 +00:00
Matt Corallo
0b4bb24af8 Clean up at least some lifetimes on SimpleRefPeerManager
Rather than simply a, b, c, d...we at least use names for a few
things, also splitting the reused 'f lifetime.
2023-10-03 04:36:25 +00:00
Matt Corallo
04841acb86
Merge pull request #2595 from TheBlueMatt/2023-09-117-bindings-part1
Various cleanups to make bindings generation simpler
2023-10-03 03:56:46 +00:00
Matt Corallo
a938fecc00
Merge pull request #2632 from TheBlueMatt/2023-09-writeable-rwlock
Implement Readable/Writeable for RwLock wrappers
2023-10-03 03:45:03 +00:00
Matt Corallo
6ce4c6cbc5 Mark AChannelManager no-export
The trait itself has no purpose for bindings, as all structs are
concretized anyway. Further, the bindings have specific handling
for generic bounding traits like this.
2023-10-01 00:05:01 +00:00
Matt Corallo
095fca9293 Avoid ref to a Vec when accessing custom onion TLVs
The bindings can't easily return a reference to a `Vec`, so we
instead split the implementation into vec/slice depending on the
`c_bindings` flag.
2023-10-01 00:05:01 +00:00
Matt Corallo
327142894d Expose parse_onion_address publicly in no-std
The reason for having a separate `parse_onion_address` from
`FromStr` is to have an onion parsing function in `no-std`, but
when we added it we forgot to make it public. We do this here, as
well as fix a few compilation warnings in `no-std`.
2023-09-30 18:06:38 +00:00
Matt Corallo
783e255d4f Switch Simple*ChannelManager locks around Score to RwLock
This switches the locks used around `ProbabilisticScorer` in
`Simple*ChannelManager` type aliases to `RwLock`.
2023-09-30 18:04:31 +00:00
Matt Corallo
6482635ba6 Fix Simple*PeerManager to not require refs to the UtxoLookup
`UtxoLookup` doesn't strictly need to be referenced from the
`PeerManager`, and in fact the new `GossipVerifier` in
`lightning-block-sync` requires itself to be owned by the
`PeerManager` (for circular type reasons).

This allows us to use `lightning-block-sync`'s `GossipVerifier`
with `SimpleArcPeerManager` in ldk-sample.
2023-09-30 17:57:54 +00:00
Matt Corallo
cff2061335
Merge pull request #2610 from wpaulino/missing-htlc-claim-balance
Fix matching of second-stage HTLC claim in get_htlc_balance
2023-09-29 23:55:04 +00:00
Wilmer Paulino
fd66a298f3
Fix wrong node broadcaster in test_yield_anchors_events 2023-09-29 16:28:22 -07:00
Wilmer Paulino
4a393ee540
Add anchors coverage to test_revoked_counterparty_aggregated_claims 2023-09-29 16:28:20 -07:00
Wilmer Paulino
fe45af62a5
Add anchors coverage to test_revoked_counterparty_htlc_tx_balances 2023-09-29 16:27:10 -07:00
Wilmer Paulino
4156d7c53d
Add anchors coverage to test_revoked_counterparty_commitment_balances 2023-09-29 16:24:45 -07:00
Wilmer Paulino
898a20066c
Add anchors coverage to test_balances_on_local_commitment_htlcs 2023-09-29 16:24:44 -07:00
Wilmer Paulino
ea4b187df4
Add anchors coverage to test_claim_value_force_close 2023-09-29 16:24:44 -07:00
Wilmer Paulino
28f2dac844
Add anchors coverage to chanmon_claim_value_coop_close 2023-09-29 16:24:44 -07:00
Wilmer Paulino
52d76f97fc
Add test util to handle bump HTLC events 2023-09-29 16:24:42 -07:00
Matt Corallo
e0fe325402
Merge pull request #2629 from jkczyz/2023-09-invreqfailed
Config-guard `Event::InvoiceRequestFailed`
2023-09-29 22:42:50 +00:00
Matt Corallo
620244dc2e
Merge pull request #2605 from wpaulino/anchors-monitor-track-to-remote-script
Use correct to_remote script in counterparty commitments
2023-09-29 22:06:58 +00:00
Jeffrey Czyz
92e5cb6805
Remove unused imports 2023-09-29 15:03:23 -07:00
Jeffrey Czyz
6bd962bc51
Remove an unnecessary enumerate 2023-09-29 15:03:23 -07:00
Jeffrey Czyz
c7219e4683
Config-guard Event::InvoiceRequestFailed
The event cannot be generated publicly, so remove it for now to avoid
users needing to handle it.
2023-09-29 15:03:13 -07:00
Matt Corallo
d007d1b79f
Merge pull request #2628 from wvanlint/fix_multiple_shutdown_results
Fix handling multiple ShutdownResults
2023-09-29 21:25:51 +00:00
Wilmer Paulino
9f3bb7d7a5
Fix incorrect anchors counterparty_payment_script upon deserialization 2023-09-29 14:22:02 -07:00
Matt Corallo
b58f057345
Merge pull request #2622 from wpaulino/funding-and-commitment-tx-confirm-same-block
Avoid early return upon confirmation of channel funding
2023-09-29 21:06:55 +00:00
Matt Corallo
efbaa19a05
Merge pull request #2626 from TheBlueMatt/2023-09-revert-2476
Revert "Remove AvailableBalances::balance_msat"
2023-09-29 21:06:41 +00:00
Wilmer Paulino
fa2a2efef4
Support signing to_remote anchors variant for StaticPaymentOutput
`to_remote` outputs on commitment transactions with anchor outputs have
an additional `1 CSV` constraint on its spending condition,
transitioning away from the previous P2WPKH script to a P2WSH.

Since our `ChannelMonitor` was never updated to track the proper
`to_remote` script on anchor outputs channels, we also missed updating
our signer to handle the new script changes.
2023-09-29 13:46:59 -07:00
Wilmer Paulino
33b745f54e
Use correct to_remote script in counterparty commitments
While our commitment transactions did use the correct `to_remote`
script, the `ChannelMonitor`'s was not as it is tracked separately. This
would lead to users never receiving an `Event::SpendableOutputs` with a
`StaticPaymentOutput` descriptor to claim the funds.

Luckily, any users affected which had channel closures confirmed by a
counterparty commitment just need to replay the closing transaction to
receive the event.
2023-09-29 13:46:56 -07:00
Matt Corallo
955e81086f
Merge pull request #2624 from wpaulino/2609-follow-up
Address 2609 follow-up comments
2023-09-29 20:07:16 +00:00
Willem Van Lint
db79ed07f4 Fix handling multiple ShutdownResults 2023-09-29 12:06:36 -07:00
Matt Corallo
fbc86cb564
Merge pull request #2623 from wpaulino/htlc-claim-receive-preimage-after-close
Claim HTLCs with preimage from currently confirmed commitment
2023-09-29 18:53:44 +00:00
Wilmer Paulino
92fcdd39e1
Avoid early return upon confirmation of channel funding
This early return is only possible if the channel requires a single
confirmation, allowing a `channel_ready` message to go out. This can be
problematic though if a commitment transaction (specifically from the
counterparty, as the channel would be immediately closed if a local
commitment is broadcast) also confirms within the same block. The
`ChannelMonitor` will detect both, but it won't inform the
`ChannelManager` at all. Luckily, while the channel still is considered
open to the `ChannelManager`, the `ChannelMonitor` will reject any
further updates to the channel state.
2023-09-29 11:46:25 -07:00
Matt Corallo
c7c4226e99 Revert "Remove AvailableBalances::balance_msat"
While removing the `balance_msat` field absolutely makes sense -
it is, at best, confusing - we really need a solid replacement for
it before we can do so. While one such replacement is in progress,
it is not complete and we'd like to not block our current release
on its completion.

This reverts commit ef5be580f5.
2023-09-29 18:32:25 +00:00
Wilmer Paulino
f267a30cc7
Only yield DelayedPaymentOutput descriptors once their delay expires
Otherwise, we could give users a descriptor ahead of time that will
result in an invalid transaction spend/broadcast.
2023-09-29 10:56:48 -07:00
Matt Corallo
5e871a7bfc
Merge pull request #2617 from wpaulino/no-persist-same-channel-update
Avoid persisting on same counterparty's ChannelUpdate
2023-09-29 17:39:49 +00:00
Elias Rohrer
a8fa5a1685
Merge pull request #2591 from TheBlueMatt/2023-09-2562-followups
Doc and comment followups to #2562
2023-09-29 19:08:36 +02:00
Wilmer Paulino
d82e6ba7a3
Test preimage claim after reorg of counterparty commitment
This test adds coverage for receiving a preimage after seeing a
counterparty commitment confirm, followed by a reorg and the
confirmation of a different commitment instead.

The first test covers the case where a holder commitment confirms after
the counterparty commitment reorg.

The second test covers the case where a previous counterparty commitment
confirms after the latest counterparty commitment reorg.
2023-09-29 09:58:38 -07:00
Wilmer Paulino
c8c535412d
Avoid persisting on same counterparty's ChannelUpdate
Some nodes may rebroadcast their `ChannelUpdate` to their counterparty
on every connection establishment, which leads to us doing an additional
persist most of the time when nothing has changed. Now, we'll only
persist if we receive an update that changes anything.
2023-09-29 09:01:46 -07:00
Elias Rohrer
5d5d6406aa
Assert equality of route params in tests
Previously we only asserted the `final_value_msat` matches. Looking at
it again we can _of course_ assert the full equality of looked-for and
included route params after all (duh, not sure what I was thinking...).

This cleans up the prior misunderstanding and fixes a bunch of tests
that would now fail otherwise.
2023-09-29 16:49:32 +02:00
Matt Corallo
6016101ac8
Merge pull request #2609 from wpaulino/monitor-get-spendable-output
Allow retrieval of SpendableOutputDescriptors from relevant transactions
2023-09-29 01:29:47 +00:00
Wilmer Paulino
ffec24b3e3
Retrieve all possible spendable outputs from transactions
Assuming our keys haven't been compromised, and that random transactions
aren't learning of these scripts somehow and sending funds to them, it
was only possible for one spendable output to exist within a
transaction.

- `shutdown_script` can only exist in co-op close transactions.
- `counterparty_payment_script` can only exist in counterparty
  commitment transactions.
- `broadcasted_holder_revokable_script` can only exist in holder
  commitment/HTLC transactions.
- `destination_script` can exist in any other type of claim we support.

Now that we're exposing this API to users such that they can rescan any
relevant transactions, there's no harm in allowing them to claim more
funds from spendable outputs than we expected.
2023-09-28 14:25:30 -07:00
Wilmer Paulino
b8f80f8ab9
Allow retrieval of SpendableOutputDescriptors from relevant transactions
Currently, our API will only expose `SpendableOutputDescriptor`s once
after they are no longer under reorg risk (see `ANTI_REORG_DELAY`).
Users have often requested they'd like the ability to retrieve these in
some other way, either for historical purposes, or to handle replaying
any in the event of a failure.
2023-09-28 14:23:33 -07:00