Skip to content

Commit 37c7f43

Browse files
committed
fix Move get_input_of_previous_funding to FundedChannel
1 parent 866368d commit 37c7f43

File tree

1 file changed

+24
-26
lines changed

1 file changed

+24
-26
lines changed

lightning/src/ln/channel.rs

+24-26
Original file line numberDiff line numberDiff line change
@@ -2860,31 +2860,6 @@ struct RefundingScope {
28602860
pending_interactive_tx_signing_session: Option<InteractiveTxSigningSession>,
28612861
}
28622862

2863-
#[cfg(splicing)]
2864-
impl RefundingScope {
2865-
/// Get a transaction input that is the previous funding transaction
2866-
fn get_input_of_previous_funding(pre_funding_transaction: &Option<Transaction>, pre_funding_txo: &Option<OutPoint>)
2867-
-> Result<(TxIn, TransactionU16LenLimited), ChannelError> {
2868-
if let Some(pre_funding_transaction) = pre_funding_transaction {
2869-
if let Some(pre_funding_txo) = pre_funding_txo {
2870-
Ok((
2871-
TxIn {
2872-
previous_output: pre_funding_txo.into_bitcoin_outpoint(),
2873-
script_sig: ScriptBuf::new(),
2874-
sequence: Sequence::ZERO,
2875-
witness: Witness::new(),
2876-
},
2877-
TransactionU16LenLimited::new(pre_funding_transaction.clone()).unwrap(), // TODO err?
2878-
))
2879-
} else {
2880-
Err(ChannelError::Warn("Internal error: Missing previous funding transaction outpoint".to_string()))
2881-
}
2882-
} else {
2883-
Err(ChannelError::Warn("Internal error: Missing previous funding transaction".to_string()))
2884-
}
2885-
}
2886-
}
2887-
28882863
impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
28892864
fn new_for_inbound_channel<'a, ES: Deref, F: Deref, L: Deref>(
28902865
fee_estimator: &'a LowerBoundedFeeEstimator<F>,
@@ -9266,7 +9241,7 @@ impl<SP: Deref> FundedChannel<SP> where
92669241
let pre_funding_transaction = &self.funding.funding_transaction;
92679242
let pre_funding_txo = &self.funding.get_funding_txo();
92689243
// We need the current funding tx as an extra input
9269-
let prev_funding_input = RefundingScope::get_input_of_previous_funding(pre_funding_transaction, pre_funding_txo)?;
9244+
let prev_funding_input = Self::get_input_of_previous_funding(pre_funding_transaction, pre_funding_txo)?;
92709245
if let Some(ref mut pending_splice) = &mut self.pending_splice {
92719246
pending_splice.refunding_scope = Some(refunding_scope);
92729247
debug_assert!(pending_splice.awaiting_splice_ack);
@@ -9294,6 +9269,29 @@ impl<SP: Deref> FundedChannel<SP> where
92949269
Ok(tx_msg_opt)
92959270
}
92969271

9272+
/// Get a transaction input that is the previous funding transaction
9273+
#[cfg(splicing)]
9274+
fn get_input_of_previous_funding(pre_funding_transaction: &Option<Transaction>, pre_funding_txo: &Option<OutPoint>)
9275+
-> Result<(TxIn, TransactionU16LenLimited), ChannelError> {
9276+
if let Some(pre_funding_transaction) = pre_funding_transaction {
9277+
if let Some(pre_funding_txo) = pre_funding_txo {
9278+
Ok((
9279+
TxIn {
9280+
previous_output: pre_funding_txo.into_bitcoin_outpoint(),
9281+
script_sig: ScriptBuf::new(),
9282+
sequence: Sequence::ZERO,
9283+
witness: Witness::new(),
9284+
},
9285+
TransactionU16LenLimited::new(pre_funding_transaction.clone()).unwrap(), // TODO err?
9286+
))
9287+
} else {
9288+
Err(ChannelError::Warn("Internal error: Missing previous funding transaction outpoint".to_string()))
9289+
}
9290+
} else {
9291+
Err(ChannelError::Warn("Internal error: Missing previous funding transaction".to_string()))
9292+
}
9293+
}
9294+
92979295
/// Splice process starting; update state, log, etc.
92989296
#[cfg(splicing)]
92999297
pub(crate) fn splice_start<L: Deref>(&mut self, is_outgoing: bool, logger: &L) where L::Target: Logger {

0 commit comments

Comments
 (0)