mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-04-20 16:06:00 -04:00
Return original error in case downcasting to JsonRpcError fails
This commit is contained in:
parent
298fbbe6cb
commit
cedc56a160
@ -18,7 +18,7 @@ use crate::{
|
||||
storage::Database,
|
||||
SwapAmounts, TRANSACTION_ALREADY_IN_BLOCKCHAIN_ERROR_CODE,
|
||||
};
|
||||
use anyhow::{anyhow, bail, Result};
|
||||
use anyhow::{bail, Result};
|
||||
use async_recursion::async_recursion;
|
||||
use bitcoin_harness::bitcoind_rpc::jsonrpc_client::JsonRpcError;
|
||||
use futures::{
|
||||
@ -475,11 +475,12 @@ pub async fn run_until(
|
||||
}
|
||||
AliceState::T1Expired { state3 } => {
|
||||
if let Err(error) = state3.submit_tx_cancel(bitcoin_wallet.as_ref()).await {
|
||||
let json_rpc_err = error
|
||||
.downcast_ref::<JsonRpcError>()
|
||||
.ok_or_else(|| anyhow!("Failed to downcast JsonRpcError"))?;
|
||||
if json_rpc_err.code == TRANSACTION_ALREADY_IN_BLOCKCHAIN_ERROR_CODE {
|
||||
info!("Failed to send cancel transaction, assuming that is was already published by the other party...");
|
||||
if let Some(json_rpc_err) = error.downcast_ref::<JsonRpcError>() {
|
||||
if json_rpc_err.code == TRANSACTION_ALREADY_IN_BLOCKCHAIN_ERROR_CODE {
|
||||
info!("Failed to send cancel transaction, assuming that is was already included by the other party...");
|
||||
} else {
|
||||
return Err(error);
|
||||
}
|
||||
} else {
|
||||
return Err(error);
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ use crate::{
|
||||
storage::Database,
|
||||
SwapAmounts, TRANSACTION_ALREADY_IN_BLOCKCHAIN_ERROR_CODE,
|
||||
};
|
||||
use anyhow::{anyhow, bail, Result};
|
||||
use anyhow::{bail, Result};
|
||||
use async_recursion::async_recursion;
|
||||
use bitcoin_harness::bitcoind_rpc::jsonrpc_client::JsonRpcError;
|
||||
use libp2p::{core::Multiaddr, PeerId};
|
||||
@ -347,11 +347,12 @@ where
|
||||
BobState::T1Expired(state4) => {
|
||||
let result = state4.submit_tx_cancel(bitcoin_wallet.as_ref()).await;
|
||||
if let Err(error) = result {
|
||||
let json_rpc_err = error
|
||||
.downcast_ref::<JsonRpcError>()
|
||||
.ok_or_else(|| anyhow!("Failed to downcast JsonRpcError"))?;
|
||||
if json_rpc_err.code == TRANSACTION_ALREADY_IN_BLOCKCHAIN_ERROR_CODE {
|
||||
info!("Failed to send cancel transaction, assuming that is was already included by the other party...");
|
||||
if let Some(json_rpc_err) = error.downcast_ref::<JsonRpcError>() {
|
||||
if json_rpc_err.code == TRANSACTION_ALREADY_IN_BLOCKCHAIN_ERROR_CODE {
|
||||
info!("Failed to send cancel transaction, assuming that is was already included by the other party...");
|
||||
} else {
|
||||
return Err(error);
|
||||
}
|
||||
} else {
|
||||
return Err(error);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user