shaavan [Sun, 10 Dec 2023 12:47:32 +0000 (18:17 +0530)]
Do not remove Outbound Channel immediately when peer disconnects
- Do not remove channel immediately when peer_disconnect, instead
removed it after some time if peer doesn't reconnect soon (handled in
previous commit).
- Do not mark per ok_to_remove if we have some OutboundV1Channels too.
- Rebroadcast SendOpenChannel for outboundV1Channel when peer
reconnects.
- Update the relevant tests to account for the behavior change.
- Repurpose the test_disconnect_in_funding_batch to test that all
channels in the batch close when one them closes.
Matt Corallo [Tue, 30 Jan 2024 23:36:36 +0000 (23:36 +0000)]
Merge pull request #2862 from arik-so/arik/2024/01/http-error-message-fix
Improve error message for invalid response lengths
Matt Corallo [Tue, 30 Jan 2024 23:21:42 +0000 (23:21 +0000)]
Merge pull request #2780 from wpaulino/2691-follow-ups
2691 follow-ups
Matt Corallo [Tue, 30 Jan 2024 23:04:39 +0000 (23:04 +0000)]
Merge pull request #2797 from dunxen/2023-12-purgetochannelid
Remove `Outpoint::to_channel_id` method
Arik Sosman [Tue, 30 Jan 2024 19:43:04 +0000 (11:43 -0800)]
Improve error message for invalid response lengths.
Duncan Dean [Tue, 9 Jan 2024 07:07:01 +0000 (09:07 +0200)]
Remove `Outpoint::to_channel_id` method
To avoid confusion and for accuracy going forward, we remove this method
as it is inconsistent with channel IDs generated during V2 channel
establishment. If one wants to create a V1, funding outpoint-based
channel ID, then `ChannelId::v1_from_funding_outpoint` should be used
instead.
A large portion of the library has always made the assumption that having
the funding outpoint will always allow us to generate the channel ID.
This will not be the case anymore and we need to pass the channel ID along
where appropriate. All channels that could have been persisted up to this
point could only have used V1 establishment, so if some structures don't
store a channel ID for them they can safely fall back to the funding
outpoint-based version.
Wilmer Paulino [Fri, 8 Dec 2023 19:33:06 +0000 (11:33 -0800)]
Enforce compile-time check for flag getters and setters
This ensures that we cannot define or use flag getters/setters on
`ChannelState` variants in which said flag is not valid.
Wilmer Paulino [Mon, 29 Jan 2024 21:57:19 +0000 (13:57 -0800)]
Use clear helper on flags copy to mask off bits
Matt Corallo [Thu, 25 Jan 2024 01:52:13 +0000 (01:52 +0000)]
Merge pull request #2694 from Evanfeenstra/public-scid-utils
public scid utils
Matt Corallo [Wed, 24 Jan 2024 23:14:01 +0000 (23:14 +0000)]
Merge pull request #2697 from jkczyz/2023-10-offer-functional-tests
Functional tests for BOLT 12 Offers payment flow
Matt Corallo [Mon, 22 Jan 2024 23:55:35 +0000 (23:55 +0000)]
Merge pull request #2844 from TheBlueMatt/2024-01-cut-121
Release 0.0.121
Matt Corallo [Mon, 22 Jan 2024 22:22:20 +0000 (22:22 +0000)]
Bump versions to LDK 0.0.121/invoice 0.29
Matt Corallo [Mon, 22 Jan 2024 22:21:16 +0000 (22:21 +0000)]
Add CHANGELOG entry for 0.0.121
Matt Corallo [Mon, 22 Jan 2024 22:30:59 +0000 (22:30 +0000)]
Merge pull request #2841 from TheBlueMatt/2024-01-batch-deadlock
Fix deadlock when handling bad calls to `batch_funding.._generated`
Matt Corallo [Mon, 22 Jan 2024 22:30:56 +0000 (22:30 +0000)]
Merge pull request #2842 from jkczyz/2024-01-fix-peer-handler-unwrap
Fix panic when peer is mid-handshake
Jeffrey Czyz [Mon, 22 Jan 2024 22:26:54 +0000 (16:26 -0600)]
Remove unnecessary unwraps
Jeffrey Czyz [Thu, 18 Jan 2024 21:34:19 +0000 (15:34 -0600)]
Fix panic when peer is mid-handshake
Peer::their_node_id is set to Some during the handshake process.
However,
df3ab2ee2753e7f9ec02ddf1c8a51db77c50e35d accesses the field
unconditionally, causing a panic. This may be triggered if a gossip
message is received mid-handshake from another peer or if the user calls
broadcast_node_announcement during this time. The latter tends to be
executed on a timer.
Ensure that Peer::their_node_id is only accessed once the handshake is
complete.
Matt Corallo [Mon, 22 Jan 2024 20:26:32 +0000 (20:26 +0000)]
Fix deadlock when handling bad calls to `batch_funding.._generated`
When handling calls to `batch_funding_transaction_generated` which
were missing outputs for one of the batch channels, we'd previously
deadlock when trying to clean up the now-closed channels. This
fixes that and adds a new test case for it.
Found by the full_stack_target fuzzer.
Evan Feenstra [Sat, 28 Oct 2023 15:38:17 +0000 (08:38 -0700)]
public scid utils
Elias Rohrer [Fri, 19 Jan 2024 20:41:51 +0000 (21:41 +0100)]
Merge pull request #2835 from TheBlueMatt/2024-01-cut-120
Change v0.0.120 release name
Matt Corallo [Wed, 17 Jan 2024 23:18:47 +0000 (23:18 +0000)]
Change v0.0.120 release name
"Un"blinded makes more sense, since the fuzzer was unblinded :)
Matt Corallo [Wed, 17 Jan 2024 23:02:24 +0000 (23:02 +0000)]
Merge pull request #2834 from TheBlueMatt/2024-01-cut-120
Cut 0.0.120
Matt Corallo [Wed, 17 Jan 2024 21:25:50 +0000 (21:25 +0000)]
Bump crate versions to 0.0.120/invoice 0.28
Matt Corallo [Wed, 17 Jan 2024 21:00:26 +0000 (21:00 +0000)]
Add CHANGELOG entry for 0.0.120
Matt Corallo [Wed, 17 Jan 2024 21:21:36 +0000 (21:21 +0000)]
Merge pull request #2818 from valentinewallace/2024-01-blinded-path-retries
Avoid retrying over previously failed blinded paths
valentinewallace [Wed, 17 Jan 2024 17:53:02 +0000 (12:53 -0500)]
Merge pull request #2828 from TheBlueMatt/2024-01-crypto-module
Move cryptographic algorithms and utilities to a new `crypto` mod
Valentine Wallace [Tue, 9 Jan 2024 16:58:13 +0000 (11:58 -0500)]
Test that we won't retry over previously failed blinded paths.
Valentine Wallace [Tue, 9 Jan 2024 16:53:51 +0000 (11:53 -0500)]
Test util: separate out code to construct a blinded path.
Valentine Wallace [Tue, 9 Jan 2024 16:52:37 +0000 (11:52 -0500)]
Avoid building routes over previously failed blinded payment paths.
Valentine Wallace [Tue, 9 Jan 2024 16:32:38 +0000 (11:32 -0500)]
Store previously failed blinded paths on outbound payment failure.
Useful so we don't retry over these paths.
Valentine Wallace [Tue, 9 Jan 2024 16:28:38 +0000 (11:28 -0500)]
Persist previously failed blinded paths in RouteParameters.
Useful so we don't retry over these paths.
Valentine Wallace [Fri, 12 Jan 2024 16:35:08 +0000 (11:35 -0500)]
Add failed_within_blinded_path to DecodedOnionFailure.
Will be used to ensure correctness when we store previously failed blinded
paths to avoid retrying over them.
Valentine Wallace [Fri, 12 Jan 2024 01:11:14 +0000 (20:11 -0500)]
Add failed_within_blinded_path to onion util internal struct.
Will be used to ensure correctness when we store previously failed blinded
paths to avoid retrying over them.
Matt Corallo [Wed, 17 Jan 2024 00:47:48 +0000 (00:47 +0000)]
Merge pull request #2831 from jkczyz/2024-01-fix-cltv-expiry-delta
Use consistent `cltv_expiry_delta` in `ForwardTlvs`
Matt Corallo [Wed, 17 Jan 2024 00:37:09 +0000 (00:37 +0000)]
Merge pull request #2832 from p2pderivatives/fix-ln-net-tokio-dropping-messages
Fix lightning-net-tokio sometimes dropping messages
Matt Corallo [Wed, 17 Jan 2024 00:28:30 +0000 (00:28 +0000)]
Merge pull request #2812 from valentinewallace/2023-12-blinded-forwarding
Complete route blinding support
Tibo-lg [Wed, 17 Jan 2024 00:20:30 +0000 (09:20 +0900)]
Fix lightning-net-tokio sometimes dropping messages
Jeffrey Czyz [Thu, 11 Jan 2024 19:13:12 +0000 (13:13 -0600)]
Use consistent cltv_expiry_delta in ForwardTlvs
When converting from CounterpartyForwardingInfo to PaymentRelay, the
cltv_expiry_delta is copied. Then, when forming a blinded payment path,
the value is mutated so that esoteric values don't reveal information
about the path. However, the value was only used in computing
PaymentConstraints and wasn't actually updated in PaymentRelay. Move the
logic for modifying the cltv_expiry_delta to the conversion code to
avoid this inconsistency.
Valentine Wallace [Thu, 11 Jan 2024 18:47:17 +0000 (13:47 -0500)]
Advertise route blinding feature as supported.
Now that we fully support forwarding blinded payments, we should advertise
support so nodes on the network can include us in their blinded paths.
Valentine Wallace [Wed, 20 Dec 2023 19:04:04 +0000 (14:04 -0500)]
Fix sender double-including shadow offset in CLTV expiry height.
The excess delta is included in the final RouteHop::cltv_expiry_delta, so by
adding it explicitly to cur_cltv we were erroneously including it twice in the
total cltv expiry.
This could've add up to an extra MAX_SHADOW_CLTV_DELTA_OFFSET (432) blocks to
the total cltv expiry.
Valentine Wallace [Wed, 20 Dec 2023 19:00:17 +0000 (14:00 -0500)]
Rename test var to be more descriptive.
Valentine Wallace [Mon, 18 Dec 2023 19:42:07 +0000 (14:42 -0500)]
Complete remaining TODOs for failing blinded non-intro forwards.
Valentine Wallace [Mon, 18 Dec 2023 19:36:57 +0000 (14:36 -0500)]
Add failure mode info to BlindedForward struct.
See added docs.
Matt Corallo [Mon, 15 Jan 2024 01:25:10 +0000 (01:25 +0000)]
Move cryptographic algorithms and utilities to a new `crypto` mod
As we'd generally like the `lightning` crate to, over time, have
more modules rather than being very monolithic, we should move the
cryptographic things into their own module, which we do here.
We also take this opportunity to move stream adapters into their
own module and make clear that the ChaChaPoly `decrypt` method is
variable time.
Jeffrey Czyz [Fri, 5 Jan 2024 05:40:43 +0000 (23:40 -0600)]
Fix bench build warning
Jeffrey Czyz [Thu, 4 Jan 2024 23:39:18 +0000 (17:39 -0600)]
Reorganize #[cfg(not(c_bindings))] imports
Jeffrey Czyz [Thu, 21 Dec 2023 00:05:42 +0000 (18:05 -0600)]
Add ASCII art diagram explaining offers_tests
Jeffrey Czyz [Wed, 20 Dec 2023 23:52:09 +0000 (17:52 -0600)]
Functional test for failing duplicate payments
Jeffrey Czyz [Wed, 20 Dec 2023 20:37:31 +0000 (14:37 -0600)]
Functional tests for failing without payment paths
Jeffrey Czyz [Wed, 20 Dec 2023 20:32:53 +0000 (14:32 -0600)]
Add Features::clear_route_blinding for testing
Jeffrey Czyz [Tue, 19 Dec 2023 23:24:11 +0000 (17:24 -0600)]
Offers functional tests for duplicated payment ids
Jeffrey Czyz [Tue, 19 Dec 2023 22:06:55 +0000 (16:06 -0600)]
Functional tests for failing without blinded paths
Jeffrey Czyz [Fri, 15 Dec 2023 05:46:12 +0000 (23:46 -0600)]
Functional tests for offers with blinded paths
Jeffrey Czyz [Fri, 3 Nov 2023 19:01:57 +0000 (14:01 -0500)]
Functional tests for offers without blinded paths
Jeffrey Czyz [Tue, 31 Oct 2023 19:27:29 +0000 (14:27 -0500)]
Functional tests for BOLT 12 Offers payment flow
ChannelManager provides utilities to create offers and refunds along
with utilities to initiate and request payment for them, respectively.
It also manages the payment flow via implementing OffersMessageHandler.
Test that functionality, including the resulting event generation.
Jeffrey Czyz [Tue, 9 Jan 2024 21:05:29 +0000 (15:05 -0600)]
Consolidate conditional imports
Jeffrey Czyz [Tue, 9 Jan 2024 20:59:30 +0000 (14:59 -0600)]
Remove redundant negations from feature check
Jeffrey Czyz [Thu, 4 Jan 2024 16:30:51 +0000 (10:30 -0600)]
Remove "no-std" feature checks
An upcoming rust-bitcoin release will remove the "no-std" feature.
Replace "no-std" in feature checks with "std", negating as needed. Using
a single feature flag makes the checks more consistent across modules.
Jeffrey Czyz [Thu, 14 Dec 2023 16:25:10 +0000 (10:25 -0600)]
Have TestRouter wrap DefaultRouter
TestRouter checks route and scoring expectations before delegating to
the standalone find_route function. Refactor it to wrap DefaultRouter
and delegate to it instead. This allows TestRouter to implement
create_blinded_payment_paths by delegating to DefaultRouter.
Jeffrey Czyz [Fri, 27 Oct 2023 18:27:55 +0000 (13:27 -0500)]
Support OnionMessenger in functional_test_utils
OnionMessenger is needed to write functional tests for ChannelManager's
OffersMessageHandler implementation. Also adds a TestMessageRouter,
which simply wraps DefaultMessageRouter for now.
Jeffrey Czyz [Wed, 3 Jan 2024 21:41:00 +0000 (15:41 -0600)]
DRY up EntropySource implementation
The ChaCha20-based EntropySource implementation is duplicated within the
sign module. Refactor those into a RandomBytes implementation so that it
may be reused both there. Also useful as a standalone EntropySource
implementation for tests where an independent EntropySource is needed to
ensure that backwards-compatibility testing is not broken.
Jeffrey Czyz [Fri, 27 Oct 2023 15:39:41 +0000 (10:39 -0500)]
Fix import order in functional_test_utils.rs
Jeffrey Czyz [Wed, 1 Nov 2023 18:12:44 +0000 (13:12 -0500)]
Add peel_onion_message method to OnionMessenger
When testing OnionMessenger in functional tests, it would be useful to
examine the contents of an OnionMessage response. Expose the standalone
peel_onion_message on OnionMessenger to facilitate this.
Elias Rohrer [Mon, 15 Jan 2024 09:38:03 +0000 (10:38 +0100)]
Merge pull request #2824 from shuoer86/main
Fix typos
shuoer86 [Fri, 12 Jan 2024 12:46:47 +0000 (20:46 +0800)]
Fix typo lightning/src/util/wakers.rs
shuoer86 [Fri, 12 Jan 2024 12:46:40 +0000 (20:46 +0800)]
Fix typo lightning/src/routing/router.rs
shuoer86 [Fri, 12 Jan 2024 12:46:33 +0000 (20:46 +0800)]
Fix typo lightning/src/ln/peer_handler.rs
shuoer86 [Fri, 12 Jan 2024 12:46:26 +0000 (20:46 +0800)]
Fix typo lightning-invoice/src/ser.rs
shuoer86 [Fri, 12 Jan 2024 12:46:16 +0000 (20:46 +0800)]
Fix typo CONTRIBUTING.md
Matt Corallo [Thu, 11 Jan 2024 19:35:26 +0000 (19:35 +0000)]
Merge pull request #2800 from optout21/channel-close-add-funding
Add channel funding txo to Channel Event::ChannelClosed
Elias Rohrer [Thu, 11 Jan 2024 17:41:01 +0000 (18:41 +0100)]
Merge pull request #2822 from TheBlueMatt/2024-01-pm-dyn-ref
Drop `PeerManager` type bound on `UtxoLookup` entirely
Valentine Wallace [Mon, 18 Dec 2023 19:27:12 +0000 (14:27 -0500)]
Make BlindedFailure enum pub.
Necessary to include it in the public PendingHTLCInfo struct in the next commit.
Valentine Wallace [Mon, 18 Dec 2023 19:16:02 +0000 (14:16 -0500)]
Test successful payment to 3-hop blinded path.
Valentine Wallace [Wed, 20 Dec 2023 00:16:37 +0000 (19:16 -0500)]
Fix final blinded hop CLTV expiry on send.
Previously, we were setting the final blinded hop's CLTV expiry height to
best_block_height + total_blinded_path_cltv_delta + shadow_cltv_offset. This is
incorrect, it should instead be set to best_block_height + shadow_cltv_offset
only -- it doesn't make sense to include the delta for the other blinded hops
in the final hop's expiry.
The reason this too-high final cltv value didn't cause test failures previously
is because of a 2nd bug that is fixed in an upcoming commit where the sender
adds the shadow offset twice to the total path CLTV expiry. This 2nd offset
meant that intermediate nodes had some buffer CLTV to subtract their delta from
while still (usually) have enough leftover to meet the expiry in the final hop's
onion.
Valentine Wallace [Mon, 18 Dec 2023 19:15:48 +0000 (14:15 -0500)]
Support forwarding blinded HTLCs as non-intro node.
Error handling will be completed in upcoming commit(s).
valentinewallace [Thu, 11 Jan 2024 16:30:46 +0000 (11:30 -0500)]
Merge pull request #2801 from valentinewallace/2023-12-rb-groundwork-followups
#2128 follow-ups
valentinewallace [Thu, 11 Jan 2024 16:22:34 +0000 (11:22 -0500)]
Merge pull request #2820 from TheBlueMatt/2024-01-fuzz-ooo-monitor-updates
Test individual monitor update compl in chanmon_consistency fuzzer
valentinewallace [Thu, 11 Jan 2024 14:52:00 +0000 (09:52 -0500)]
Merge pull request #2821 from TheBlueMatt/2024-01-om-direct-export
Expose `onion_message` items directly rather than via re-exports
optout [Thu, 11 Jan 2024 08:15:53 +0000 (09:15 +0100)]
Add channel funding txo to Channel Event::ChannelClosed
Wilmer Paulino [Fri, 8 Dec 2023 18:44:44 +0000 (10:44 -0800)]
Assert we never write channels in pre-funded/shutdown state
Wilmer Paulino [Fri, 8 Dec 2023 18:23:13 +0000 (10:23 -0800)]
Check funding transaction on outbound channels only
This was a slight regression, but not a critical one. Only outbound
channels should have a funding transaction present.
Wilmer Paulino [Fri, 8 Dec 2023 18:21:29 +0000 (10:21 -0800)]
Simplify ChannelState checks
Wilmer Paulino [Fri, 8 Dec 2023 18:20:51 +0000 (10:20 -0800)]
Rename should_force_holding_cell to can_generate_new_commitment
This better reflects the intent behind the callsites of the method.
Wilmer Paulino [Fri, 8 Dec 2023 18:20:20 +0000 (10:20 -0800)]
Add note and test regarding ChannelState's implicit ordering
Matt Corallo [Thu, 11 Jan 2024 00:04:39 +0000 (00:04 +0000)]
Merge pull request #2791 from valentinewallace/2023-12-multihop-recv-followups
Follow-ups to #2688
Matt Corallo [Wed, 10 Jan 2024 18:27:57 +0000 (18:27 +0000)]
Expose `onion_message` items directly rather than via re-exports
When we originally added the `onion_message` module, there weren't
a lot of public items in it, and it didn't make a lot of sense to
export the whole sub-module structure publicly. So, instead, we
exported the public items via re-exports directly in the
`onion_message` top-level module. However, as time went on, more
and more things entered the module, which left the top-level module
rather cluttered.
Worse, in 0.0.119, we exposed
`onion_message::messenger::SendSuccess` via the return type of
`send_message`, but forgot to re-export the enum itself, making
it impossible to actually use from external code.
Here we address both issues and simply replace the re-export with
the underlying sub-module structure.
Matt Corallo [Wed, 10 Jan 2024 22:37:07 +0000 (22:37 +0000)]
Merge pull request #2809 from TheBlueMatt/2023-12-closing-event-cleanup-fixes
Clean Up Funding Error Handling and shutdown
Matt Corallo [Wed, 10 Jan 2024 22:24:43 +0000 (22:24 +0000)]
Drop `PeerManager` type bound on `UtxoLookup` entirely
In
67659677d4fdb6bf418d66dfa37c61706425232b we relaxed the bounds
set on `UtxoLookup` to enable those using `RoutingMessageHandler`
other than `P2PGossipSync` to use `UtxoLookup`. Sadly, because this
requires having a concrete `PeerManager` type which does *not* use
`UtxoLookup` in the `RoutingMessageHandler` type, this broke users
who were directly using `P2PGossipSync`.
We could split `UtxoLookup` into two, with different bounds, for
the two use-cases, but instead here we simply switch to storing a
reference to the `PeerManager` via a `dyn Fn` which allows us to
wake the `PeerManager` when we need to.
Fixes #2813
Valentine Wallace [Wed, 13 Dec 2023 21:27:54 +0000 (16:27 -0500)]
Rename parameter from err_packet to err_contents.
This name is more accurate since the method has been generalized to support
malformed HTLCs.
Valentine Wallace [Wed, 13 Dec 2023 19:23:23 +0000 (14:23 -0500)]
Remove outdated comment.
Valentine Wallace [Wed, 13 Dec 2023 19:20:51 +0000 (14:20 -0500)]
Normalize order of (sha256_of_onion, failure_code) in trait.
This helps avoid destructuring the tuple.
Valentine Wallace [Wed, 13 Dec 2023 19:15:58 +0000 (14:15 -0500)]
DRY malformed HTLC handling during htlc batch processing.
Valentine Wallace [Wed, 13 Dec 2023 19:09:16 +0000 (14:09 -0500)]
Fix logger usage during batched htlc processing of malforms.
Introduced due to a rebase error.
Valentine Wallace [Wed, 10 Jan 2024 16:19:09 +0000 (11:19 -0500)]
Clean up code DRY'd in previous commit.
Valentine Wallace [Thu, 14 Dec 2023 20:34:51 +0000 (15:34 -0500)]
Rename OutboundOnionPayload::BlindedReceive::amt_msat to be more descriptive.
Valentine Wallace [Thu, 14 Dec 2023 20:32:34 +0000 (15:32 -0500)]
Rename OutboundOnionPayload::Receive::amt_msat to be more descriptive.
Valentine Wallace [Thu, 14 Dec 2023 20:21:15 +0000 (15:21 -0500)]
Rename InboundOnionPayload::BlindedReceive::amt_msat to be more descriptive.
Valentine Wallace [Thu, 14 Dec 2023 20:15:41 +0000 (15:15 -0500)]
Rename InboundOnionPayload::Receive::amt_msat to be more descriptive.
Valentine Wallace [Wed, 13 Dec 2023 22:22:50 +0000 (17:22 -0500)]
Rename OutboundOnionPayload::BlindedReceive::outgoing_cltv_value.
There is no outgoing HTLC for received HTLCs, so rename to be more accurate.
Valentine Wallace [Wed, 13 Dec 2023 22:18:56 +0000 (17:18 -0500)]
Rename OutboundOnionPayload::Receive::outgoing_cltv_value.
There is no outgoing HTLC for received HTLCs, so rename to be more accurate.