mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-11-28 03:30:33 -05:00
fix(cli): allow bitcoin-change-address to be omitted when making request to rpc server (#1728)
This commit is contained in:
parent
c80bdb2d8c
commit
75cfc6b0d4
4 changed files with 43 additions and 33 deletions
|
|
@ -31,7 +31,7 @@ pub struct Request {
|
|||
pub enum Method {
|
||||
BuyXmr {
|
||||
seller: Multiaddr,
|
||||
bitcoin_change_address: bitcoin::Address,
|
||||
bitcoin_change_address: Option<bitcoin::Address>,
|
||||
monero_receive_address: monero::Address,
|
||||
swap_id: Uuid,
|
||||
},
|
||||
|
|
@ -335,6 +335,25 @@ impl Request {
|
|||
let env_config = context.config.env_config;
|
||||
let seed = context.config.seed.clone().context("Could not get seed")?;
|
||||
|
||||
// When no change address was provided we default to the internal wallet
|
||||
let bitcoin_change_address = match bitcoin_change_address {
|
||||
Some(addr) => addr,
|
||||
None => {
|
||||
let internal_wallet_address = context
|
||||
.bitcoin_wallet()
|
||||
.expect("bitcoin wallet should exist")
|
||||
.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 seller_peer_id = seller
|
||||
.extract_peer_id()
|
||||
.context("Seller address must contain peer ID")?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue