Commit graph

8550 commits

Author SHA1 Message Date
Matt Corallo
04c769b0c5 Improve readability in messenger.rs now that we're rustfmt'ing
In ecbab29386 we ran rustfmt blindly
on `lightning/src/onion_message/messenger.rs`. This exposed a few
untidy things in the file and made them worse, which we should have
cleaned up as we went.

Here we address these, removing some unnecessary generics,
condensing some lines by adding intermediate variables, and
reducing very vertical match statements.
2025-02-01 20:55:05 +00:00
Matt Corallo
c45c3a7d4d Use constant for buffer size in OM functional_tests.rs
In 3c3e93e7b5 we ran rustfmt blindly
on `lightning/src/onion_message/functional_tests.rs`. This left
the file with a handful of warts that really should have been
cleaned up as we went.

Here we take the opportunity to clean up the `peer_buffer_full`
test which used a constant for the number of messages we can push
before the buffer fills, rather than calculating the amount based
on the buffer size constant, also removing a comment that got moved
by rustfmt into a place where it was no longer understandable.
2025-02-01 20:55:05 +00:00
Matt Corallo
f8a5ef5c2c Clean up terrible rustfmt-isms in OM functional_tests.rs
In 3c3e93e7b5 we ran rustfmt blindly
on `lightning/src/onion_message/functional_tests.rs`. This left
the file with a handful of warts that really should have been
cleaned up as we went.

Here we clean up a handful of rustfmt-isms, ranging from terrible
to somewhat ugly, introduced in `functional_tests.rs`.
2025-02-01 20:55:05 +00:00
Matt Corallo
0ba12dbb88 Clean up type aliases in functional_tests
In 3c3e93e7b5 we ran rustfmt blindly
on `lightning/src/onion_message/functional_tests.rs`. This left
the file with a handful of warts that really should have been
cleaned up as we went.

Here we clean up types a bit by importing structs directly and
adding a few type aliases.
2025-02-01 20:55:05 +00:00
Elias Rohrer
c7c3973bb0
Merge pull request #3576 from tnull/2025-01-rustfmt-onion-message
`rustfmt`: Run on `onion_message`
2025-02-01 14:05:03 +01:00
Wilmer Paulino
9b66e2c409
Merge pull request #3554 from wpaulino/channel-monitor-by-channel-id
Start tracking ChannelMonitors by channel ID in ChainMonitor and ChannelManager
2025-01-31 15:41:04 -08:00
Wilmer Paulino
717db82540
Remove funding script return value from ChannelMonitor::get_funding_txo
It's not needed except for one place where we can just access the field
directly, so we can avoid the allocation on each call. For API
consumers, they may still access the funding script via
`ChannelMonitor::get_funding_script`.
2025-01-31 13:26:35 -08:00
Wilmer Paulino
e8854f9a07
Use channel ID over funding outpoint to track monitors in ChannelManager
As motivated by the previous commit, we do some of the same work here at
the `ChannelManager` level instead. Unfortunately, we still need to
track the funding outpoint to support downgrades by writing the in
flight monitor updates as two separate TLVs, one using the channel IDs,
and the other using the funding outpoints. Once we are willing to stop
supporting downgrades past this version, we can fully drop it.
2025-01-31 13:26:34 -08:00
Wilmer Paulino
d205d8d515
Use channel ID over funding outpoint to track monitors in ChainMonitor
Once dual funding/splicing is supported, channels will no longer
maintain their original funding outpoint. Ideally, we identify
`ChannelMonitor`s with a stable identifier, such as the channel ID,
which is fixed throughout the channel's lifetime.

