Skip to content

Commit

Permalink
minor Add optional change destination parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
optout21 committed Feb 21, 2025
1 parent 22c866a commit e8d57fe
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lightning/src/ln/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2129,9 +2129,12 @@ impl<SP: Deref> InitialRemoteCommitmentReceiver<SP> for FundedChannel<SP> where
}

impl<SP: Deref> PendingV2Channel<SP> 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<ES: Deref>(
&mut self, signer_provider: &SP, entropy_source: &ES, holder_node_id: PublicKey,
change_destination_opt: Option<ScriptBuf>,
) -> Result<Option<InteractiveTxMessageSend>, APIError>
where ES::Target: EntropySource
{
Expand Down Expand Up @@ -2183,10 +2186,15 @@ impl<SP: Deref> PendingV2Channel<SP> 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,
Expand Down

0 comments on commit e8d57fe

Please sign in to comment.