Skip to content

Commit c5af1c3

Browse files
committed
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.
1 parent 61e5819 commit c5af1c3

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

lightning/src/ln/channel.rs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5517,6 +5517,9 @@ where
55175517
funding
55185518
.channel_transaction_parameters.funding_outpoint = Some(outpoint);
55195519

5520+
self.channel_state = ChannelState::FundingNegotiated(FundingNegotiatedFlags::new());
5521+
self.channel_state.set_interactive_signing();
5522+
55205523
if is_splice {
55215524
debug_assert_eq!(
55225525
holder_commitment_transaction_number,
@@ -5580,10 +5583,6 @@ where
55805583
});
55815584
};
55825585

5583-
let mut channel_state = ChannelState::FundingNegotiated(FundingNegotiatedFlags::new());
5584-
channel_state.set_interactive_signing();
5585-
self.channel_state = channel_state;
5586-
55875586
Ok((commitment_signed, funding_ready_for_sig_event))
55885587
}
55895588

@@ -5636,16 +5635,7 @@ where
56365635
SP::Target: SignerProvider,
56375636
L::Target: Logger
56385637
{
5639-
if !matches!(
5640-
self.channel_state, ChannelState::NegotiatingFunding(flags)
5641-
if flags == (NegotiatingFundingFlags::OUR_INIT_SENT | NegotiatingFundingFlags::THEIR_INIT_SENT)
5642-
) {
5643-
debug_assert!(false);
5644-
let msg = "Tried to get an initial commitment_signed messsage at a time other than \
5645-
immediately after initial handshake completion (or tried to get funding_created twice)";
5646-
let reason = ClosureReason::ProcessingError { err: msg.to_owned() };
5647-
return Err(ChannelError::Close((msg.to_owned(), reason)));
5648-
}
5638+
assert!(matches!(self.channel_state, ChannelState::FundingNegotiated(flags) if flags.is_interactive_signing()));
56495639

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

0 commit comments

Comments
 (0)