diff --git a/swap/src/asb/recovery/cancel.rs b/swap/src/asb/recovery/cancel.rs index c3168026..0bff4214 100644 --- a/swap/src/asb/recovery/cancel.rs +++ b/swap/src/asb/recovery/cancel.rs @@ -15,7 +15,7 @@ pub async fn cancel( swap_id: Uuid, bitcoin_wallet: Arc, db: Arc, - force: bool, + graceful: bool, ) -> Result> { let state = db.get_state(swap_id)?.try_into_alice()?.into(); @@ -52,7 +52,7 @@ pub async fn cancel( tracing::info!(%swap_id, "Trying to manually cancel swap"); - if !force { + if graceful { tracing::debug!(%swap_id, "Checking if cancel timelock is expired"); if let ExpiredTimelocks::None = state3.expired_timelocks(bitcoin_wallet.as_ref()).await? { diff --git a/swap/src/bin/swap.rs b/swap/src/bin/swap.rs index b3f6fb05..23fa458e 100644 --- a/swap/src/bin/swap.rs +++ b/swap/src/bin/swap.rs @@ -273,7 +273,7 @@ async fn main() -> Result<()> { } Command::Cancel { swap_id, - force, + graceful, bitcoin_electrum_rpc_url, bitcoin_target_block, } => { @@ -292,7 +292,7 @@ async fn main() -> Result<()> { ) .await?; - let cancel = cli::cancel(swap_id, Arc::new(bitcoin_wallet), db, force).await?; + let cancel = cli::cancel(swap_id, Arc::new(bitcoin_wallet), db, graceful).await?; match cancel { Ok((txid, _)) => { @@ -305,7 +305,7 @@ async fn main() -> Result<()> { } Command::Refund { swap_id, - force, + graceful: force, bitcoin_electrum_rpc_url, bitcoin_target_block, } => { diff --git a/swap/src/cli/command.rs b/swap/src/cli/command.rs index 0f0dc18b..b6d58154 100644 --- a/swap/src/cli/command.rs +++ b/swap/src/cli/command.rs @@ -171,7 +171,7 @@ where } RawCommand::Cancel { swap_id: SwapId { swap_id }, - force, + graceful: force, bitcoin, } => { let (bitcoin_electrum_rpc_url, bitcoin_target_block) = @@ -184,7 +184,7 @@ where data_dir: data::data_dir_from(data, is_testnet)?, cmd: Command::Cancel { swap_id, - force, + graceful: force, bitcoin_electrum_rpc_url, bitcoin_target_block, }, @@ -192,7 +192,7 @@ where } RawCommand::Refund { swap_id: SwapId { swap_id }, - force, + graceful: force, bitcoin, } => { let (bitcoin_electrum_rpc_url, bitcoin_target_block) = @@ -205,7 +205,7 @@ where data_dir: data::data_dir_from(data, is_testnet)?, cmd: Command::Refund { swap_id, - force, + graceful: force, bitcoin_electrum_rpc_url, bitcoin_target_block, }, @@ -261,13 +261,13 @@ pub enum Command { }, Cancel { swap_id: Uuid, - force: bool, + graceful: bool, bitcoin_electrum_rpc_url: Url, bitcoin_target_block: usize, }, Refund { swap_id: Uuid, - force: bool, + graceful: bool, bitcoin_electrum_rpc_url: Url, bitcoin_target_block: usize, }, @@ -376,24 +376,24 @@ enum RawCommand { #[structopt(flatten)] tor: Tor, }, - /// Try to cancel an ongoing swap (expert users only) + /// Force submission of the cancel transaction overriding the protocol state machine and blockheight checks (expert users only) Cancel { #[structopt(flatten)] swap_id: SwapId, - #[structopt(short, long)] - force: bool, + #[structopt(short, long, help = "Performs checks to see whether it is appropriate to refund before submitting the cancel transaction")] + graceful: bool, #[structopt(flatten)] bitcoin: Bitcoin, }, - /// Try to cancel a swap and refund the BTC (expert users only) + /// Force submission of the cancel transaction overriding the protocol state machine and blockheight checks (expert users only) Refund { #[structopt(flatten)] swap_id: SwapId, - #[structopt(short, long)] - force: bool, + #[structopt(short, long, help = "Performs checks to see whether it is appropriate to refund before submitting the refund transaction")] + graceful: bool, #[structopt(flatten)] bitcoin: Bitcoin, @@ -1173,7 +1173,7 @@ mod tests { data_dir: data_dir_path_cli().join(TESTNET), cmd: Command::Cancel { swap_id: Uuid::from_str(SWAP_ID).unwrap(), - force: false, + graceful: false, bitcoin_electrum_rpc_url: Url::from_str(DEFAULT_ELECTRUM_RPC_URL_TESTNET) .unwrap(), bitcoin_target_block: DEFAULT_BITCOIN_CONFIRMATION_TARGET_TESTNET, @@ -1189,7 +1189,7 @@ mod tests { data_dir: data_dir_path_cli().join(MAINNET), cmd: Command::Cancel { swap_id: Uuid::from_str(SWAP_ID).unwrap(), - force: false, + graceful: false, bitcoin_electrum_rpc_url: Url::from_str(DEFAULT_ELECTRUM_RPC_URL).unwrap(), bitcoin_target_block: DEFAULT_BITCOIN_CONFIRMATION_TARGET, }, @@ -1204,7 +1204,7 @@ mod tests { data_dir: data_dir_path_cli().join(TESTNET), cmd: Command::Refund { swap_id: Uuid::from_str(SWAP_ID).unwrap(), - force: false, + graceful: false, bitcoin_electrum_rpc_url: Url::from_str(DEFAULT_ELECTRUM_RPC_URL_TESTNET) .unwrap(), bitcoin_target_block: DEFAULT_BITCOIN_CONFIRMATION_TARGET_TESTNET, @@ -1220,7 +1220,7 @@ mod tests { data_dir: data_dir_path_cli().join(MAINNET), cmd: Command::Refund { swap_id: Uuid::from_str(SWAP_ID).unwrap(), - force: false, + graceful: false, bitcoin_electrum_rpc_url: Url::from_str(DEFAULT_ELECTRUM_RPC_URL).unwrap(), bitcoin_target_block: DEFAULT_BITCOIN_CONFIRMATION_TARGET, }, diff --git a/swap/src/cli/refund.rs b/swap/src/cli/refund.rs index a769eda9..7d027287 100644 --- a/swap/src/cli/refund.rs +++ b/swap/src/cli/refund.rs @@ -13,11 +13,11 @@ pub async fn refund( swap_id: Uuid, bitcoin_wallet: Arc, db: Database, - force: bool, + graceful: bool, ) -> Result> { let state = db.get_state(swap_id)?.try_into_bob()?.into(); - let state6 = if force { + let state6 = if !graceful { match state { BobState::BtcLocked(state3) => state3.cancel(), BobState::XmrLockProofReceived { state, .. } => state.cancel(),