@@ -5962,17 +5962,19 @@ pub(super) struct FundingNegotiationContext {
59625962 /// The funding inputs we will be contributing to the channel.
59635963 #[allow(dead_code)] // TODO(dual_funding): Remove once contribution to V2 channels is enabled.
59645964 pub our_funding_inputs: Vec<(TxIn, TransactionU16LenLimited)>,
5965+ /// The change output script. This will be used if needed or -- if not set -- generated using
5966+ /// `SignerProvider::get_destination_script`.
5967+ #[allow(dead_code)] // TODO(splicing): Remove once splicing is enabled.
5968+ pub change_script: Option<ScriptBuf>,
59655969}
59665970
59675971impl FundingNegotiationContext {
59685972 /// Prepare and start interactive transaction negotiation.
5969- /// `change_destination_opt` - Optional destination for optional change; if None,
5970- /// default destination address is used.
59715973 /// If error occurs, it is caused by our side, not the counterparty.
59725974 #[cfg(splicing)]
59735975 fn into_interactive_tx_constructor<SP: Deref, ES: Deref>(
59745976 self, context: &ChannelContext<SP>, funding: &FundingScope, signer_provider: &SP,
5975- entropy_source: &ES, holder_node_id: PublicKey, change_destination_opt: Option<ScriptBuf>,
5977+ entropy_source: &ES, holder_node_id: PublicKey,
59765978 ) -> Result<InteractiveTxConstructor, AbortReason>
59775979 where
59785980 SP::Target: SignerProvider,
@@ -6009,12 +6011,12 @@ impl FundingNegotiationContext {
60096011 context.holder_dust_limit_satoshis,
60106012 )?;
60116013 if let Some(change_value) = change_value_opt {
6012- let change_script = if let Some(script) = change_destination_opt {
6014+ let change_script = if let Some(script) = self.change_script {
60136015 script
60146016 } else {
6015- signer_provider.get_destination_script(context.channel_keys_id).map_err(
6016- |_err| AbortReason::InternalError("Error getting destination script"),
6017- )?
6017+ signer_provider
6018+ .get_destination_script(context.channel_keys_id)
6019+ .map_err(|_err| AbortReason::InternalError("Error getting change script") )?
60186020 };
60196021 let mut change_output =
60206022 TxOut { value: Amount::from_sat(change_value), script_pubkey: change_script };
@@ -10584,11 +10586,13 @@ where
1058410586 /// Initiate splicing.
1058510587 /// - `our_funding_inputs`: the inputs we contribute to the new funding transaction.
1058610588 /// Includes the witness weight for this input (e.g. P2WPKH_WITNESS_WEIGHT=109 for typical P2WPKH inputs).
10589+ /// - `change_script`: an option change output script. If `None` and needed, one will be
10590+ /// generated by `SignerProvider::get_destination_script`.
1058710591 #[cfg(splicing)]
1058810592 pub fn splice_channel(
1058910593 &mut self, our_funding_contribution_satoshis: i64,
10590- our_funding_inputs: Vec<(TxIn, Transaction, Weight)>, funding_feerate_per_kw: u32 ,
10591- locktime: u32,
10594+ our_funding_inputs: Vec<(TxIn, Transaction, Weight)>, change_script: Option<ScriptBuf> ,
10595+ funding_feerate_per_kw: u32, locktime: u32,
1059210596 ) -> Result<msgs::SpliceInit, APIError> {
1059310597 // Check if a splice has been initiated already.
1059410598 // Note: only a single outstanding splice is supported (per spec)
@@ -10659,6 +10663,7 @@ where
1065910663 funding_feerate_sat_per_1000_weight: funding_feerate_per_kw,
1066010664 shared_funding_input: Some(prev_funding_input),
1066110665 our_funding_inputs: funding_inputs,
10666+ change_script,
1066210667 };
1066310668
1066410669 self.pending_splice = Some(PendingSplice {
@@ -10766,6 +10771,7 @@ where
1076610771 funding_feerate_sat_per_1000_weight: msg.funding_feerate_per_kw,
1076710772 shared_funding_input: Some(prev_funding_input),
1076810773 our_funding_inputs: Vec::new(),
10774+ change_script: None,
1076910775 };
1077010776
1077110777 let mut interactive_tx_constructor = funding_negotiation_context
@@ -10775,7 +10781,6 @@ where
1077510781 signer_provider,
1077610782 entropy_source,
1077710783 holder_node_id.clone(),
10778- None,
1077910784 )
1078010785 .map_err(|err| {
1078110786 ChannelError::WarnAndDisconnect(format!(
@@ -10875,7 +10880,6 @@ where
1087510880 signer_provider,
1087610881 entropy_source,
1087710882 holder_node_id.clone(),
10878- None,
1087910883 )
1088010884 .map_err(|err| {
1088110885 ChannelError::WarnAndDisconnect(format!(
@@ -12459,6 +12463,7 @@ where
1245912463 funding_feerate_sat_per_1000_weight,
1246012464 shared_funding_input: None,
1246112465 our_funding_inputs: funding_inputs,
12466+ change_script: None,
1246212467 };
1246312468 let chan = Self {
1246412469 funding,
@@ -12614,6 +12619,7 @@ where
1261412619 funding_feerate_sat_per_1000_weight: msg.funding_feerate_sat_per_1000_weight,
1261512620 shared_funding_input: None,
1261612621 our_funding_inputs: our_funding_inputs.clone(),
12622+ change_script: None,
1261712623 };
1261812624 let shared_funding_output = TxOut {
1261912625 value: Amount::from_sat(funding.get_value_satoshis()),
0 commit comments