Skip to content

Commit 2f9a0c1

Browse files
committed
fix Get rid of unfunded_context reference in Refunding
1 parent 62ec2b0 commit 2f9a0c1

File tree

1 file changed

+12
-24
lines changed

1 file changed

+12
-24
lines changed

lightning/src/ln/channel.rs

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,10 +1258,9 @@ impl<SP: Deref> Channel<SP> where
12581258
#[cfg(not(splicing))]
12591259
ChannelPhase::Funded(_) => { debug_assert!(false); None }
12601260
#[cfg(splicing)]
1261-
ChannelPhase::Funded(chan) => {
1262-
chan.pending_splice.as_mut().and_then(|splice|
1263-
splice.refunding_scope.as_mut().map(|refunding_scope| &mut refunding_scope.pending_unfunded_context)
1264-
)
1261+
ChannelPhase::Funded(_chan) => {
1262+
debug_assert!(false, "FundedChannel is not unfunded!");
1263+
None
12651264
}
12661265
ChannelPhase::UnfundedOutboundV1(chan) => Some(&mut chan.unfunded_context),
12671266
ChannelPhase::UnfundedInboundV1(chan) => Some(&mut chan.unfunded_context),
@@ -2438,6 +2437,8 @@ impl<SP: Deref> InitialRemoteCommitmentReceiver<SP> for FundedChannel<SP> where
24382437
struct FundedChannelRefundingWrapper<'a, SP: Deref> where SP::Target: SignerProvider {
24392438
channel_context: &'a mut ChannelContext<SP>,
24402439
refunding_scope: &'a mut RefundingScope,
2440+
/// For accessing commitment transaction number
2441+
holder_commitment_point: &'a HolderCommitmentPoint,
24412442
}
24422443

24432444
#[cfg(splicing)]
@@ -2480,9 +2481,8 @@ impl<'a, SP: Deref> FundingTxConstructorV2<SP> for FundedChannelRefundingWrapper
24802481
&mut self.refunding_scope.pending_dual_funding_context
24812482
}
24822483

2483-
#[inline]
2484-
fn unfunded_context(&self) -> &UnfundedChannelContext {
2485-
&self.refunding_scope.pending_unfunded_context
2484+
fn transaction_number(&self) -> u64 {
2485+
self.holder_commitment_point.transaction_number()
24862486
}
24872487

24882488
#[inline]
@@ -2509,7 +2509,7 @@ pub(super) trait FundingTxConstructorV2<SP: Deref>: ChannelContextProvider<SP> w
25092509
fn pending_funding_and_context_mut(&mut self) -> (&FundingScope, &mut ChannelContext<SP>);
25102510
fn dual_funding_context(&self) -> &DualFundingChannelContext;
25112511
fn dual_funding_context_mut(&mut self) -> &mut DualFundingChannelContext;
2512-
fn unfunded_context(&self) -> &UnfundedChannelContext;
2512+
fn transaction_number(&self) -> u64;
25132513
fn interactive_tx_constructor(&self) -> Option<&InteractiveTxConstructor>;
25142514
fn interactive_tx_constructor_mut(&mut self) -> &mut Option<InteractiveTxConstructor>;
25152515
fn interactive_tx_signing_session_mut(&mut self) -> &mut Option<InteractiveTxSigningSession>;
@@ -2694,8 +2694,7 @@ pub(super) trait FundingTxConstructorV2<SP: Deref>: ChannelContextProvider<SP> w
26942694
{
26952695
let our_funding_satoshis = self.dual_funding_context()
26962696
.our_funding_satoshis;
2697-
let transaction_number = self.unfunded_context()
2698-
.transaction_number();
2697+
let transaction_number = self.transaction_number();
26992698
let pending_funding = self.pending_funding();
27002699

27012700
let mut output_index = None;
@@ -2826,9 +2825,8 @@ impl<SP: Deref> FundingTxConstructorV2<SP> for PendingV2Channel<SP> where SP::Ta
28262825
&mut self.dual_funding_context
28272826
}
28282827

2829-
#[inline]
2830-
fn unfunded_context(&self) -> &UnfundedChannelContext {
2831-
&self.unfunded_context
2828+
fn transaction_number(&self) -> u64 {
2829+
self.unfunded_context.transaction_number()
28322830
}
28332831

28342832
#[inline]
@@ -2853,7 +2851,6 @@ impl<SP: Deref> FundingTxConstructorV2<SP> for PendingV2Channel<SP> where SP::Ta
28532851
struct RefundingScope {
28542852
// Fields belonging for [`PendingV2Channel`], except the context
28552853
pending_funding: FundingScope,
2856-
pending_unfunded_context: UnfundedChannelContext,
28572854
pending_dual_funding_context: DualFundingChannelContext,
28582855
/// The current interactive transaction construction session under negotiation.
28592856
pending_interactive_tx_constructor: Option<InteractiveTxConstructor>,
@@ -5422,6 +5419,7 @@ impl<SP: Deref> FundedChannel<SP> where
54225419
Ok(FundedChannelRefundingWrapper {
54235420
channel_context: &mut self.context,
54245421
refunding_scope,
5422+
holder_commitment_point: &self.holder_commitment_point,
54255423
})
54265424
} else {
54275425
Err("Channel is not refunding")
@@ -9128,14 +9126,9 @@ impl<SP: Deref> FundedChannel<SP> where
91289126
funding_feerate_sat_per_1000_weight: msg.funding_feerate_per_kw,
91299127
our_funding_inputs: Vec::new(),
91309128
};
9131-
let pending_unfunded_context = UnfundedChannelContext {
9132-
unfunded_channel_age_ticks: 0,
9133-
holder_commitment_point: HolderCommitmentPoint::new(&self.context.holder_signer, &self.context.secp_ctx),
9134-
};
91359129

91369130
let refunding_scope = Some(RefundingScope {
91379131
pending_funding,
9138-
pending_unfunded_context,
91399132
pending_dual_funding_context,
91409133
pending_interactive_tx_constructor: None,
91419134
pending_interactive_tx_signing_session: None,
@@ -9256,14 +9249,9 @@ impl<SP: Deref> FundedChannel<SP> where
92569249
if let Some(ref mut pending_splice_mut) = &mut self.pending_splice {
92579250
pending_dual_funding_context.our_funding_inputs = std::mem::take(&mut pending_splice_mut.our_funding_inputs);
92589251
};
9259-
let pending_unfunded_context = UnfundedChannelContext {
9260-
unfunded_channel_age_ticks: 0,
9261-
holder_commitment_point: HolderCommitmentPoint::new(&self.context.holder_signer, &self.context.secp_ctx),
9262-
};
92639252

92649253
let refunding_scope = RefundingScope {
92659254
pending_funding,
9266-
pending_unfunded_context,
92679255
pending_dual_funding_context,
92689256
pending_interactive_tx_constructor: None,
92699257
pending_interactive_tx_signing_session: None,

0 commit comments

Comments
 (0)