Skip to content

Commit

Permalink
Allow writing V2 channels that are in a Funded phase
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dunxen committed Dec 6, 2024
1 parent 56812cd commit 38e43b2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lightning/src/ln/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9239,7 +9239,14 @@ impl<SP: Deref> Writeable for Channel<SP> where SP::Target: SignerProvider {
self.context.channel_id.write(writer)?;
{
let mut channel_state = self.context.channel_state;
if matches!(channel_state, ChannelState::AwaitingChannelReady(_)|ChannelState::ChannelReady(_)) {
if matches!(channel_state, ChannelState::AwaitingChannelReady(_)|ChannelState::ChannelReady(_))
{
channel_state.set_peer_disconnected();
} else if matches!(channel_state, ChannelState::FundingNegotiated) &&
self.context.holder_commitment_point.transaction_number() == INITIAL_COMMITMENT_NUMBER - 1 {
// This is a V2 session which has an active signing session
// TODO(dual_funding): When we allow contributing funds to dual-funded channels,
// we will need to handle persisting appropriate signing session state.
channel_state.set_peer_disconnected();
} else {
debug_assert!(false, "Pre-funded/shutdown channels should not be written");
Expand Down

0 comments on commit 38e43b2

Please sign in to comment.