@@ -5962,17 +5962,19 @@ pub(super) struct FundingNegotiationContext {
5962
5962
/// The funding inputs we will be contributing to the channel.
5963
5963
#[allow(dead_code)] // TODO(dual_funding): Remove once contribution to V2 channels is enabled.
5964
5964
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>,
5965
5969
}
5966
5970
5967
5971
impl FundingNegotiationContext {
5968
5972
/// Prepare and start interactive transaction negotiation.
5969
- /// `change_destination_opt` - Optional destination for optional change; if None,
5970
- /// default destination address is used.
5971
5973
/// If error occurs, it is caused by our side, not the counterparty.
5972
5974
#[cfg(splicing)]
5973
5975
fn into_interactive_tx_constructor<SP: Deref, ES: Deref>(
5974
5976
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,
5976
5978
) -> Result<InteractiveTxConstructor, AbortReason>
5977
5979
where
5978
5980
SP::Target: SignerProvider,
@@ -6009,12 +6011,12 @@ impl FundingNegotiationContext {
6009
6011
context.holder_dust_limit_satoshis,
6010
6012
)?;
6011
6013
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 {
6013
6015
script
6014
6016
} 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") )?
6018
6020
};
6019
6021
let mut change_output =
6020
6022
TxOut { value: Amount::from_sat(change_value), script_pubkey: change_script };
@@ -10584,11 +10586,13 @@ where
10584
10586
/// Initiate splicing.
10585
10587
/// - `our_funding_inputs`: the inputs we contribute to the new funding transaction.
10586
10588
/// 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`.
10587
10591
#[cfg(splicing)]
10588
10592
pub fn splice_channel(
10589
10593
&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,
10592
10596
) -> Result<msgs::SpliceInit, APIError> {
10593
10597
// Check if a splice has been initiated already.
10594
10598
// Note: only a single outstanding splice is supported (per spec)
@@ -10659,6 +10663,7 @@ where
10659
10663
funding_feerate_sat_per_1000_weight: funding_feerate_per_kw,
10660
10664
shared_funding_input: Some(prev_funding_input),
10661
10665
our_funding_inputs: funding_inputs,
10666
+ change_script,
10662
10667
};
10663
10668
10664
10669
self.pending_splice = Some(PendingSplice {
@@ -10766,6 +10771,7 @@ where
10766
10771
funding_feerate_sat_per_1000_weight: msg.funding_feerate_per_kw,
10767
10772
shared_funding_input: Some(prev_funding_input),
10768
10773
our_funding_inputs: Vec::new(),
10774
+ change_script: None,
10769
10775
};
10770
10776
10771
10777
let mut interactive_tx_constructor = funding_negotiation_context
@@ -10775,7 +10781,6 @@ where
10775
10781
signer_provider,
10776
10782
entropy_source,
10777
10783
holder_node_id.clone(),
10778
- None,
10779
10784
)
10780
10785
.map_err(|err| {
10781
10786
ChannelError::WarnAndDisconnect(format!(
@@ -10875,7 +10880,6 @@ where
10875
10880
signer_provider,
10876
10881
entropy_source,
10877
10882
holder_node_id.clone(),
10878
- None,
10879
10883
)
10880
10884
.map_err(|err| {
10881
10885
ChannelError::WarnAndDisconnect(format!(
@@ -12459,6 +12463,7 @@ where
12459
12463
funding_feerate_sat_per_1000_weight,
12460
12464
shared_funding_input: None,
12461
12465
our_funding_inputs: funding_inputs,
12466
+ change_script: None,
12462
12467
};
12463
12468
let chan = Self {
12464
12469
funding,
@@ -12614,6 +12619,7 @@ where
12614
12619
funding_feerate_sat_per_1000_weight: msg.funding_feerate_sat_per_1000_weight,
12615
12620
shared_funding_input: None,
12616
12621
our_funding_inputs: our_funding_inputs.clone(),
12622
+ change_script: None,
12617
12623
};
12618
12624
let shared_funding_output = TxOut {
12619
12625
value: Amount::from_sat(funding.get_value_satoshis()),
0 commit comments