mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-02-03 11:00:16 -05:00
Merge #351
351: Show the actual BTC amount and fee to be swapped r=da-kami a=da-kami We got user feedback, that it is confusing that the amount "found" in the wallet does not match the amount actually being swapped, thus with this PR we explicitly display the amount swapped and fees. Co-authored-by: Daniel Karzel <daniel@comit.network>
This commit is contained in:
commit
097197783c
@ -321,7 +321,7 @@ async fn determine_btc_to_swap(
|
||||
// TODO: Also wait for more funds if balance < dust
|
||||
let initial_balance = initial_balance.await?;
|
||||
|
||||
if initial_balance == Amount::ZERO {
|
||||
let balance = if initial_balance == Amount::ZERO {
|
||||
info!(
|
||||
"Please deposit the BTC you want to swap to {} (max {})",
|
||||
get_new_address.await?,
|
||||
@ -333,23 +333,23 @@ async fn determine_btc_to_swap(
|
||||
.context("Failed to wait for Bitcoin deposit")?;
|
||||
|
||||
info!("Received {}", new_balance);
|
||||
new_balance
|
||||
} else {
|
||||
info!("Found {} in wallet", initial_balance);
|
||||
}
|
||||
initial_balance
|
||||
};
|
||||
|
||||
let max_giveable = max_giveable
|
||||
.await
|
||||
.context("Failed to compute max 'giveable' Bitcoin amount")?;
|
||||
let fees = balance - max_giveable;
|
||||
|
||||
let max_accepted = bid_quote.max_quantity;
|
||||
|
||||
if max_giveable > max_accepted {
|
||||
info!(
|
||||
"Max giveable amount {} exceeds max accepted amount {}!",
|
||||
max_giveable, max_accepted
|
||||
);
|
||||
}
|
||||
let btc_swap_amount = min(max_giveable, max_accepted);
|
||||
info!("Swapping {} with {} fees", btc_swap_amount, fees);
|
||||
|
||||
Ok(min(max_giveable, max_accepted))
|
||||
Ok(btc_swap_amount)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user