@@ -5954,17 +5954,19 @@ pub(super) struct FundingNegotiationContext {
5954
5954
/// The funding inputs we will be contributing to the channel.
5955
5955
#[allow(dead_code)] // TODO(dual_funding): Remove once contribution to V2 channels is enabled.
5956
5956
pub our_funding_inputs: Vec<(TxIn, TransactionU16LenLimited)>,
5957
+ /// The change output script. This will be used if needed or -- if not set -- generated using
5958
+ /// `SignerProvider::get_destination_script`.
5959
+ #[allow(dead_code)] // TODO(splicing): Remove once splicing is enabled.
5960
+ pub change_script: Option<ScriptBuf>,
5957
5961
}
5958
5962
5959
5963
impl FundingNegotiationContext {
5960
5964
/// Prepare and start interactive transaction negotiation.
5961
- /// `change_destination_opt` - Optional destination for optional change; if None,
5962
- /// default destination address is used.
5963
5965
/// If error occurs, it is caused by our side, not the counterparty.
5964
5966
#[cfg(splicing)]
5965
5967
fn into_interactive_tx_constructor<SP: Deref, ES: Deref>(
5966
5968
self, context: &ChannelContext<SP>, funding: &FundingScope, signer_provider: &SP,
5967
- entropy_source: &ES, holder_node_id: PublicKey, change_destination_opt: Option<ScriptBuf>,
5969
+ entropy_source: &ES, holder_node_id: PublicKey,
5968
5970
) -> Result<InteractiveTxConstructor, AbortReason>
5969
5971
where
5970
5972
SP::Target: SignerProvider,
@@ -6001,12 +6003,12 @@ impl FundingNegotiationContext {
6001
6003
context.holder_dust_limit_satoshis,
6002
6004
)?;
6003
6005
if let Some(change_value) = change_value_opt {
6004
- let change_script = if let Some(script) = change_destination_opt {
6006
+ let change_script = if let Some(script) = self.change_script {
6005
6007
script
6006
6008
} else {
6007
- signer_provider.get_destination_script(context.channel_keys_id).map_err(
6008
- |_err| AbortReason::InternalError("Error getting destination script"),
6009
- )?
6009
+ signer_provider
6010
+ .get_destination_script(context.channel_keys_id)
6011
+ .map_err(|_err| AbortReason::InternalError("Error getting change script") )?
6010
6012
};
6011
6013
let mut change_output =
6012
6014
TxOut { value: Amount::from_sat(change_value), script_pubkey: change_script };
@@ -10573,11 +10575,13 @@ where
10573
10575
/// Initiate splicing.
10574
10576
/// - `our_funding_inputs`: the inputs we contribute to the new funding transaction.
10575
10577
/// Includes the witness weight for this input (e.g. P2WPKH_WITNESS_WEIGHT=109 for typical P2WPKH inputs).
10578
+ /// - `change_script`: an option change output script. If `None` and needed, one will be
10579
+ /// generated by `SignerProvider::get_destination_script`.
10576
10580
#[cfg(splicing)]
10577
10581
pub fn splice_channel(
10578
10582
&mut self, our_funding_contribution_satoshis: i64,
10579
- our_funding_inputs: Vec<(TxIn, Transaction, Weight)>, funding_feerate_per_kw: u32 ,
10580
- locktime: u32,
10583
+ our_funding_inputs: Vec<(TxIn, Transaction, Weight)>, change_script: Option<ScriptBuf> ,
10584
+ funding_feerate_per_kw: u32, locktime: u32,
10581
10585
) -> Result<msgs::SpliceInit, APIError> {
10582
10586
// Check if a splice has been initiated already.
10583
10587
// Note: only a single outstanding splice is supported (per spec)
@@ -10648,6 +10652,7 @@ where
10648
10652
funding_feerate_sat_per_1000_weight: funding_feerate_per_kw,
10649
10653
shared_funding_input: Some(prev_funding_input),
10650
10654
our_funding_inputs: funding_inputs,
10655
+ change_script,
10651
10656
};
10652
10657
10653
10658
self.pending_splice = Some(PendingSplice {
@@ -10755,6 +10760,7 @@ where
10755
10760
funding_feerate_sat_per_1000_weight: msg.funding_feerate_per_kw,
10756
10761
shared_funding_input: Some(prev_funding_input),
10757
10762
our_funding_inputs: Vec::new(),
10763
+ change_script: None,
10758
10764
};
10759
10765
10760
10766
let mut interactive_tx_constructor = funding_negotiation_context
@@ -10764,7 +10770,6 @@ where
10764
10770
signer_provider,
10765
10771
entropy_source,
10766
10772
holder_node_id.clone(),
10767
- None,
10768
10773
)
10769
10774
.map_err(|err| {
10770
10775
ChannelError::Warn(format!(
@@ -10864,7 +10869,6 @@ where
10864
10869
signer_provider,
10865
10870
entropy_source,
10866
10871
holder_node_id.clone(),
10867
- None,
10868
10872
)
10869
10873
.map_err(|err| {
10870
10874
ChannelError::Warn(format!("V2 channel rejected due to sender error, {:?}", err))
@@ -12443,6 +12447,7 @@ where
12443
12447
funding_feerate_sat_per_1000_weight,
12444
12448
shared_funding_input: None,
12445
12449
our_funding_inputs: funding_inputs,
12450
+ change_script: None,
12446
12451
};
12447
12452
let chan = Self {
12448
12453
funding,
@@ -12598,6 +12603,7 @@ where
12598
12603
funding_feerate_sat_per_1000_weight: msg.funding_feerate_sat_per_1000_weight,
12599
12604
shared_funding_input: None,
12600
12605
our_funding_inputs: our_funding_inputs.clone(),
12606
+ change_script: None,
12601
12607
};
12602
12608
let shared_funding_output = TxOut {
12603
12609
value: Amount::from_sat(funding.get_value_satoshis()),
0 commit comments