mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-10-01 01:45:40 -04:00
Have --force
flag only override the timelock check
It might very well be that the cancel transaction is already published. If that is the case, there is no point in failing the command. We simply transition to cancel and exit normally. The reason this comes up now is because Alice now properly waits for the cancel timelock as well and publishes the cancel transaction first. Ultimately, she should not do that because there is no benefit to her unless she can also publish the punish transaction.
This commit is contained in:
parent
24f444b9f7
commit
1b2f476cae
@ -239,9 +239,6 @@ async fn main() -> Result<()> {
|
||||
"The Cancel Transaction cannot be published yet, \
|
||||
because the timelock has not expired. Please try again later."
|
||||
),
|
||||
Err(bob::cancel::Error::CancelTxAlreadyPublished) => {
|
||||
warn!("The Cancel Transaction has already been published.")
|
||||
}
|
||||
}
|
||||
}
|
||||
Command::Refund {
|
||||
|
@ -9,8 +9,6 @@ use uuid::Uuid;
|
||||
pub enum Error {
|
||||
#[error("The cancel timelock has not expired yet.")]
|
||||
CancelTimelockNotExpiredYet,
|
||||
#[error("The cancel transaction has already been published.")]
|
||||
CancelTxAlreadyPublished,
|
||||
}
|
||||
|
||||
pub async fn cancel(
|
||||
@ -48,23 +46,15 @@ pub async fn cancel(
|
||||
if let ExpiredTimelocks::None = state6.expired_timelock(bitcoin_wallet.as_ref()).await? {
|
||||
return Ok(Err(Error::CancelTimelockNotExpiredYet));
|
||||
}
|
||||
}
|
||||
|
||||
if state6
|
||||
.check_for_tx_cancel(bitcoin_wallet.as_ref())
|
||||
.await
|
||||
.is_ok()
|
||||
{
|
||||
let txid = if let Ok(tx) = state6.check_for_tx_cancel(bitcoin_wallet.as_ref()).await {
|
||||
tracing::debug!(%swap_id, "Cancel transaction has already been published");
|
||||
|
||||
let state = BobState::BtcCancelled(state6);
|
||||
let db_state = state.into();
|
||||
db.insert_latest_state(swap_id, Swap::Bob(db_state)).await?;
|
||||
|
||||
return Ok(Err(Error::CancelTxAlreadyPublished));
|
||||
}
|
||||
}
|
||||
|
||||
let txid = state6.submit_tx_cancel(bitcoin_wallet.as_ref()).await?;
|
||||
tx.txid()
|
||||
} else {
|
||||
state6.submit_tx_cancel(bitcoin_wallet.as_ref()).await?
|
||||
};
|
||||
|
||||
let state = BobState::BtcCancelled(state6);
|
||||
let db_state = state.clone().into();
|
||||
|
Loading…
Reference in New Issue
Block a user