This commit replaces the use of funding outpoints as the key to the
monitor index with the channel ID. Note that this is strictly done to
the in-memory state; it does not change how we track monitors within
their persisted state, they are still keyed by their funding outpoint
there. Addressing that is left for follow-up work.
2025-01-31 13:26:31 -08:00
Matt Corallo
1434e9c1e2
Merge pull request #3564 from TheBlueMatt/2025-01-revoked-htlc-not-pinnable
Set correct `counterparty_spendable_height` on c.p. revoked HTLCs
2025-01-30 18:54:51 +00:00
valentinewallace
31b32c549c
Merge pull request #3578 from tnull/2025-01-rustfmt-blinded-path
` rustfmt`: Run on `blinded_path`
2025-01-30 10:42:05 -05:00
Matt Corallo
93e2da4863
Merge pull request #3565 from arik-so/min_relay_doc_fix
Fix incremental relay constant name in docs
2025-01-30 14:50:18 +00:00
Elias Rohrer
996eb2a7f3
rustfmt: Drop lightning/src/blinded_path/mod.rs from exclusion list 2025-01-30 12:04:44 +01:00
Elias Rohrer
e08ec7b1fc
rustfmt: Run on lightning/src/blinded_path/mod.rs 2025-01-30 12:04:44 +01:00
Elias Rohrer
5e84ab345a
rustfmt: Drop lightning/src/blinded_path/utils.rs from exclusion list 2025-01-30 12:04:41 +01:00
Elias Rohrer
40f5524421
rustfmt: Run on lightning/src/blinded_path/utils.rs 2025-01-30 12:04:41 +01:00
Elias Rohrer
47a1a8dbc9
rustfmt: Drop lightning/src/blinded_path/payment.rs from exclusion list 2025-01-30 12:04:36 +01:00
Elias Rohrer
fb8263da0b
rustfmt: Run on lightning/src/blinded_path/payment.rs 2025-01-30 12:04:36 +01:00
Elias Rohrer
0697401927
rustfmt: Drop lightning/src/blinded_path/message.rs from exclusion list 2025-01-30 12:04:32 +01:00
Elias Rohrer
de62b3e251
rustfmt: Run on lightning/src/blinded_path/message.rs 2025-01-30 12:04:32 +01:00
Elias Rohrer
6c0c5f0efd
rustfmt: Drop lightning/src/onion_message/mod.rs from exclusion list 2025-01-30 11:51:00 +01:00
Elias Rohrer
90e1510fc2
rustfmt: Run on lightning/src/onion_message/mod.rs 2025-01-30 11:51:00 +01:00
Elias Rohrer
5d9ee8ab03
rustfmt: Drop lightning/src/onion_message/packet.rs from exclusion list 2025-01-30 11:50:56 +01:00
Elias Rohrer
5e8611727b
rustfmt: Run on lightning/src/onion_message/packet.rs 2025-01-30 11:50:56 +01:00
Elias Rohrer
682cf76249
rustfmt: Drop lightning/src/onion_message/offers.rs from exclusion list 2025-01-30 11:50:51 +01:00
Elias Rohrer
b98f070817
rustfmt: Run on lightning/src/onion_message/offers.rs 2025-01-30 11:50:51 +01:00
Elias Rohrer
45dbcc43e3
rustfmt: Drop lightning/src/onion_message/messenger.rs from exclusion list 2025-01-30 11:50:41 +01:00
Elias Rohrer
ecbab29386
rustfmt: Run on lightning/src/onion_message/messenger.rs 2025-01-30 11:50:41 +01:00
Elias Rohrer
7f90d91bb6
rustfmt: Drop lightning/src/onion_message/functional_tests.rs from exclusion list 2025-01-30 11:50:36 +01:00
Elias Rohrer
3c3e93e7b5
rustfmt: Run on lightning/src/onion_message/functional_tests.rs 2025-01-30 11:50:36 +01:00
valentinewallace
b1fc7d8db7
Merge pull request #3333 from arik-so/dynamic_trampoline_onion_sizes
Calculate Trampoline onion packet sizes dynamically.
2025-01-28 18:28:57 -05:00
Matt Corallo
6c57a1fb42 Mark counterparty revoked offered HTLCs as Unpinnable
If the counterparty broadcasts a revoked transaction with offered
HTLCs, the output is not immediately pinnable as the counterparty
cannot claim the HTLC until the CLTV expires and they use an
HTLC-Timeout path.

Here we properly set these packages as `Unpinnable`, changing some
transaction generation during tests.
2025-01-28 20:39:08 +00:00
Matt Corallo
5eb0a34ca4 Set correct counterparty_spendable_height on c.p. revoked HTLCs
If the counterparty broadcasts a revoked transaction with offered
HTLCs, the output is not immediately pinnable as the counterparty
cannot claim the HTLC until the CLTV expires and they use an
HTLC-Timeout path.

Here we fix the `counterparty_spendable_height` value we set on
counterparty revoked HTLC claims to match reality. Note that
because we still consider these outputs `Pinnable` the value is
not used. In the next commit we'll start making them `Unpinnable`
which will actually change behavior.

