Skip to content
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

Funding signed event #3024

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jbesraa
Copy link
Contributor

@jbesraa jbesraa commented Apr 25, 2024

resolves #3023

@codecov-commenter
Copy link

codecov-commenter commented Apr 25, 2024

Codecov Report

Attention: Patch coverage is 87.55365% with 29 lines in your changes are missing coverage. Please review.

Project coverage is 89.15%. Comparing base (8701b1b) to head (20313c8).

Files Patch % Lines
lightning/src/events/mod.rs 0.00% 22 Missing ⚠️
lightning/src/ln/channel.rs 96.31% 3 Missing and 3 partials ⚠️
lightning/src/ln/functional_test_utils.rs 87.50% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3024      +/-   ##
==========================================
- Coverage   89.16%   89.15%   -0.02%     
==========================================
  Files         118      118              
  Lines       97726    97947     +221     
  Branches    97726    97947     +221     
==========================================
+ Hits        87137    87320     +183     
- Misses       8348     8381      +33     
- Partials     2241     2246       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

/// [`ChannelManager::create_channel`]: crate::ln::channelmanager::ChannelManager::create_channel
/// [`ChannelManager::accept_inbound_channel`]: crate::ln::channelmanager::ChannelManager::accept_inbound_channel
/// [`UserConfig::manually_accept_inbound_channels`]: crate::util::config::UserConfig::manually_accept_inbound_channels
user_channel_id: u128,
Copy link
Contributor

Choose a reason for hiding this comment

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

You should give the funding tx to broadcast

  Add a new flag to `UserConfig` and `ChannelContext`
  to allow users to broadcast an outbound channel funding transaction
  manually and halt the automatic broadcasting from LDK.
@jbesraa jbesraa force-pushed the funding-signed-event branch 2 times, most recently from e9ffefc to d48453a Compare April 29, 2024 09:21
@jbesraa jbesraa marked this pull request as ready for review April 29, 2024 11:51
@@ -2864,6 +2865,23 @@ macro_rules! send_channel_ready {
}
}}
}
macro_rules! emit_funding_signed_event {
($locked_events: expr, $channel: expr) => {
let funding_tx = $channel.context.get_funding_transaction(); // hmm.. this is always none?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the funding_transaction is None while it should be defined at this stage as we are after FundingCreated.. what could be the reason for this?

@@ -646,6 +646,7 @@ mod state_flags {
pub const LOCAL_SHUTDOWN_SENT: u32 = 1 << 11;
pub const SHUTDOWN_COMPLETE: u32 = 1 << 12;
pub const WAITING_FOR_BATCH: u32 = 1 << 13;
pub const FUNDING_SIGNED: u32 = 1 << 14;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

FUNDING_SIGNED is added as part of AwaitingChannelReadyFlags and not a whole new thing

  If `manually_broadcast_outbound_channels` is set, LDK will emit this
  event after the counterparty node send the `FundingSigned` msg without
  broadcasting the funding transaction.
expect_funding_signed_event(&nodes[0]);
nodes[0].node.get_and_clear_pending_msg_events();
mine_transaction(&nodes[0], &tx);
expect_channel_ready_event(&nodes[0], &nodes[1].node.get_our_node_id());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As you can see here, the channel goes from FundingSigned to ChannelReady and does not go to ChannelPending. the main reason I followed this as that ChannelPending expects the funding transaction to broadcastable.

@@ -810,6 +810,8 @@ pub struct UserConfig {
///
/// [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
pub accept_mpp_keysend: bool,
/// broadcast funding transaction manually
pub manually_broadcast_outbound_channels: bool,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, is it best to do this via a config or via a different method to pass LDK the funding transaction? A config seems to imply people might want to just turn this on, but really its a totally differnet flow, and maybe thus makes sense as a different method since it'll change the programming entirely?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok ill give that a try to see how that works.

What do you think about the next event after FundingSigned? In the current implementation its going from FundingSigned to ChannelReady ie skips the ChannelPending. I did that because in the code ChannelPending = "funding is ready and signed, just wait for confirmations", but that is not accurate for all cases. in payjoin scenario we never really know that the funding is fully signed and broadcasted.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, we should probably keep ChannelPending, I think - its pending from the lightning POV, just something else is dealing with broadcasting.

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.

Add FundingSigned event
4 participants