Skip to content

Expose temporary channel ID and user channel ID pre-funding #1121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 16, 2021

Conversation

TheBlueMatt
Copy link
Collaborator

Its pretty hard for users to track a channel pre-funding to ChannelClosed especially when our counterparty closed the channel due to a parameter mismatch. This resolves that with more data in the relevant events.

This makes it more practical for users to track channels prior to
funding, especially if the channel fails because the peer rejects
it for a parameter mismatch.
This makes it more practical for users to track channels using
their own IDs, especially across funding.
@codecov
Copy link

codecov bot commented Oct 13, 2021

Codecov Report

Merging #1121 (347c49e) into main (2144166) will increase coverage by 1.16%.
The diff coverage is 63.63%.

❗ Current head 347c49e differs from pull request most recent head bb7ef6c. Consider uploading reports for the commit bb7ef6c to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1121      +/-   ##
==========================================
+ Coverage   90.67%   91.83%   +1.16%     
==========================================
  Files          66       66              
  Lines       34732    39174    +4442     
==========================================
+ Hits        31492    35977    +4485     
+ Misses       3240     3197      -43     
Impacted Files Coverage Δ
lightning/src/routing/router.rs 96.04% <ø> (ø)
lightning/src/ln/channelmanager.rs 85.24% <53.84%> (+0.08%) ⬆️
lightning/src/ln/functional_test_utils.rs 96.92% <100.00%> (+1.83%) ⬆️
lightning/src/util/events.rs 33.33% <100.00%> (+0.92%) ⬆️
lightning/src/chain/mod.rs 50.00% <0.00%> (-8.83%) ⬇️
lightning/src/ln/onion_route_tests.rs 96.52% <0.00%> (-0.12%) ⬇️
lightning/src/ln/monitor_tests.rs 100.00% <0.00%> (ø)
lightning-background-processor/src/lib.rs 94.38% <0.00%> (+0.15%) ⬆️
lightning-persister/src/lib.rs 94.96% <0.00%> (+0.74%) ⬆️
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2144166...bb7ef6c. Read the comment docs.

Copy link
Contributor

@arik-so arik-so left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're gonna keep a user id around, it might be helpful to have the abilitty to set a channel's user id (just once), so once an iincoming channel is persisted to some local database, it's easier to keep track of.

/// [`Event::FundingGenerationReady`]: events::Event::FundingGenerationReady
/// [`Event::FundingGenerationReady::temporary_channel_id`]: events::Event::FundingGenerationReady::temporary_channel_id
/// [`Event::ChannelClosed::channel_id`]: events::Event::ChannelClosed::channel_id
pub fn create_channel(&self, their_network_key: PublicKey, channel_value_satoshis: u64, push_msat: u64, user_id: u64, override_config: Option<UserConfig>) -> Result<[u8; 32], APIError> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to create a type alias for the channel id here instead of just [u8; 32]?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, maybe lets do that as a part of addressing #105? We'll want to separate the types out between temporary channel ids and permanent ones, I think.

@TheBlueMatt
Copy link
Collaborator Author

If we're gonna keep a user id around, it might be helpful to have the abilitty to set a channel's user id (just once), so once an iincoming channel is persisted to some local database, it's easier to keep track of.

Yea, there's a few things we should probably consider for the user id, since its not new or (materially) changed in this PR, lets leave it for a followup and figure out what we want to do with it in #1125.

Copy link
Contributor

@valentinewallace valentinewallace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor suggestions only

@TheBlueMatt TheBlueMatt added this to the 0.0.102 milestone Oct 15, 2021
Copy link
Contributor

@jkczyz jkczyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine with holding off on decision on channel_user_id as per #1125.

@TheBlueMatt
Copy link
Collaborator Author

Oops, sorry, fixed missing renames for user_id.

@TheBlueMatt TheBlueMatt force-pushed the 2021-10-return-temp-id branch from 347c49e to 656a4a1 Compare October 16, 2021 00:25
@TheBlueMatt TheBlueMatt force-pushed the 2021-10-return-temp-id branch from 656a4a1 to bb7ef6c Compare October 16, 2021 00:27
@TheBlueMatt
Copy link
Collaborator Author

