From e8d57feb8ab0eafd13485b310ba55338f31e6d9a Mon Sep 17 00:00:00 2001 From: optout <13562139+optout21@users.noreply.github.com> Date: Fri, 21 Feb 2025 22:57:46 +0100 Subject: [PATCH] minor Add optional change destination parameter --- lightning/src/ln/channel.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs index e594982914d..26f3b75d961 100644 --- a/lightning/src/ln/channel.rs +++ b/lightning/src/ln/channel.rs @@ -2129,9 +2129,12 @@ impl InitialRemoteCommitmentReceiver for FundedChannel where } impl PendingV2Channel where SP::Target: SignerProvider { + /// Prepare and start interactive transaction negotiation. + /// `change_destination_opt` - Optional destination for optional change; if None, default destination address is used. #[allow(dead_code)] // TODO(dual_funding): Remove once contribution to V2 channels is enabled fn begin_interactive_funding_tx_construction( &mut self, signer_provider: &SP, entropy_source: &ES, holder_node_id: PublicKey, + change_destination_opt: Option, ) -> Result, APIError> where ES::Target: EntropySource { @@ -2183,10 +2186,15 @@ impl PendingV2Channel where SP::Target: SignerProvider { ), })?; if let Some(change_value) = change_value_opt { - let change_script = signer_provider.get_destination_script(self.context.channel_keys_id).map_err( - |err| APIError::APIMisuseError { - err: format!("Failed to get change script as new destination script, {:?}", err), - })?; + let change_script = match change_destination_opt { + Some(script) => script, + None => { + signer_provider.get_destination_script(self.context.channel_keys_id).map_err( + |err| APIError::APIMisuseError { + err: format!("Failed to get change script as new destination script, {:?}", err), + })? + } + }; let mut change_output = TxOut { value: Amount::from_sat(change_value), script_pubkey: change_script,