gui: pass change_address param to createspend

This commit is contained in:
jp1ac4 2024-01-29 15:53:49 +00:00
parent a34070dce1
commit fae32df086
No known key found for this signature in database
GPG Key ID: A7ACD32423568D7B
4 changed files with 14 additions and 10 deletions

View File

@ -381,7 +381,7 @@ impl Step for DefineSpend {
return Command::perform(
async move {
daemon
.create_spend_tx(&inputs, &outputs, feerate_vb)
.create_spend_tx(&inputs, &outputs, feerate_vb, None)
.map_err(|e| e.into())
.and_then(|res| match res {
CreateSpendResult::Success { psbt, .. } => Ok(psbt),

View File

@ -86,15 +86,17 @@ impl<C: Client + Debug> Daemon for Lianad<C> {
coins_outpoints: &[OutPoint],
destinations: &HashMap<Address<address::NetworkUnchecked>, u64>,
feerate_vb: u64,
change_address: Option<Address<address::NetworkUnchecked>>,
) -> Result<CreateSpendResult, DaemonError> {
self.call(
"createspend",
Some(vec![
json!(destinations),
json!(coins_outpoints),
json!(feerate_vb),
]),
)
let mut input = vec![
json!(destinations),
json!(coins_outpoints),
json!(feerate_vb),
];
if let Some(change_address) = change_address {
input.push(json!(change_address));
}
self.call("createspend", Some(input))
}
fn rbf_psbt(

View File

@ -87,9 +87,10 @@ impl Daemon for EmbeddedDaemon {
coins_outpoints: &[OutPoint],
destinations: &HashMap<Address<address::NetworkUnchecked>, u64>,
feerate_vb: u64,
change_address: Option<Address<address::NetworkUnchecked>>,
) -> Result<CreateSpendResult, DaemonError> {
self.control()?
.create_spend(destinations, coins_outpoints, feerate_vb, None)
.create_spend(destinations, coins_outpoints, feerate_vb, change_address)
.map_err(|e| DaemonError::Unexpected(e.to_string()))
}

View File

@ -62,6 +62,7 @@ pub trait Daemon: Debug {
coins_outpoints: &[OutPoint],
destinations: &HashMap<Address<address::NetworkUnchecked>, u64>,
feerate_vb: u64,
change_address: Option<Address<address::NetworkUnchecked>>,
) -> Result<model::CreateSpendResult, DaemonError>;
fn rbf_psbt(
&self,