Note that when upgrading we have to wipe the
`counterparty_spendable_height` value for non-offered HTLCs as
otherwise we'd consider them `Unpinnable` when they are, in fact,
`Pinnable`.
2025-01-28 20:39:08 +00:00
Arik Sosman
14c3479d96
Fix incremental relay constant name in docs 2025-01-28 12:13:58 -08:00
Matt Corallo
97e70b40cf
Merge pull request #3546 from tnull/2025-01-update-main-post-0.1-release
Update `main` post-0.1 release
2025-01-28 19:16:59 +00:00
Arik Sosman
7c6f2207d7
Calculate Trampoline onion size dynamically
For outbound Trampoline payments, we will need to generate onion
packets whose size matches their content. This allows them to be
included in individual hops at arbitrary positions.

A future spec change may involve defining a static size to improve
privacy from Trampoline nodes.
2025-01-28 11:00:22 -08:00
Wilmer Paulino
569f906688
Merge pull request #3539 from TheBlueMatt/2025-01-3513-followups
Further decouple ChannelManager from Channel state somewhat
2025-01-28 09:25:09 -08:00
Elias Rohrer
f19016f900
Drop (currently) unused BP dev-dependency from lightning-liquidity
.. we planned to use the BP for some more advanced integration tests, but we
haven't actually implemented them as of now. Here we drop the
unnecessary dev-dependency for now.
2025-01-28 16:45:09 +01:00
Matt Corallo
9ef96a5e56
Set release date for 0.1, plus some text about the milestone 2025-01-28 16:45:09 +01:00
Matt Corallo
a8c03f455a
Bump crate versions to 0.1.0/invoice 0.33.0/dns-resolver 0.2
Sadly, dns-resolver got uploaded as 0.1.0 without a -beta1 tag (and
yanked), and thus we release it here as 0.2.0.
2025-01-28 16:45:09 +01:00
Matt Corallo
bece44c72e Reduce chan state logic from ChannelManager when reconnecting
After #3513 we have a bit more encapsulation of channel logic in
channel.rs with channelmanager.rs needing a bit less knowledge of
which specific state a channel is in.

This continues that trend slightly when a peer reconnects.
2025-01-28 14:48:58 +00:00
Matt Corallo
e3325a23ff Reduce chan state logic from ChannelManager when disconnecting
After #3513 we have a bit more encapsulation of channel logic in
channel.rs with channelmanager.rs needing a bit less knowledge of
which specific state a channel is in.

This continues that trend slightly when a peer disconnects.
2025-01-28 14:48:58 +00:00
Arik
8d8b4ead5c
Merge pull request #3556 from TheBlueMatt/2025-01-fail-back-on-expiry
Fail HTLC backwards before upstream claims on-chain
2025-01-27 15:00:31 -08:00
Matt Corallo
59da80687e Reduce chan state logic from ChannelManager when unblocking signer
After #3513 we have a bit more encapsulation of channel logic in
channel.rs with channelmanager.rs needing a bit less knowledge of
which specific state a channel is in.

This continues that trend slightly when unblocking the signer.
2025-01-27 21:37:52 +00:00
Matt Corallo
695c612be9 Remove redundant variable 2025-01-27 21:35:35 +00:00
Matt Corallo
0454d45b5d
Merge pull request #3534 from valentinewallace/2025-01-send-with-route
Reinstate `ChannelManager::send_payment_with_route` API
2025-01-27 21:23:52 +00:00
Matt Corallo
ed7befc077
Merge pull request #3550 from jkczyz/2025-01-refactor-channel-phase
Encapsulate `Channel` enum variants inside a struct
2025-01-27 21:21:30 +00:00
Matt Corallo
39ff6025cd
Merge pull request #3549 from lightning-signer/2025-01-invoice-base32
RawBolt11Invoice serialization utilities
2025-01-27 18:28:55 +00:00
Matt Corallo
e93622b843 Drop counterparty_spendable_height accessor
`counterparty_spendable_height` is not used outside of `package.rs`
so there's not much reason to have an accessor for it. Also, in the
next commit an issue with setting the correct value for revoked
counterparty HTLC outputs is fixed, and the upgrade path causes the
value to be 0 in some cases, making using the value in too many
places somewhat fraught.
2025-01-27 18:25:24 +00:00
Valentine Wallace
82a2c845d8
Reinstate ChannelManager::send_payment_with_route API
Support more ergonomically sending payments to specific routes.

We removed the original version of this API because it was hard to work with,
but the concept of sending a payment to a specific route is still useful.
Previously, users were able to do this via manually matching the payment id in
their router, but that's cumbersome when we could just handle it internally.
2025-01-27 12:47:58 -05:00