Skip to content

Update channel_reestablish for splicing #3886

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

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Enter FundingNegotiated state after constructing funding tx
The ChannelState::NegotiatingFunding assertion check in
ChannelContext::get_initial_commitment_signed will fail when
implementing splicing's channel_reestablish logic. In order to support
it and channel establishment, enter ChannelState::FundingNegotiated
prior to calling the method and update the assertion accordingly.
  • Loading branch information
jkczyz committed Jul 11, 2025
commit ab5ccd13addc5d6f58826dd581dbb96642ad5a7d
18 changes: 4 additions & 14 deletions lightning/src/ln/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2960,6 +2960,8 @@ where
};
self.funding.channel_transaction_parameters.funding_outpoint = Some(outpoint);

self.context.channel_state = ChannelState::FundingNegotiated(FundingNegotiatedFlags::new());

self.context.assert_no_commitment_advancement(transaction_number, "initial commitment_signed");
let commitment_signed = self.context.get_initial_commitment_signed(&self.funding, logger);
let commitment_signed = match commitment_signed {
Expand Down Expand Up @@ -3008,13 +3010,10 @@ where
)));
};

let mut channel_state = ChannelState::FundingNegotiated(FundingNegotiatedFlags::new());
channel_state.set_interactive_signing();
self.context.channel_state = channel_state;

// Clear the interactive transaction constructor
self.interactive_tx_constructor.take();
self.interactive_tx_signing_session = Some(signing_session);
self.context.channel_state.set_interactive_signing();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not set the flag above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are other error conditions, which could prevent us from assigning interactive_tx_signing_session to Some.

Copy link
Contributor

Choose a reason for hiding this comment

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

Aren't those unreachable though?


Ok((commitment_signed, funding_ready_for_sig_event))
}
Expand Down Expand Up @@ -5530,16 +5529,7 @@ where
SP::Target: SignerProvider,
L::Target: Logger
{
if !matches!(
self.channel_state, ChannelState::NegotiatingFunding(flags)
if flags == (NegotiatingFundingFlags::OUR_INIT_SENT | NegotiatingFundingFlags::THEIR_INIT_SENT)
) {
debug_assert!(false);
return Err(ChannelError::Close(("Tried to get an initial commitment_signed messsage at a time other than \
immediately after initial handshake completion (or tried to get funding_created twice)".to_string(),
ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(true) }
)));
}
assert!(matches!(self.channel_state, ChannelState::FundingNegotiated(_)));

let signature = match self.get_initial_counterparty_commitment_signature(funding, logger) {
Ok(res) => res,
Expand Down