Skip to content

Commit b729f2c

Browse files
committed
Allow writing V2 channels that are in a Funded phase
We allow persisting `Channel`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 5da2e5a commit b729f2c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lightning/src/ln/channel.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -9239,7 +9239,14 @@ impl<SP: Deref> Writeable for Channel<SP> where SP::Target: SignerProvider {
92399239
self.context.channel_id.write(writer)?;
92409240
{
92419241
let mut channel_state = self.context.channel_state;
9242-
if matches!(channel_state, ChannelState::AwaitingChannelReady(_)|ChannelState::ChannelReady(_)) {
9242+
if matches!(channel_state, ChannelState::AwaitingChannelReady(_)|ChannelState::ChannelReady(_))
9243+
{
9244+
channel_state.set_peer_disconnected();
9245+
} else if matches!(channel_state, ChannelState::FundingNegotiated) &&
9246+
self.context.holder_commitment_point.transaction_number() == INITIAL_COMMITMENT_NUMBER - 1 {
9247+
// This is a V2 session which has an active signing session
9248+
// TODO(dual_funding): When we allow contributing funds to dual-funded channels,
9249+
// we will need to handle persisting appropriate signing session state.
92439250
channel_state.set_peer_disconnected();
92449251
} else {
92459252
debug_assert!(false, "Pre-funded/shutdown channels should not be written");

0 commit comments

Comments
 (0)