@@ -2258,6 +2258,27 @@ impl FundingScope {
22582258 short_channel_id: None,
22592259 })
22602260 }
2261+
2262+ /// Returns a `SharedOwnedInput` for using this `FundingScope` as the input to a new splice.
2263+ #[cfg(splicing)]
2264+ fn to_splice_funding_input(&self) -> SharedOwnedInput {
2265+ let funding_txo = self.get_funding_txo().expect("funding_txo should be set");
2266+ let input = TxIn {
2267+ previous_output: funding_txo.into_bitcoin_outpoint(),
2268+ script_sig: ScriptBuf::new(),
2269+ sequence: Sequence::ZERO,
2270+ witness: Witness::new(),
2271+ };
2272+
2273+ let prev_output = TxOut {
2274+ value: Amount::from_sat(self.get_value_satoshis()),
2275+ script_pubkey: self.get_funding_redeemscript().to_p2wsh(),
2276+ };
2277+
2278+ let local_owned = self.value_to_self_msat / 1000;
2279+
2280+ SharedOwnedInput::new(input, prev_output, local_owned)
2281+ }
22612282}
22622283
22632284/// Info about a pending splice
@@ -10542,6 +10563,8 @@ where
1054210563 false, // is_outbound
1054310564 )?;
1054410565
10566+ let prev_funding_input = self.funding.to_splice_funding_input();
10567+
1054510568 let funding_negotiation_context = FundingNegotiationContext {
1054610569 is_initiator: false,
1054710570 our_funding_satoshis,
@@ -10576,14 +10599,13 @@ where
1057610599 holder_commitment_transaction_number: self.holder_commitment_point.transaction_number(),
1057710600 };
1057810601
10579- // Start interactive funding negotiation. TODO(splicing): Add current funding as extra input, once shared inputs are supported, see #3842.
1058010602 let _msg = negotiating_view
1058110603 .begin_interactive_funding_tx_construction(
1058210604 signer_provider,
1058310605 entropy_source,
1058410606 holder_node_id.clone(),
1058510607 None,
10586- None ,
10608+ Some(prev_funding_input) ,
1058710609 )
1058810610 .map_err(|err| {
1058910611 ChannelError::Warn(format!(
@@ -10667,11 +10689,8 @@ where
1066710689 true, // is_outbound
1066810690 )?;
1066910691
10670- let pre_funding_transaction = &self.funding.funding_transaction;
10671- let pre_funding_txo = &self.funding.get_funding_txo();
10672- // We need the current funding tx as an extra input
10673- let prev_funding_input =
10674- Self::get_input_of_previous_funding(pre_funding_transaction, pre_funding_txo)?;
10692+ let prev_funding_input = self.funding.to_splice_funding_input();
10693+
1067510694 debug_assert!(pending_splice.funding.is_none());
1067610695 pending_splice.funding = Some(funding_scope);
1067710696 // update funding values
@@ -10709,34 +10728,6 @@ where
1070910728 Ok(tx_msg_opt)
1071010729 }
1071110730
10712- /// Get a transaction input that is the previous funding transaction
10713- #[cfg(splicing)]
10714- fn get_input_of_previous_funding(
10715- pre_funding_transaction: &Option<Transaction>, pre_funding_txo: &Option<OutPoint>,
10716- ) -> Result<(TxIn, TransactionU16LenLimited), ChannelError> {
10717- if let Some(pre_funding_transaction) = pre_funding_transaction {
10718- if let Some(pre_funding_txo) = pre_funding_txo {
10719- Ok((
10720- TxIn {
10721- previous_output: pre_funding_txo.into_bitcoin_outpoint(),
10722- script_sig: ScriptBuf::new(),
10723- sequence: Sequence::ZERO,
10724- witness: Witness::new(),
10725- },
10726- TransactionU16LenLimited::new(pre_funding_transaction.clone()).unwrap(), // TODO err?
10727- ))
10728- } else {
10729- Err(ChannelError::Warn(
10730- "Internal error: Missing previous funding transaction outpoint".to_string(),
10731- ))
10732- }
10733- } else {
10734- Err(ChannelError::Warn(
10735- "Internal error: Missing previous funding transaction".to_string(),
10736- ))
10737- }
10738- }
10739-
1074010731 #[cfg(splicing)]
1074110732 pub fn splice_locked<NS: Deref, L: Deref>(
1074210733 &mut self, msg: &msgs::SpliceLocked, node_signer: &NS, chain_hash: ChainHash,
0 commit comments