Skip to content

Commit 94f6051

Browse files
committed
Add RefundingChannel, that can act as both funded and pendingV2
1 parent cd1b44e commit 94f6051

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

lightning/src/ln/channel.rs

+71
Original file line numberDiff line numberDiff line change
@@ -2618,6 +2618,77 @@ impl<SP: Deref> PendingV2ChannelTrait<SP> for PendingV2Channel<SP> where SP::Tar
26182618
}
26192619
}
26202620

2621+
#[cfg(splicing)]
2622+
struct RefundingChannel<SP: Deref> where SP::Target: SignerProvider {
2623+
funded_channel: FundedChannel<SP>,
2624+
2625+
// Fields belonging for PendingV2Channel, except duplicate context
2626+
pending_funding: FundingScope,
2627+
// Note: there is a single context
2628+
pending_unfunded_context: UnfundedChannelContext,
2629+
pending_dual_funding_context: DualFundingChannelContext,
2630+
/// The current interactive transaction construction session under negotiation.
2631+
pending_interactive_tx_constructor: Option<InteractiveTxConstructor>,
2632+
pending_interactive_tx_signing_session: Option<InteractiveTxSigningSession>,
2633+
}
2634+
2635+
#[cfg(splicing)]
2636+
impl<SP: Deref> PendingV2ChannelTrait<SP> for RefundingChannel<SP> where SP::Target: SignerProvider {
2637+
#[inline]
2638+
fn context(&self) -> &ChannelContext<SP> {
2639+
&self.funded_channel.context
2640+
}
2641+
2642+
#[inline]
2643+
fn context_mut(&mut self) -> &mut ChannelContext<SP> {
2644+
&mut self.funded_channel.context
2645+
}
2646+
2647+
#[inline]
2648+
fn funding(&self) -> &FundingScope {
2649+
&self.pending_funding
2650+
}
2651+
2652+
#[inline]
2653+
fn funding_mut(&mut self) -> &mut FundingScope {
2654+
&mut self.pending_funding
2655+
}
2656+
2657+
#[inline]
2658+
fn funding_and_context_mut(&mut self) -> (&mut FundingScope, &mut ChannelContext<SP>) {
2659+
(&mut self.pending_funding, &mut self.funded_channel.context)
2660+
}
2661+
2662+
#[inline]
2663+
fn dual_funding_context(&self) -> &DualFundingChannelContext {
2664+
&self.pending_dual_funding_context
2665+
}
2666+
2667+
fn swap_out_dual_funding_context_inputs(&mut self, funding_inputs: &mut Vec<(TxIn, TransactionU16LenLimited)>) {
2668+
mem::swap(&mut self.pending_dual_funding_context.our_funding_inputs, funding_inputs);
2669+
}
2670+
2671+
#[inline]
2672+
fn unfunded_context(&self) -> &UnfundedChannelContext {
2673+
&self.pending_unfunded_context
2674+
}
2675+
2676+
#[inline]
2677+
fn interactive_tx_constructor(&self) -> Option<&InteractiveTxConstructor> {
2678+
self.pending_interactive_tx_constructor.as_ref()
2679+
}
2680+
2681+
#[inline]
2682+
fn interactive_tx_constructor_mut(&mut self) -> &mut Option<InteractiveTxConstructor> {
2683+
&mut self.pending_interactive_tx_constructor
2684+
}
2685+
2686+
#[inline]
2687+
fn interactive_tx_signing_session_mut(&mut self) -> &mut Option<InteractiveTxSigningSession> {
2688+
&mut self.pending_interactive_tx_signing_session
2689+
}
2690+
}
2691+
26212692
impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
26222693
fn new_for_inbound_channel<'a, ES: Deref, F: Deref, L: Deref>(
26232694
fee_estimator: &'a LowerBoundedFeeEstimator<F>,

0 commit comments

Comments
 (0)