Skip to content

Commit 01ba29d

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 01ba29d

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

lightning/src/ln/channel.rs

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

5520+
self.channel_state = ChannelState::FundingNegotiated(FundingNegotiatedFlags::new());
5521+
55205522
if is_splice {
55215523
debug_assert_eq!(
55225524
holder_commitment_transaction_number,
@@ -5580,9 +5582,7 @@ where
55805582
});
55815583
};
55825584

5583-
let mut channel_state = ChannelState::FundingNegotiated(FundingNegotiatedFlags::new());
5584-
channel_state.set_interactive_signing();
5585-
self.channel_state = channel_state;
5585+
self.channel_state.set_interactive_signing();
55865586

55875587
Ok((commitment_signed, funding_ready_for_sig_event))
55885588
}
@@ -5636,16 +5636,7 @@ where
56365636
SP::Target: SignerProvider,
56375637
L::Target: Logger
56385638
{
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-
}
5639+
assert!(matches!(self.channel_state, ChannelState::FundingNegotiated(_)));
56495640

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

0 commit comments

Comments
 (0)