Squashed the fixup commit down, diff since Jeff's ACK:

$ git diff-tree -U1 347c49e1 bb7ef6c29
diff --git a/fuzz/src/router.rs b/fuzz/src/router.rs
index 6c792916f..b80a8284e 100644
--- a/fuzz/src/router.rs
+++ b/fuzz/src/router.rs
@@ -218,3 +218,3 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
 								channel_value_satoshis: slice_to_be64(get_slice!(8)),
-								user_id: 0, inbound_capacity_msat: 0,
+								user_channel_id: 0, inbound_capacity_msat: 0,
 								unspendable_punishment_reserve: None,
$ 

@TheBlueMatt
Copy link
Collaborator Author

Diff since Val's ACK is also just one trivial variable rename, so gonna take this. Gotta wait on #1127 anyway:

$ git diff-tree -U1 539bb6d0aed0c0cc273f78ec3c29b7aeaec64ac0 bb7ef6c2901a9582e19511ab0a974d1de3ef1205
diff --git a/fuzz/src/router.rs b/fuzz/src/router.rs
index 6c792916f..b80a8284e 100644
--- a/fuzz/src/router.rs
+++ b/fuzz/src/router.rs
@@ -218,3 +218,3 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
 								channel_value_satoshis: slice_to_be64(get_slice!(8)),
-								user_id: 0, inbound_capacity_msat: 0,
+								user_channel_id: 0, inbound_capacity_msat: 0,
 								unspendable_punishment_reserve: None,
diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs
index 7f4caacfc..0106fe51d 100644
--- a/lightning/src/ln/channelmanager.rs
+++ b/lightning/src/ln/channelmanager.rs
@@ -778,4 +778,4 @@ pub struct ChannelDetails {
 	pub unspendable_punishment_reserve: Option<u64>,
-	/// The user_id passed in to create_channel, or 0 if the channel was inbound.
-	pub user_id: u64,
+	/// The `user_channel_id` passed in to create_channel, or 0 if the channel was inbound.
+	pub user_channel_id: u64,
 	/// The available outbound capacity for sending HTLCs to the remote peer. This does not include
@@ -1363,3 +1363,3 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
 					outbound_capacity_msat,
-					user_id: channel.get_user_id(),
+					user_channel_id: channel.get_user_id(),
 					confirmations_required: channel.minimum_depth(),
diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs
index d6adb889d..9e02e10f9 100644
--- a/lightning/src/routing/router.rs
+++ b/lightning/src/routing/router.rs
@@ -1329,3 +1329,3 @@ mod tests {
 			channel_value_satoshis: 0,
-			user_id: 0,
+			user_channel_id: 0,
 			outbound_capacity_msat,
diff --git a/lightning/src/util/events.rs b/lightning/src/util/events.rs
index 8502f9be4..7ea369f55 100644
--- a/lightning/src/util/events.rs
+++ b/lightning/src/util/events.rs
@@ -148,4 +148,4 @@ pub enum Event {
 		output_script: Script,
-		/// The `user_id` value passed in to [`ChannelManager::create_channel`], or 0 for an
-		/// inbound channel.
+		/// The `user_channel_id` value passed in to [`ChannelManager::create_channel`], or 0 for
+		/// an inbound channel.
 		///
@@ -267,4 +267,4 @@ pub enum Event {
 		channel_id: [u8; 32],
-		/// The `user_id` value passed in to [`ChannelManager::create_channel`], or 0 for an
-		/// inbound channel. This will always be zero for objects serialized with LDK versions
+		/// The `user_channel_id` value passed in to [`ChannelManager::create_channel`], or 0 for
+		/// an inbound channel. This will always be zero for objects serialized with LDK versions
 		/// prior to 0.0.102.
$

@TheBlueMatt TheBlueMatt merged commit 001bc71 into lightningdevkit:main Oct 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants