Skip to content

Commit 02cc54a

Browse files
committed
Add RefundingChannel, that can act as both funded and pendingV2
1 parent b5fb8a3 commit 02cc54a

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

lightning/src/ln/channel.rs

+78
Original file line numberDiff line numberDiff line change
@@ -2627,6 +2627,84 @@ impl<SP: Deref> PendingV2ChannelTrait<SP> for PendingV2Channel<SP> where SP::Tar
26272627
}
26282628
}
26292629

2630+
#[cfg(splicing)]
2631+
struct RefundingChannel<SP: Deref> where SP::Target: SignerProvider {
2632+
funded_channel: FundedChannel<SP>,
2633+
2634+
// Fields belonging for PendingV2Channel, except duplicate context
2635+
pending_funding: FundingScope,
2636+
// Note: there is a single context
2637+
pending_unfunded_context: UnfundedChannelContext,
2638+
pending_dual_funding_context: DualFundingChannelContext,
2639+
/// The current interactive transaction construction session under negotiation.
2640+
pending_interactive_tx_constructor: Option<InteractiveTxConstructor>,
2641+
pending_interactive_tx_signing_session: Option<InteractiveTxSigningSession>,
2642+
}
2643+
2644+
#[cfg(splicing)]
2645+
impl<SP: Deref> PendingV2ChannelTrait<SP> for RefundingChannel<SP> where SP::Target: SignerProvider {
2646+
#[inline]
2647+
fn context(&self) -> &ChannelContext<SP> {
2648+
&self.funded_channel.context
2649+
}
2650+
2651+
#[inline]
2652+
fn context_mut(&mut self) -> &mut ChannelContext<SP> {
2653+
&mut self.funded_channel.context
2654+
}
2655+
2656+
#[inline]
2657+
fn funding(&self) -> &FundingScope {
2658+
&self.pending_funding
2659+
}
2660+
2661+
#[inline]
2662+
fn funding_mut(&mut self) -> &mut FundingScope {
2663+
&mut self.pending_funding
2664+
}
2665+
2666+
#[inline]
2667+
fn funding_and_context_mut(&mut self) -> (&mut FundingScope, &mut ChannelContext<SP>) {
2668+
(&mut self.pending_funding, &mut self.funded_channel.context)
2669+
}
2670+
2671+
#[inline]
2672+
fn dual_funding_context(&self) -> &DualFundingChannelContext {
2673+
&self.pending_dual_funding_context
2674+
}
2675+
2676+
fn swap_out_dual_funding_context_inputs(&mut self, funding_inputs: &mut Vec<(TxIn, TransactionU16LenLimited)>) {
2677+
mem::swap(&mut self.pending_dual_funding_context.our_funding_inputs, funding_inputs);
2678+
}
2679+
2680+
#[inline]
2681+
fn unfunded_context(&self) -> &UnfundedChannelContext {
2682+
&self.pending_unfunded_context
2683+
}
2684+
2685+
#[inline]
2686+
fn interactive_tx_constructor(&self) -> Option<&InteractiveTxConstructor> {
2687+
self.pending_interactive_tx_constructor.as_ref()
2688+
}
2689+
2690+
#[inline]
2691+
fn interactive_tx_constructor_mut(&mut self) -> Option<&mut InteractiveTxConstructor> {
2692+
self.pending_interactive_tx_constructor.as_mut()
2693+
}
2694+
2695+
fn set_interactive_tx_constructor(&mut self, iatxc: Option<InteractiveTxConstructor>) {
2696+
self.pending_interactive_tx_constructor = iatxc;
2697+
}
2698+
2699+
fn clear_interactive_tx_constructor(&mut self) {
2700+
self.pending_interactive_tx_constructor.take();
2701+
}
2702+
2703+
fn set_interactive_tx_signing_session(&mut self, session: InteractiveTxSigningSession) {
2704+
self.pending_interactive_tx_signing_session = Some(session);
2705+
}
2706+
}
2707+
26302708
impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
26312709
fn new_for_inbound_channel<'a, ES: Deref, F: Deref, L: Deref>(
26322710
fee_estimator: &'a LowerBoundedFeeEstimator<F>,

0 commit comments

Comments
 (0)