Skip to content

Commit 271a6a2

Browse files
committed
Add RefundingChannel, that can act as both funded and pendingV2
1 parent 77fc455 commit 271a6a2

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed

lightning/src/ln/channel.rs

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2449,6 +2449,100 @@ impl<SP: Deref> PendingV2ChannelTrait<SP> for PendingV2Channel<SP> where SP::Tar
24492449
}
24502450
}
24512451

2452+
#[cfg(splicing)]
2453+
struct RefundingChannel<SP: Deref> where SP::Target: SignerProvider {
2454+
funded_channel: FundedChannel<SP>,
2455+
2456+
// Fields belonging for PendingV2Channel, except duplicate context
2457+
pending_funding: FundingScope,
2458+
// Note: there is a single context
2459+
pending_unfunded_context: UnfundedChannelContext,
2460+
pending_dual_funding_context: DualFundingChannelContext,
2461+
/// The current interactive transaction construction session under negotiation.
2462+
pending_interactive_tx_constructor: Option<InteractiveTxConstructor>,
2463+
pending_interactive_tx_signing_session: Option<InteractiveTxSigningSession>,
2464+
}
2465+
2466+
/*
2467+
#[cfg(splicing)]
2468+
impl<SP: Deref> InitialRemoteCommitmentReceiver<SP> for RefundingChannel<SP> where SP::Target: SignerProvider {
2469+
#[inline]
2470+
fn context(&self) -> &ChannelContext<SP> {
2471+
&self.funded_channel.context
2472+
}
2473+
2474+
#[inline]
2475+
fn context_mut(&mut self) -> &mut ChannelContext<SP> {
2476+
&mut self.funded_channel.context
2477+
}
2478+
2479+
#[inline]
2480+
fn funding(&self) -> &FundingScope {
2481+
&self.funded_channel.funding
2482+
}
2483+
2484+
#[inline]
2485+
fn funding_mut(&mut self) -> &mut FundingScope {
2486+
&mut self.funded_channel.funding
2487+
}
2488+
2489+
fn received_msg(&self) -> &'static str {
2490+
"commitment_signed" // TODO ?
2491+
}
2492+
}
2493+
*/
2494+
2495+
#[cfg(splicing)]
2496+
impl<SP: Deref> PendingV2ChannelTrait<SP> for RefundingChannel<SP> where SP::Target: SignerProvider {
2497+
#[inline]
2498+
fn context(&self) -> &ChannelContext<SP> {
2499+
&self.funded_channel.context
2500+
}
2501+
2502+
#[inline]
2503+
fn context_mut(&mut self) -> &mut ChannelContext<SP> {
2504+
&mut self.funded_channel.context
2505+
}
2506+
2507+
#[inline]
2508+
fn funding(&self) -> &FundingScope {
2509+
&self.pending_funding
2510+
}
2511+
2512+
#[inline]
2513+
fn funding_mut(&mut self) -> &mut FundingScope {
2514+
&mut self.pending_funding
2515+
}
2516+
2517+
#[inline]
2518+
fn funding_and_context_mut(&mut self) -> (&mut FundingScope, &mut ChannelContext<SP>) {
2519+
(&mut self.pending_funding, &mut self.funded_channel.context)
2520+
}
2521+
2522+
#[inline]
2523+
fn dual_funding_context(&self) -> &DualFundingChannelContext {
2524+
&self.pending_dual_funding_context
2525+
}
2526+
2527+
#[inline]
2528+
fn unfunded_context(&self) -> &UnfundedChannelContext {
2529+
&self.pending_unfunded_context
2530+
}
2531+
2532+
#[inline]
2533+
fn interactive_tx_constructor_mut(&mut self) -> Option<&mut InteractiveTxConstructor> {
2534+
self.pending_interactive_tx_constructor.as_mut()
2535+
}
2536+
2537+
fn clear_interactive_tx_constructor(&mut self) {
2538+
self.pending_interactive_tx_constructor.take();
2539+
}
2540+
2541+
fn set_interactive_tx_signing_session(&mut self, session: InteractiveTxSigningSession) {
2542+
self.pending_interactive_tx_signing_session = Some(session);
2543+
}
2544+
}
2545+
24522546
impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
24532547
fn new_for_inbound_channel<'a, ES: Deref, F: Deref, L: Deref>(
24542548
fee_estimator: &'a LowerBoundedFeeEstimator<F>,

0 commit comments

Comments
 (0)