Skip to content

Commit e8d57fe

Browse files
committed
minor Add optional change destination parameter
1 parent 22c866a commit e8d57fe

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

lightning/src/ln/channel.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2129,9 +2129,12 @@ impl<SP: Deref> InitialRemoteCommitmentReceiver<SP> for FundedChannel<SP> where
21292129
}
21302130

21312131
impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
2132+
/// Prepare and start interactive transaction negotiation.
2133+
/// `change_destination_opt` - Optional destination for optional change; if None, default destination address is used.
21322134
#[allow(dead_code)] // TODO(dual_funding): Remove once contribution to V2 channels is enabled
21332135
fn begin_interactive_funding_tx_construction<ES: Deref>(
21342136
&mut self, signer_provider: &SP, entropy_source: &ES, holder_node_id: PublicKey,
2137+
change_destination_opt: Option<ScriptBuf>,
21352138
) -> Result<Option<InteractiveTxMessageSend>, APIError>
21362139
where ES::Target: EntropySource
21372140
{
@@ -2183,10 +2186,15 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
21832186
),
21842187
})?;
21852188
if let Some(change_value) = change_value_opt {
2186-
let change_script = signer_provider.get_destination_script(self.context.channel_keys_id).map_err(
2187-
|err| APIError::APIMisuseError {
2188-
err: format!("Failed to get change script as new destination script, {:?}", err),
2189-
})?;
2189+
let change_script = match change_destination_opt {
2190+
Some(script) => script,
2191+
None => {
2192+
signer_provider.get_destination_script(self.context.channel_keys_id).map_err(
2193+
|err| APIError::APIMisuseError {
2194+
err: format!("Failed to get change script as new destination script, {:?}", err),
2195+
})?
2196+
}
2197+
};
21902198
let mut change_output = TxOut {
21912199
value: Amount::from_sat(change_value),
21922200
script_pubkey: change_script,

0 commit comments

Comments
 (0)