mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-08-08 22:42:35 -04:00
Inform user if cancel tx is has already been published
Alice and Bob can both submit cancel. A scenario exists where one of them may try and manually cancel but the other party has already published cancel. Log a message to notify the user this has happened. Add reusable function to check error for bitcoin rpc error code
This commit is contained in:
parent
f511ff093c
commit
110a5d2229
4 changed files with 80 additions and 19 deletions
|
@ -1,4 +1,4 @@
|
|||
use crate::bitcoin::{Txid, Wallet};
|
||||
use crate::bitcoin::{parse_rpc_error_code, RpcErrorCode, Txid, Wallet};
|
||||
use crate::database::{Database, Swap};
|
||||
use crate::protocol::bob::BobState;
|
||||
use anyhow::{bail, Result};
|
||||
|
@ -38,9 +38,11 @@ pub async fn cancel(
|
|||
let txid = match state6.submit_tx_cancel(bitcoin_wallet.as_ref()).await {
|
||||
Ok(txid) => txid,
|
||||
Err(err) => {
|
||||
if let Some(bdk::Error::TransactionConfirmed) = err.downcast_ref::<bdk::Error>() {
|
||||
tracing::info!("Cancel transaction has already been published and confirmed")
|
||||
};
|
||||
if let Ok(code) = parse_rpc_error_code(&err) {
|
||||
if code == i64::from(RpcErrorCode::RpcVerifyAlreadyInChain) {
|
||||
tracing::info!("Cancel transaction has already been confirmed on chain")
|
||||
}
|
||||
}
|
||||
bail!(err);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue