feat(gui, swap): allow change-address to be omitted and default to internal wallet (#68)

This PR:
- allows --change-address to be omitted and default to internal wallet address (https://github.com/comit-network/xmr-btc-swap/pull/1709). This is a change that is merged from upstream into our fork
- adds the necessary components for the tauri integration and the ui components to allow toggling between internal vs external refund address

Co-authored-by: binarybaron <86064887+binarybaron@users.noreply.github.com>
Co-authored-by: Einliterflasche <81313171+Einliterflasche@users.noreply.github.com>
Co-authored-by: Byron Hambly <byron@hambly.dev>
This commit is contained in:
binarybaron 2024-09-09 19:47:15 +02:00 committed by GitHub
parent 91482f1e16
commit 063f9dbf9b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 118 additions and 50 deletions

View file

@ -44,8 +44,8 @@ pub trait Request {
pub struct BuyXmrArgs {
#[typeshare(serialized_as = "string")]
pub seller: Multiaddr,
#[typeshare(serialized_as = "string")]
pub bitcoin_change_address: bitcoin::Address,
#[typeshare(serialized_as = "Option<string>")]
pub bitcoin_change_address: Option<bitcoin::Address>,
#[typeshare(serialized_as = "string")]
pub monero_receive_address: monero::Address,
}
@ -545,6 +545,21 @@ pub async fn buy_xmr(
.as_ref()
.expect("Could not find Bitcoin wallet"),
);
let bitcoin_change_address = match bitcoin_change_address {
Some(addr) => addr,
None => {
let internal_wallet_address = bitcoin_wallet.new_address().await?;
tracing::info!(
internal_wallet_address=%internal_wallet_address,
"No --change-address supplied. Any change will be received to the internal wallet."
);
internal_wallet_address
}
};
let monero_wallet = Arc::clone(
context
.monero_wallet