Skip to content

Commit 2010c72

Browse files
committed
Add RefundingV2 phase (for splicing)
1 parent 45a6b1f commit 2010c72

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

lightning/src/ln/channel.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,6 +1148,9 @@ enum ChannelPhase<SP: Deref> where SP::Target: SignerProvider {
11481148
#[allow(dead_code)] // TODO(dual_funding): Remove once creating V2 channels is enabled.
11491149
UnfundedV2(PendingV2Channel<SP>),
11501150
Funded(FundedChannel<SP>),
1151+
#[cfg(splicing)]
1152+
/// Used during splicing, channel is funded but a new funding is being renegotiated.
1153+
RefundingV2(FundedChannel<SP>),
11511154
}
11521155

11531156
impl<SP: Deref> Channel<SP> where
@@ -1161,6 +1164,8 @@ impl<SP: Deref> Channel<SP> where
11611164
ChannelPhase::UnfundedOutboundV1(chan) => &chan.context,
11621165
ChannelPhase::UnfundedInboundV1(chan) => &chan.context,
11631166
ChannelPhase::UnfundedV2(chan) => &chan.context,
1167+
#[cfg(splicing)]
1168+
ChannelPhase::RefundingV2(chan) => &chan.context,
11641169
}
11651170
}
11661171

@@ -1171,6 +1176,8 @@ impl<SP: Deref> Channel<SP> where
11711176
ChannelPhase::UnfundedOutboundV1(chan) => &mut chan.context,
11721177
ChannelPhase::UnfundedInboundV1(chan) => &mut chan.context,
11731178
ChannelPhase::UnfundedV2(chan) => &mut chan.context,
1179+
#[cfg(splicing)]
1180+
ChannelPhase::RefundingV2(ref mut chan) => &mut chan.context,
11741181
}
11751182
}
11761183

@@ -1181,6 +1188,8 @@ impl<SP: Deref> Channel<SP> where
11811188
ChannelPhase::UnfundedOutboundV1(chan) => Some(&mut chan.unfunded_context),
11821189
ChannelPhase::UnfundedInboundV1(chan) => Some(&mut chan.unfunded_context),
11831190
ChannelPhase::UnfundedV2(chan) => Some(&mut chan.unfunded_context),
1191+
#[cfg(splicing)]
1192+
ChannelPhase::RefundingV2(_) => { debug_assert!(false); None },
11841193
}
11851194
}
11861195

@@ -1288,6 +1297,8 @@ impl<SP: Deref> Channel<SP> where
12881297
})
12891298
},
12901299
ChannelPhase::UnfundedV2(_) => None,
1300+
#[cfg(splicing)]
1301+
ChannelPhase::RefundingV2(chan) => Some(chan.signer_maybe_unblocked(logger)),
12911302
}
12921303
}
12931304

@@ -1307,6 +1318,8 @@ impl<SP: Deref> Channel<SP> where
13071318
ChannelPhase::UnfundedOutboundV1(chan) => chan.is_resumable(),
13081319
ChannelPhase::UnfundedInboundV1(_) => false,
13091320
ChannelPhase::UnfundedV2(_) => false,
1321+
#[cfg(splicing)]
1322+
ChannelPhase::RefundingV2(chan) => chan.remove_uncommitted_htlcs_and_mark_paused(logger).is_ok(),
13101323
}
13111324
}
13121325

@@ -1347,6 +1360,9 @@ impl<SP: Deref> Channel<SP> where
13471360
},
13481361
#[cfg(not(dual_funding))]
13491362
ChannelPhase::UnfundedV2(_) => ReconnectionMsg::None,
1363+
#[cfg(splicing)]
1364+
ChannelPhase::RefundingV2(chan) =>
1365+
ReconnectionMsg::Reestablish(chan.get_channel_reestablish(logger)),
13501366
}
13511367
}
13521368

@@ -1380,6 +1396,8 @@ impl<SP: Deref> Channel<SP> where
13801396
debug_assert!(false);
13811397
Ok(None)
13821398
},
1399+
#[cfg(splicing)]
1400+
ChannelPhase::RefundingV2(_) => Ok(None),
13831401
}
13841402
}
13851403

0 commit comments

Comments
 (0)