Skip to content

Commit 3294c46

Browse files
committed
Allow writing V2 channels that are in a Funded phase
We allow persisting `FundedChannel`s in a `ChannelState::FundingNegotiated` only if the holder commitment number has advanced to the second commitment number. Currently we don't need new persistence, but we will need to persist some information such as `tx_signatures` when we allow contributing funds to dual-funded channels.
1 parent 9739331 commit 3294c46

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lightning/src/ln/channel.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9646,7 +9646,14 @@ impl<SP: Deref> Writeable for FundedChannel<SP> where SP::Target: SignerProvider
96469646
self.context.channel_id.write(writer)?;
96479647
{
96489648
let mut channel_state = self.context.channel_state;
9649-
if matches!(channel_state, ChannelState::AwaitingChannelReady(_)|ChannelState::ChannelReady(_)) {
9649+
if matches!(channel_state, ChannelState::AwaitingChannelReady(_)|ChannelState::ChannelReady(_))
9650+
{
9651+
channel_state.set_peer_disconnected();
9652+
} else if matches!(channel_state, ChannelState::FundingNegotiated) &&
9653+
self.holder_commitment_point.transaction_number() == INITIAL_COMMITMENT_NUMBER - 1 {
9654+
// This is a V2 session which has an active signing session
9655+
// TODO(dual_funding): When we allow contributing funds to dual-funded channels,
9656+
// we will need to handle persisting appropriate signing session state.
96509657
channel_state.set_peer_disconnected();
96519658
} else {
96529659
debug_assert!(false, "Pre-funded/shutdown channels should not be written");

0 commit comments

Comments
 (0)