mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-12-25 15:39:25 -05:00
Merge #246
246: Change anyhow! to bail! in error scenarios r=da-kami a=da-kami Unfortunately I handled the two failure scenarios in the ASB wrong - I thought that was fixed already, but that was different logic in a different PR. 😬😬😬 Co-authored-by: Daniel Karzel <daniel@comit.network>
This commit is contained in:
commit
108bc4c3ab
@ -16,7 +16,7 @@ use crate::{
|
|||||||
},
|
},
|
||||||
seed::Seed,
|
seed::Seed,
|
||||||
};
|
};
|
||||||
use anyhow::{anyhow, Context, Result};
|
use anyhow::{bail, Context, Result};
|
||||||
use futures::future::RemoteHandle;
|
use futures::future::RemoteHandle;
|
||||||
use libp2p::{
|
use libp2p::{
|
||||||
core::Multiaddr, futures::FutureExt, request_response::ResponseChannel, PeerId, Swarm,
|
core::Multiaddr, futures::FutureExt, request_response::ResponseChannel, PeerId, Swarm,
|
||||||
@ -221,19 +221,19 @@ where
|
|||||||
let xmr_amount = rate.sell_quote(btc_amount)?;
|
let xmr_amount = rate.sell_quote(btc_amount)?;
|
||||||
|
|
||||||
if xmr_amount > self.max_sell {
|
if xmr_amount > self.max_sell {
|
||||||
anyhow!(MaximumSellAmountExceeded {
|
bail!(MaximumSellAmountExceeded {
|
||||||
actual: xmr_amount,
|
actual: xmr_amount,
|
||||||
max_sell: self.max_sell
|
max_sell: self.max_sell
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
let xmr_balance = monero_wallet.get_balance().await?;
|
let xmr_balance = monero_wallet.get_balance().await?;
|
||||||
let xmr_lock_fees = monero_wallet.static_tx_fee_estimate();
|
let xmr_lock_fees = monero_wallet.static_tx_fee_estimate();
|
||||||
|
|
||||||
if xmr_balance < xmr_amount + xmr_lock_fees {
|
if xmr_balance < xmr_amount + xmr_lock_fees {
|
||||||
anyhow!(BalanceTooLow {
|
bail!(BalanceTooLow {
|
||||||
balance: xmr_balance
|
balance: xmr_balance
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
let quote_response = QuoteResponse { xmr_amount };
|
let quote_response = QuoteResponse { xmr_amount };
|
||||||
|
Loading…
Reference in New Issue
Block a user