mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-11-29 12:06:35 -05:00
Revert "introduce better approach for checking for error"
This reverts commit 7844ad1483.
This commit is contained in:
parent
ca8a9cbc0b
commit
4421db7aad
1 changed files with 9 additions and 11 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::bitcoin::{parse_rpc_error_code, RpcErrorCode, Wallet};
|
use crate::bitcoin::{parse_rpc_error_code, ExpiredTimelocks, RpcErrorCode, Wallet};
|
||||||
use crate::protocol::bob::BobState;
|
use crate::protocol::bob::BobState;
|
||||||
use crate::protocol::Database;
|
use crate::protocol::Database;
|
||||||
use anyhow::{bail, Result};
|
use anyhow::{bail, Result};
|
||||||
|
|
@ -16,12 +16,11 @@ pub async fn cancel_and_refund(
|
||||||
};
|
};
|
||||||
|
|
||||||
let state = match refund(swap_id, bitcoin_wallet, db).await {
|
let state = match refund(swap_id, bitcoin_wallet, db).await {
|
||||||
Ok(s) => {
|
Ok(s) => s,
|
||||||
tracing::info!("Refund transaction submitted");
|
|
||||||
s
|
|
||||||
}
|
|
||||||
Err(e) => bail!(e),
|
Err(e) => bail!(e),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
tracing::info!("Refund transaction submitted");
|
||||||
Ok(state)
|
Ok(state)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -65,10 +64,12 @@ pub async fn cancel(
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
if let Ok(error_code) = parse_rpc_error_code(&err) {
|
if let Ok(error_code) = parse_rpc_error_code(&err) {
|
||||||
if error_code == i64::from(RpcErrorCode::RpcVerifyError) {
|
if error_code == i64::from(RpcErrorCode::RpcVerifyError) {
|
||||||
if err
|
if let ExpiredTimelocks::None { .. } =
|
||||||
.to_string()
|
state6.expired_timelock(bitcoin_wallet.as_ref()).await?
|
||||||
.contains("Failed to broadcast Bitcoin refund transaction")
|
|
||||||
{
|
{
|
||||||
|
tracing::debug!(%error_code, "parse rpc error");
|
||||||
|
tracing::info!("General error trying to submit cancel transaction");
|
||||||
|
} else {
|
||||||
let txid = state6
|
let txid = state6
|
||||||
.construct_tx_cancel()
|
.construct_tx_cancel()
|
||||||
.expect("Error when constructing tx_cancel")
|
.expect("Error when constructing tx_cancel")
|
||||||
|
|
@ -78,9 +79,6 @@ pub async fn cancel(
|
||||||
.await?;
|
.await?;
|
||||||
tracing::info!("Cancel transaction has already been confirmed on chain. The swap has therefore already been cancelled by Alice.");
|
tracing::info!("Cancel transaction has already been confirmed on chain. The swap has therefore already been cancelled by Alice.");
|
||||||
return Ok((txid, state));
|
return Ok((txid, state));
|
||||||
} else {
|
|
||||||
tracing::debug!(%error_code, "parse rpc error");
|
|
||||||
tracing::info!("General error trying to submit cancel transaction");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue