You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
xmr-btc-swap/swap/src/asb/command.rs

789 lines
25 KiB
Rust

use crate::asb::config::GetDefaults;
use crate::bitcoin::Amount;
use crate::env;
use crate::env::GetConfig;
use anyhow::{bail, Result};
use bitcoin::Address;
use serde::Serialize;
use std::ffi::OsString;
use std::path::PathBuf;
use structopt::StructOpt;
use uuid::Uuid;
pub fn parse_args<I, T>(raw_args: I) -> Result<Arguments>
where
I: IntoIterator<Item = T>,
T: Into<OsString> + Clone,
{
let matches = RawArguments::clap().get_matches_from_safe(raw_args)?;
let args = RawArguments::from_clap(&matches);
let json = args.json;
let disable_timestamp = args.disable_timestamp;
let testnet = args.testnet;
let config = args.config;
let command: RawCommand = args.cmd;
let arguments = match command {
RawCommand::Start { resume_only } => Arguments {
testnet,
json,
disable_timestamp,
config_path: config_path(config, testnet)?,
env_config: env_config(testnet),
cmd: Command::Start { resume_only },
},
RawCommand::History => Arguments {
testnet,
json,
disable_timestamp,
config_path: config_path(config, testnet)?,
env_config: env_config(testnet),
cmd: Command::History,
},
RawCommand::WithdrawBtc { amount, address } => Arguments {
testnet,
json,
disable_timestamp,
config_path: config_path(config, testnet)?,
env_config: env_config(testnet),
cmd: Command::WithdrawBtc {
amount,
address: bitcoin_address(address, testnet)?,
},
},
RawCommand::Balance => Arguments {
testnet,
json,
disable_timestamp,
config_path: config_path(config, testnet)?,
env_config: env_config(testnet),
cmd: Command::Balance,
},
RawCommand::Config => Arguments {
testnet,
json,
disable_timestamp,
config_path: config_path(config, testnet)?,
env_config: env_config(testnet),
cmd: Command::Config,
},
RawCommand::ExportBitcoinWallet => Arguments {
testnet,
json,
disable_timestamp,
config_path: config_path(config, testnet)?,
env_config: env_config(testnet),
cmd: Command::ExportBitcoinWallet,
},
RawCommand::ManualRecovery(ManualRecovery::Redeem {
redeem_params: RecoverCommandParams { swap_id },
do_not_await_finality,
}) => Arguments {
testnet,
json,
disable_timestamp,
config_path: config_path(config, testnet)?,
env_config: env_config(testnet),
cmd: Command::Redeem {
swap_id,
do_not_await_finality,
},
},
RawCommand::ManualRecovery(ManualRecovery::Cancel {
cancel_params: RecoverCommandParams { swap_id },
}) => Arguments {
testnet,
json,
disable_timestamp,
config_path: config_path(config, testnet)?,
env_config: env_config(testnet),
cmd: Command::Cancel { swap_id },
},
RawCommand::ManualRecovery(ManualRecovery::Refund {
refund_params: RecoverCommandParams { swap_id },
}) => Arguments {
testnet,
json,
disable_timestamp,
config_path: config_path(config, testnet)?,
env_config: env_config(testnet),
cmd: Command::Refund { swap_id },
},
RawCommand::ManualRecovery(ManualRecovery::Punish {
punish_params: RecoverCommandParams { swap_id },
}) => Arguments {
testnet,
json,
disable_timestamp,
config_path: config_path(config, testnet)?,
env_config: env_config(testnet),
cmd: Command::Punish { swap_id },
},
RawCommand::ManualRecovery(ManualRecovery::SafelyAbort { swap_id }) => Arguments {
testnet,
json,
disable_timestamp,
config_path: config_path(config, testnet)?,
env_config: env_config(testnet),
cmd: Command::SafelyAbort { swap_id },
},
};
Ok(arguments)
}
fn bitcoin_address(address: Address, is_testnet: bool) -> Result<Address> {
let network = if is_testnet {
bitcoin::Network::Testnet
} else {
bitcoin::Network::Bitcoin
};
if address.network != network {
bail!(BitcoinAddressNetworkMismatch {
expected: network,
actual: address.network
});
}
Ok(address)
}
fn config_path(config: Option<PathBuf>, is_testnet: bool) -> Result<PathBuf> {
let config_path = if let Some(config_path) = config {
config_path
} else if is_testnet {
env::Testnet::getConfigFileDefaults()?.config_path
} else {
env::Mainnet::getConfigFileDefaults()?.config_path
};
Ok(config_path)
}
fn env_config(is_testnet: bool) -> env::Config {
if is_testnet {
env::Testnet::get_config()
} else {
env::Mainnet::get_config()
}
}
#[derive(thiserror::Error, Debug, Clone, Copy, PartialEq, Serialize)]
#[error("Invalid Bitcoin address provided, expected address on network {expected:?} but address provided is on {actual:?}")]
pub struct BitcoinAddressNetworkMismatch {
#[serde(with = "crate::bitcoin::network")]
expected: bitcoin::Network,
#[serde(with = "crate::bitcoin::network")]
actual: bitcoin::Network,
}
#[derive(Debug, PartialEq)]
pub struct Arguments {
pub testnet: bool,
pub json: bool,
pub disable_timestamp: bool,
pub config_path: PathBuf,
pub env_config: env::Config,
pub cmd: Command,
}
#[derive(Debug, PartialEq)]
pub enum Command {
Start {
resume_only: bool,
},
History,
Config,
WithdrawBtc {
amount: Option<Amount>,
address: Address,
},
Balance,
Redeem {
swap_id: Uuid,
do_not_await_finality: bool,
},
Cancel {
swap_id: Uuid,
},
Refund {
swap_id: Uuid,
},
Punish {
swap_id: Uuid,
},
SafelyAbort {
swap_id: Uuid,
},
ExportBitcoinWallet,
}
#[derive(structopt::StructOpt, Debug)]
#[structopt(
name = "asb",
about = "Automated Swap Backend for swapping XMR for BTC",
author,
version = env!("VERGEN_GIT_SEMVER_LIGHTWEIGHT")
)]
pub struct RawArguments {
#[structopt(long, help = "Swap on testnet")]
pub testnet: bool,
#[structopt(
short,
long = "json",
help = "Changes the log messages to json vs plain-text. If you run ASB as a service, it is recommended to set this to true to simplify log analyses."
)]
pub json: bool,
#[structopt(
short,
long = "disable-timestamp",
help = "Disable timestamping of log messages"
)]
pub disable_timestamp: bool,
#[structopt(
long = "config",
help = "Provide a custom path to the configuration file. The configuration file must be a toml file.",
parse(from_os_str)
)]
pub config: Option<PathBuf>,
#[structopt(subcommand)]
pub cmd: RawCommand,
}
#[derive(structopt::StructOpt, Debug)]
#[structopt(name = "xmr_btc-swap", about = "XMR BTC atomic swap")]
pub enum RawCommand {
#[structopt(about = "Main command to run the ASB.")]
Start {
#[structopt(
long = "resume-only",
help = "For maintenance only. When set, no new swap requests will be accepted, but existing unfinished swaps will be resumed."
)]
resume_only: bool,
},
#[structopt(about = "Prints swap-id and the state of each swap ever made.")]
History,
#[structopt(about = "Prints the current config")]
Config,
#[structopt(about = "Allows withdrawing BTC from the internal Bitcoin wallet.")]
WithdrawBtc {
#[structopt(
long = "amount",
Upgrade libp2p and stabilized the version #dependency-type: direct:production # update-type: version-update:semver-patch #dependency-type: direct:production # update-type: version-update:semver-patch # dependency-type: direct:production #update-type: version-update:semver-patch Fix failing CI tests due to deleted xmrto docker hub images Fix failing CI tests due to deleted xmrto docker hub images by moving to the docker images provided by melotools Bump tempfile from 3.2.0 to 3.3.0 Bumps [tempfile](https://github.com/Stebalien/tempfile) from 3.2.0 to 3.3.0. - [Release notes](https://github.com/Stebalien/tempfile/releases) - [Changelog](https://github.com/Stebalien/tempfile/blob/master/NEWS) - [Commits](https://github.com/Stebalien/tempfile/compare/v3.2.0...v3.3.0) --- updated-dependencies: - dependency-name: tempfile dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Always write logs as JSON to files Bump torut from 0.2.0 to 0.2.1 Bumps [torut](https://github.com/teawithsand/torut) from 0.2.0 to 0.2.1. - [Release notes](https://github.com/teawithsand/torut/releases) - [Commits](https://github.com/teawithsand/torut/commits) --- updated-dependencies: - dependency-name: torut dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump time from 0.3.3 to 0.3.7 Bumps [time](https://github.com/time-rs/time) from 0.3.3 to 0.3.7. - [Release notes](https://github.com/time-rs/time/releases) - [Changelog](https://github.com/time-rs/time/blob/main/CHANGELOG.md) - [Commits](https://github.com/time-rs/time/compare/v0.3.3...v0.3.7) --- updated-dependencies: - dependency-name: time dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump tokio from 1.12.0 to 1.16.1 Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.12.0 to 1.16.1. - [Release notes](https://github.com/tokio-rs/tokio/releases) - [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.12.0...tokio-1.16.1) --- updated-dependencies: - dependency-name: tokio dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Bump dialoguer from 0.8.0 to 0.10.0 Bumps [dialoguer](https://github.com/mitsuhiko/dialoguer) from 0.8.0 to 0.10.0. - [Release notes](https://github.com/mitsuhiko/dialoguer/releases) - [Changelog](https://github.com/mitsuhiko/dialoguer/blob/master/CHANGELOG.md) - [Commits](https://github.com/mitsuhiko/dialoguer/compare/0.8.0...v0.10.0) --- updated-dependencies: - dependency-name: dialoguer dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Bump reqwest from 0.11.7 to 0.11.9 Bumps [reqwest](https://github.com/seanmonstar/reqwest) from 0.11.7 to 0.11.9. - [Release notes](https://github.com/seanmonstar/reqwest/releases) - [Changelog](https://github.com/seanmonstar/reqwest/blob/master/CHANGELOG.md) - [Commits](https://github.com/seanmonstar/reqwest/compare/v0.11.7...v0.11.9) --- updated-dependencies: - dependency-name: reqwest dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump actions/setup-python from 2.3.1 to 2.3.2 Bumps [actions/setup-python](https://github.com/actions/setup-python) from 2.3.1 to 2.3.2. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v2.3.1...v2.3.2) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Adjust quote based on Bitcoin balance Update dependencies and rust-toolchain to 1.59 This commit updates the rust-toolchain to the current stable version 1.59, and fixes a number of new clippy warnings from that change. Other changes: - updates backoff to 0.4 - updates swap to 2021 edition - updates comfy-table to 5.0 - updates monero-wallet to 2021 edition - updates moneor-harness to 2021 edition - updates bdk and rust_decimal - updates tokio-util to 0.7 - updates workflow to use actions/setup-python@3 - updates pem and serde_with - adds stable rust toolchain notice to readme Change to rino nodes Update dprint plugins to fix CI error Bump futures from 0.3.17 to 0.3.21 Bumps [futures](https://github.com/rust-lang/futures-rs) from 0.3.17 to 0.3.21. - [Release notes](https://github.com/rust-lang/futures-rs/releases) - [Changelog](https://github.com/rust-lang/futures-rs/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/futures-rs/compare/0.3.17...0.3.21) --- updated-dependencies: - dependency-name: futures dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump structopt from 0.3.25 to 0.3.26 Bumps [structopt](https://github.com/TeXitoi/structopt) from 0.3.25 to 0.3.26. - [Release notes](https://github.com/TeXitoi/structopt/releases) - [Changelog](https://github.com/TeXitoi/structopt/blob/master/CHANGELOG.md) - [Commits](https://github.com/TeXitoi/structopt/compare/v0.3.25...v0.3.26) --- updated-dependencies: - dependency-name: structopt dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump serde from 1.0.133 to 1.0.136 Bumps [serde](https://github.com/serde-rs/serde) from 1.0.133 to 1.0.136. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.133...v1.0.136) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump hyper from 0.14.16 to 0.14.18 Bumps [hyper](https://github.com/hyperium/hyper) from 0.14.16 to 0.14.18. - [Release notes](https://github.com/hyperium/hyper/releases) - [Changelog](https://github.com/hyperium/hyper/blob/master/CHANGELOG.md) - [Commits](https://github.com/hyperium/hyper/compare/v0.14.16...v0.14.18) --- updated-dependencies: - dependency-name: hyper dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Inform Bob that he has been punished Reduce required confirmations for Bitcoin transactions from 2 to 1 Don't wait for refund transaction to receive confirmations Don't wait for refund transaction to receive confirmations to mitigate a scenario where the swap is stuck in `BtcCancelled` because it's not resumable. Add dial_as_listener to tor transport Upgrade to libp2p and stabilized version Updated dprint rustfmt pluging and 2021 Add dial_as_listener to tor transport Upgrade to libp2p and stabilized version Updated dprint rustfmt pluging and 2021 Update dprint plugins to fix CI error Bump futures from 0.3.17 to 0.3.21 Bumps [futures](https://github.com/rust-lang/futures-rs) from 0.3.17 to 0.3.21. - [Release notes](https://github.com/rust-lang/futures-rs/releases) - [Changelog](https://github.com/rust-lang/futures-rs/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/futures-rs/compare/0.3.17...0.3.21) --- updated-dependencies: - dependency-name: futures dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump structopt from 0.3.25 to 0.3.26 Bumps [structopt](https://github.com/TeXitoi/structopt) from 0.3.25 to 0.3.26. - [Release notes](https://github.com/TeXitoi/structopt/releases) - [Changelog](https://github.com/TeXitoi/structopt/blob/master/CHANGELOG.md) - [Commits](https://github.com/TeXitoi/structopt/compare/v0.3.25...v0.3.26) --- updated-dependencies: - dependency-name: structopt dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump serde from 1.0.133 to 1.0.136 Bumps [serde](https://github.com/serde-rs/serde) from 1.0.133 to 1.0.136. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.133...v1.0.136) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump hyper from 0.14.16 to 0.14.18 Bumps [hyper](https://github.com/hyperium/hyper) from 0.14.16 to 0.14.18. - [Release notes](https://github.com/hyperium/hyper/releases) - [Changelog](https://github.com/hyperium/hyper/blob/master/CHANGELOG.md) - [Commits](https://github.com/hyperium/hyper/compare/v0.14.16...v0.14.18) --- updated-dependencies: - dependency-name: hyper dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Inform Bob that he has been punished Reduce required confirmations for Bitcoin transactions from 2 to 1 Don't wait for refund transaction to receive confirmations Don't wait for refund transaction to receive confirmations to mitigate a scenario where the swap is stuck in `BtcCancelled` because it's not resumable. Add dial_as_listener to tor transport Updated dprint rustfmt pluging and 2021 Updated dprint rustfmt pluging and 2021 fix in redial fix connecting to peer message gichange in formating Update dprint plugins to fix CI error Bump futures from 0.3.17 to 0.3.21 Bumps [futures](https://github.com/rust-lang/futures-rs) from 0.3.17 to 0.3.21. - [Release notes](https://github.com/rust-lang/futures-rs/releases) - [Changelog](https://github.com/rust-lang/futures-rs/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/futures-rs/compare/0.3.17...0.3.21) --- updated-dependencies: - dependency-name: futures dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump structopt from 0.3.25 to 0.3.26 Bumps [structopt](https://github.com/TeXitoi/structopt) from 0.3.25 to 0.3.26. - [Release notes](https://github.com/TeXitoi/structopt/releases) - [Changelog](https://github.com/TeXitoi/structopt/blob/master/CHANGELOG.md) - [Commits](https://github.com/TeXitoi/structopt/compare/v0.3.25...v0.3.26) --- updated-dependencies: - dependency-name: structopt dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump serde from 1.0.133 to 1.0.136 Bumps [serde](https://github.com/serde-rs/serde) from 1.0.133 to 1.0.136. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.133...v1.0.136) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump hyper from 0.14.16 to 0.14.18 Bumps [hyper](https://github.com/hyperium/hyper) from 0.14.16 to 0.14.18. - [Release notes](https://github.com/hyperium/hyper/releases) - [Changelog](https://github.com/hyperium/hyper/blob/master/CHANGELOG.md) - [Commits](https://github.com/hyperium/hyper/compare/v0.14.16...v0.14.18) --- updated-dependencies: - dependency-name: hyper dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Inform Bob that he has been punished Reduce required confirmations for Bitcoin transactions from 2 to 1 Don't wait for refund transaction to receive confirmations Don't wait for refund transaction to receive confirmations to mitigate a scenario where the swap is stuck in `BtcCancelled` because it's not resumable. Bump actions/checkout from 2.4.0 to 3.0.0 Bumps [actions/checkout](https://github.com/actions/checkout) from 2.4.0 to 3.0.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v2.4.0...v3.0.0) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Bump tokio-util from 0.7.0 to 0.7.1 Bumps [tokio-util](https://github.com/tokio-rs/tokio) from 0.7.0 to 0.7.1. - [Release notes](https://github.com/tokio-rs/tokio/releases) - [Commits](https://github.com/tokio-rs/tokio/compare/tokio-util-0.7.0...tokio-util-0.7.1) --- updated-dependencies: - dependency-name: tokio-util dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump thomaseizinger/keep-a-changelog-new-release from 1.2.1 to 1.3.0 Bumps [thomaseizinger/keep-a-changelog-new-release](https://github.com/thomaseizinger/keep-a-changelog-new-release) from 1.2.1 to 1.3.0. - [Release notes](https://github.com/thomaseizinger/keep-a-changelog-new-release/releases) - [Changelog](https://github.com/thomaseizinger/keep-a-changelog-new-release/blob/master/CHANGELOG.md) - [Commits](https://github.com/thomaseizinger/keep-a-changelog-new-release/compare/1.2.1...1.3.0) --- updated-dependencies: - dependency-name: thomaseizinger/keep-a-changelog-new-release dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> update option documentation to specify amount format Bump async-compression from 0.3.8 to 0.3.12 Bumps [async-compression](https://github.com/Nemo157/async-compression) from 0.3.8 to 0.3.12. - [Release notes](https://github.com/Nemo157/async-compression/releases) - [Commits](https://github.com/Nemo157/async-compression/compare/0.3.8...0.3.12) --- updated-dependencies: - dependency-name: async-compression dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump serde_json from 1.0.74 to 1.0.79 Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.74 to 1.0.79. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/v1.0.74...v1.0.79) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump Swatinem/rust-cache from 1.3.0 to 1.4.0 Bumps [Swatinem/rust-cache](https://github.com/Swatinem/rust-cache) from 1.3.0 to 1.4.0. - [Release notes](https://github.com/Swatinem/rust-cache/releases) - [Changelog](https://github.com/Swatinem/rust-cache/blob/v1/CHANGELOG.md) - [Commits](https://github.com/Swatinem/rust-cache/compare/v1.3.0...v1.4.0) --- updated-dependencies: - dependency-name: Swatinem/rust-cache dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Bump tracing from 0.1.29 to 0.1.33 Bumps [tracing](https://github.com/tokio-rs/tracing) from 0.1.29 to 0.1.33. - [Release notes](https://github.com/tokio-rs/tracing/releases) - [Commits](https://github.com/tokio-rs/tracing/compare/tracing-0.1.29...tracing-0.1.33) --- updated-dependencies: - dependency-name: tracing dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump strum from 0.23.0 to 0.24.0 Bumps [strum](https://github.com/Peternator7/strum) from 0.23.0 to 0.24.0. - [Release notes](https://github.com/Peternator7/strum/releases) - [Changelog](https://github.com/Peternator7/strum/blob/master/CHANGELOG.md) - [Commits](https://github.com/Peternator7/strum/commits) --- updated-dependencies: - dependency-name: strum dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Bump serde_with from 1.12.0 to 1.12.1 Bumps [serde_with](https://github.com/jonasbb/serde_with) from 1.12.0 to 1.12.1. - [Release notes](https://github.com/jonasbb/serde_with/releases) - [Commits](https://github.com/jonasbb/serde_with/compare/v1.12.0...v1.12.1) --- updated-dependencies: - dependency-name: serde_with dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump rust_decimal_macros from 1.22.0 to 1.23.1 Bumps [rust_decimal_macros](https://github.com/paupino/rust-decimal) from 1.22.0 to 1.23.1. - [Release notes](https://github.com/paupino/rust-decimal/releases) - [Commits](https://github.com/paupino/rust-decimal/compare/1.22.0...1.23.1) --- updated-dependencies: - dependency-name: rust_decimal_macros dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Bump reqwest from 0.11.9 to 0.11.10 Bumps [reqwest](https://github.com/seanmonstar/reqwest) from 0.11.9 to 0.11.10. - [Release notes](https://github.com/seanmonstar/reqwest/releases) - [Changelog](https://github.com/seanmonstar/reqwest/blob/master/CHANGELOG.md) - [Commits](https://github.com/seanmonstar/reqwest/compare/v0.11.9...v0.11.10) --- updated-dependencies: - dependency-name: reqwest dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump time from 0.3.7 to 0.3.9 Bumps [time](https://github.com/time-rs/time) from 0.3.7 to 0.3.9. - [Release notes](https://github.com/time-rs/time/releases) - [Changelog](https://github.com/time-rs/time/blob/main/CHANGELOG.md) - [Commits](https://github.com/time-rs/time/compare/v0.3.7...v0.3.9) --- updated-dependencies: - dependency-name: time dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump toml from 0.5.8 to 0.5.9 Bumps [toml](https://github.com/alexcrichton/toml-rs) from 0.5.8 to 0.5.9. - [Release notes](https://github.com/alexcrichton/toml-rs/releases) - [Commits](https://github.com/alexcrichton/toml-rs/compare/0.5.8...0.5.9) --- updated-dependencies: - dependency-name: toml dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump actions/checkout from 3.0.0 to 3.0.1 Bumps [actions/checkout](https://github.com/actions/checkout) from 3.0.0 to 3.0.1. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3.0.0...v3.0.1) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump tracing from 0.1.33 to 0.1.34 Bumps [tracing](https://github.com/tokio-rs/tracing) from 0.1.33 to 0.1.34. - [Release notes](https://github.com/tokio-rs/tracing/releases) - [Commits](https://github.com/tokio-rs/tracing/compare/tracing-0.1.33...tracing-0.1.34) --- updated-dependencies: - dependency-name: tracing dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump vergen from 6.0.0 to 7.0.0 Bumps [vergen](https://github.com/rustyhorde/vergen) from 6.0.0 to 7.0.0. - [Release notes](https://github.com/rustyhorde/vergen/releases) - [Commits](https://github.com/rustyhorde/vergen/compare/6.0.0...7.0.0) --- updated-dependencies: - dependency-name: vergen dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Update from monero v17.2.0 to monero v17.3.0 Implement Identify protocol to make network and version of ASB available to peers Bump uuid from 0.8.2 to 1.0.0 Bumps [uuid](https://github.com/uuid-rs/uuid) from 0.8.2 to 1.0.0. - [Release notes](https://github.com/uuid-rs/uuid/releases) - [Commits](https://github.com/uuid-rs/uuid/compare/0.8.2...1.0.0) --- updated-dependencies: - dependency-name: uuid dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Update dprint plugins to fix CI error Bump futures from 0.3.17 to 0.3.21 Bumps [futures](https://github.com/rust-lang/futures-rs) from 0.3.17 to 0.3.21. - [Release notes](https://github.com/rust-lang/futures-rs/releases) - [Changelog](https://github.com/rust-lang/futures-rs/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/futures-rs/compare/0.3.17...0.3.21) --- updated-dependencies: - dependency-name: futures dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump structopt from 0.3.25 to 0.3.26 Bumps [structopt](https://github.com/TeXitoi/structopt) from 0.3.25 to 0.3.26. - [Release notes](https://github.com/TeXitoi/structopt/releases) - [Changelog](https://github.com/TeXitoi/structopt/blob/master/CHANGELOG.md) - [Commits](https://github.com/TeXitoi/structopt/compare/v0.3.25...v0.3.26) --- updated-dependencies: - dependency-name: structopt dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump serde from 1.0.133 to 1.0.136 Bumps [serde](https://github.com/serde-rs/serde) from 1.0.133 to 1.0.136. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.133...v1.0.136) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump hyper from 0.14.16 to 0.14.18 Bumps [hyper](https://github.com/hyperium/hyper) from 0.14.16 to 0.14.18. - [Release notes](https://github.com/hyperium/hyper/releases) - [Changelog](https://github.com/hyperium/hyper/blob/master/CHANGELOG.md) - [Commits](https://github.com/hyperium/hyper/compare/v0.14.16...v0.14.18) --- updated-dependencies: - dependency-name: hyper dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Inform Bob that he has been punished Don't wait for refund transaction to receive confirmations Don't wait for refund transaction to receive confirmations to mitigate a scenario where the swap is stuck in `BtcCancelled` because it's not resumable. Bump actions/checkout from 2.4.0 to 3.0.0 Bumps [actions/checkout](https://github.com/actions/checkout) from 2.4.0 to 3.0.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v2.4.0...v3.0.0) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Bump tokio-util from 0.7.0 to 0.7.1 Bumps [tokio-util](https://github.com/tokio-rs/tokio) from 0.7.0 to 0.7.1. - [Release notes](https://github.com/tokio-rs/tokio/releases) - [Commits](https://github.com/tokio-rs/tokio/compare/tokio-util-0.7.0...tokio-util-0.7.1) --- updated-dependencies: - dependency-name: tokio-util dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump thomaseizinger/keep-a-changelog-new-release from 1.2.1 to 1.3.0 Bumps [thomaseizinger/keep-a-changelog-new-release](https://github.com/thomaseizinger/keep-a-changelog-new-release) from 1.2.1 to 1.3.0. - [Release notes](https://github.com/thomaseizinger/keep-a-changelog-new-release/releases) - [Changelog](https://github.com/thomaseizinger/keep-a-changelog-new-release/blob/master/CHANGELOG.md) - [Commits](https://github.com/thomaseizinger/keep-a-changelog-new-release/compare/1.2.1...1.3.0) --- updated-dependencies: - dependency-name: thomaseizinger/keep-a-changelog-new-release dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> update option documentation to specify amount format Bump async-compression from 0.3.8 to 0.3.12 Bumps [async-compression](https://github.com/Nemo157/async-compression) from 0.3.8 to 0.3.12. - [Release notes](https://github.com/Nemo157/async-compression/releases) - [Commits](https://github.com/Nemo157/async-compression/compare/0.3.8...0.3.12) --- updated-dependencies: - dependency-name: async-compression dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump serde_json from 1.0.74 to 1.0.79 Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.74 to 1.0.79. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/v1.0.74...v1.0.79) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump Swatinem/rust-cache from 1.3.0 to 1.4.0 Bumps [Swatinem/rust-cache](https://github.com/Swatinem/rust-cache) from 1.3.0 to 1.4.0. - [Release notes](https://github.com/Swatinem/rust-cache/releases) - [Changelog](https://github.com/Swatinem/rust-cache/blob/v1/CHANGELOG.md) - [Commits](https://github.com/Swatinem/rust-cache/compare/v1.3.0...v1.4.0) --- updated-dependencies: - dependency-name: Swatinem/rust-cache dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Bump strum from 0.23.0 to 0.24.0 Bumps [strum](https://github.com/Peternator7/strum) from 0.23.0 to 0.24.0. - [Release notes](https://github.com/Peternator7/strum/releases) - [Changelog](https://github.com/Peternator7/strum/blob/master/CHANGELOG.md) - [Commits](https://github.com/Peternator7/strum/commits) --- updated-dependencies: - dependency-name: strum dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Bump serde_with from 1.12.0 to 1.12.1 Bumps [serde_with](https://github.com/jonasbb/serde_with) from 1.12.0 to 1.12.1. - [Release notes](https://github.com/jonasbb/serde_with/releases) - [Commits](https://github.com/jonasbb/serde_with/compare/v1.12.0...v1.12.1) --- updated-dependencies: - dependency-name: serde_with dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump rust_decimal_macros from 1.22.0 to 1.23.1 Bumps [rust_decimal_macros](https://github.com/paupino/rust-decimal) from 1.22.0 to 1.23.1. - [Release notes](https://github.com/paupino/rust-decimal/releases) - [Commits](https://github.com/paupino/rust-decimal/compare/1.22.0...1.23.1) --- updated-dependencies: - dependency-name: rust_decimal_macros dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Bump toml from 0.5.8 to 0.5.9 Bumps [toml](https://github.com/alexcrichton/toml-rs) from 0.5.8 to 0.5.9. - [Release notes](https://github.com/alexcrichton/toml-rs/releases) - [Commits](https://github.com/alexcrichton/toml-rs/compare/0.5.8...0.5.9) --- updated-dependencies: - dependency-name: toml dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump actions/checkout from 3.0.0 to 3.0.1 Bumps [actions/checkout](https://github.com/actions/checkout) from 3.0.0 to 3.0.1. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3.0.0...v3.0.1) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump tracing from 0.1.33 to 0.1.34 Bumps [tracing](https://github.com/tokio-rs/tracing) from 0.1.33 to 0.1.34. - [Release notes](https://github.com/tokio-rs/tracing/releases) - [Commits](https://github.com/tokio-rs/tracing/compare/tracing-0.1.33...tracing-0.1.34) --- updated-dependencies: - dependency-name: tracing dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump vergen from 6.0.0 to 7.0.0 Bumps [vergen](https://github.com/rustyhorde/vergen) from 6.0.0 to 7.0.0. - [Release notes](https://github.com/rustyhorde/vergen/releases) - [Commits](https://github.com/rustyhorde/vergen/compare/6.0.0...7.0.0) --- updated-dependencies: - dependency-name: vergen dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Bump uuid from 0.8.2 to 1.0.0 Bumps [uuid](https://github.com/uuid-rs/uuid) from 0.8.2 to 1.0.0. - [Release notes](https://github.com/uuid-rs/uuid/releases) - [Commits](https://github.com/uuid-rs/uuid/compare/0.8.2...1.0.0) --- updated-dependencies: - dependency-name: uuid dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Update dprint plugins to fix CI error Bump futures from 0.3.17 to 0.3.21 Bumps [futures](https://github.com/rust-lang/futures-rs) from 0.3.17 to 0.3.21. - [Release notes](https://github.com/rust-lang/futures-rs/releases) - [Changelog](https://github.com/rust-lang/futures-rs/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/futures-rs/compare/0.3.17...0.3.21) --- updated-dependencies: - dependency-name: futures dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump structopt from 0.3.25 to 0.3.26 Bumps [structopt](https://github.com/TeXitoi/structopt) from 0.3.25 to 0.3.26. - [Release notes](https://github.com/TeXitoi/structopt/releases) - [Changelog](https://github.com/TeXitoi/structopt/blob/master/CHANGELOG.md) - [Commits](https://github.com/TeXitoi/structopt/compare/v0.3.25...v0.3.26) --- updated-dependencies: - dependency-name: structopt dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump serde from 1.0.133 to 1.0.136 Bumps [serde](https://github.com/serde-rs/serde) from 1.0.133 to 1.0.136. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.133...v1.0.136) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump hyper from 0.14.16 to 0.14.18 Bumps [hyper](https://github.com/hyperium/hyper) from 0.14.16 to 0.14.18. - [Release notes](https://github.com/hyperium/hyper/releases) - [Changelog](https://github.com/hyperium/hyper/blob/master/CHANGELOG.md) - [Commits](https://github.com/hyperium/hyper/compare/v0.14.16...v0.14.18) --- updated-dependencies: - dependency-name: hyper dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Inform Bob that he has been punished Don't wait for refund transaction to receive confirmations Don't wait for refund transaction to receive confirmations to mitigate a scenario where the swap is stuck in `BtcCancelled` because it's not resumable. Bump tokio-util from 0.7.0 to 0.7.1 Bumps [tokio-util](https://github.com/tokio-rs/tokio) from 0.7.0 to 0.7.1. - [Release notes](https://github.com/tokio-rs/tokio/releases) - [Commits](https://github.com/tokio-rs/tokio/compare/tokio-util-0.7.0...tokio-util-0.7.1) --- updated-dependencies: - dependency-name: tokio-util dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump thomaseizinger/keep-a-changelog-new-release from 1.2.1 to 1.3.0 Bumps [thomaseizinger/keep-a-changelog-new-release](https://github.com/thomaseizinger/keep-a-changelog-new-release) from 1.2.1 to 1.3.0. - [Release notes](https://github.com/thomaseizinger/keep-a-changelog-new-release/releases) - [Changelog](https://github.com/thomaseizinger/keep-a-changelog-new-release/blob/master/CHANGELOG.md) - [Commits](https://github.com/thomaseizinger/keep-a-changelog-new-release/compare/1.2.1...1.3.0) --- updated-dependencies: - dependency-name: thomaseizinger/keep-a-changelog-new-release dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> update option documentation to specify amount format Bump async-compression from 0.3.8 to 0.3.12 Bumps [async-compression](https://github.com/Nemo157/async-compression) from 0.3.8 to 0.3.12. - [Release notes](https://github.com/Nemo157/async-compression/releases) - [Commits](https://github.com/Nemo157/async-compression/compare/0.3.8...0.3.12) --- updated-dependencies: - dependency-name: async-compression dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump serde_json from 1.0.74 to 1.0.79 Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.74 to 1.0.79. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/v1.0.74...v1.0.79) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump Swatinem/rust-cache from 1.3.0 to 1.4.0 Bumps [Swatinem/rust-cache](https://github.com/Swatinem/rust-cache) from 1.3.0 to 1.4.0. - [Release notes](https://github.com/Swatinem/rust-cache/releases) - [Changelog](https://github.com/Swatinem/rust-cache/blob/v1/CHANGELOG.md) - [Commits](https://github.com/Swatinem/rust-cache/compare/v1.3.0...v1.4.0) --- updated-dependencies: - dependency-name: Swatinem/rust-cache dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Bump strum from 0.23.0 to 0.24.0 Bumps [strum](https://github.com/Peternator7/strum) from 0.23.0 to 0.24.0. - [Release notes](https://github.com/Peternator7/strum/releases) - [Changelog](https://github.com/Peternator7/strum/blob/master/CHANGELOG.md) - [Commits](https://github.com/Peternator7/strum/commits) --- updated-dependencies: - dependency-name: strum dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Bump serde_with from 1.12.0 to 1.12.1 Bumps [serde_with](https://github.com/jonasbb/serde_with) from 1.12.0 to 1.12.1. - [Release notes](https://github.com/jonasbb/serde_with/releases) - [Commits](https://github.com/jonasbb/serde_with/compare/v1.12.0...v1.12.1) --- updated-dependencies: - dependency-name: serde_with dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump rust_decimal_macros from 1.22.0 to 1.23.1 Bumps [rust_decimal_macros](https://github.com/paupino/rust-decimal) from 1.22.0 to 1.23.1. - [Release notes](https://github.com/paupino/rust-decimal/releases) - [Commits](https://github.com/paupino/rust-decimal/compare/1.22.0...1.23.1) --- updated-dependencies: - dependency-name: rust_decimal_macros dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Bump toml from 0.5.8 to 0.5.9 Bumps [toml](https://github.com/alexcrichton/toml-rs) from 0.5.8 to 0.5.9. - [Release notes](https://github.com/alexcrichton/toml-rs/releases) - [Commits](https://github.com/alexcrichton/toml-rs/compare/0.5.8...0.5.9) --- updated-dependencies: - dependency-name: toml dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump actions/checkout from 3.0.0 to 3.0.1 Bumps [actions/checkout](https://github.com/actions/checkout) from 3.0.0 to 3.0.1. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3.0.0...v3.0.1) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump tracing from 0.1.33 to 0.1.34 Bumps [tracing](https://github.com/tokio-rs/tracing) from 0.1.33 to 0.1.34. - [Release notes](https://github.com/tokio-rs/tracing/releases) - [Commits](https://github.com/tokio-rs/tracing/compare/tracing-0.1.33...tracing-0.1.34) --- updated-dependencies: - dependency-name: tracing dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Bump vergen from 6.0.0 to 7.0.0 Bumps [vergen](https://github.com/rustyhorde/vergen) from 6.0.0 to 7.0.0. - [Release notes](https://github.com/rustyhorde/vergen/releases) - [Commits](https://github.com/rustyhorde/vergen/compare/6.0.0...7.0.0) --- updated-dependencies: - dependency-name: vergen dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Bump uuid from 0.8.2 to 1.0.0 Bumps [uuid](https://github.com/uuid-rs/uuid) from 0.8.2 to 1.0.0. - [Release notes](https://github.com/uuid-rs/uuid/releases) - [Commits](https://github.com/uuid-rs/uuid/compare/0.8.2...1.0.0) --- updated-dependencies: - dependency-name: uuid dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Checking for rendezvous peer
2 years ago
help = "Optionally specify the amount of Bitcoin to be withdrawn. If not specified the wallet will be drained. Amount must be specified in quotes with denomination, e.g `--amount '0.1 BTC'`"
)]
amount: Option<Amount>,
#[structopt(long = "address", help = "The address to receive the Bitcoin.")]
address: Address,
},
#[structopt(
about = "Prints the Bitcoin and Monero balance. Requires the monero-wallet-rpc to be running."
)]
Balance,
#[structopt(about = "Print the internal bitcoin wallet descriptor.")]
ExportBitcoinWallet,
#[structopt(about = "Contains sub-commands for recovering a swap manually.")]
ManualRecovery(ManualRecovery),
}
#[derive(structopt::StructOpt, Debug)]
pub enum ManualRecovery {
#[structopt(
about = "Publishes the Bitcoin redeem transaction. This requires that we learned the encrypted signature from Bob and is only safe if no timelock has expired."
)]
Redeem {
#[structopt(flatten)]
redeem_params: RecoverCommandParams,
#[structopt(
long = "do_not_await_finality",
help = "If this flag is present we exit directly after publishing the redeem transaction without waiting for the transaction to be included in a block"
)]
do_not_await_finality: bool,
},
#[structopt(
about = "Publishes the Bitcoin cancel transaction. By default, the cancel timelock will be enforced. A confirmed cancel transaction enables refund and punish."
)]
Cancel {
#[structopt(flatten)]
cancel_params: RecoverCommandParams,
},
#[structopt(
about = "Publishes the Monero refund transaction. By default, a swap-state where the cancel transaction was already published will be enforced. This command requires the counterparty Bitcoin refund transaction and will error if it was not published yet. "
)]
Refund {
#[structopt(flatten)]
refund_params: RecoverCommandParams,
},
#[structopt(
about = "Publishes the Bitcoin punish transaction. By default, the punish timelock and a swap-state where the cancel transaction was already published will be enforced."
)]
Punish {
#[structopt(flatten)]
punish_params: RecoverCommandParams,
},
#[structopt(about = "Safely Abort requires the swap to be in a state prior to locking XMR.")]
SafelyAbort {
#[structopt(
long = "swap-id",
help = "The swap id can be retrieved using the history subcommand"
)]
swap_id: Uuid,
},
}
#[derive(structopt::StructOpt, Debug)]
pub struct RecoverCommandParams {
#[structopt(
long = "swap-id",
help = "The swap id can be retrieved using the history subcommand"
)]
pub swap_id: Uuid,
}
#[cfg(test)]
mod tests {
use super::*;
use std::str::FromStr;
const BINARY_NAME: &str = "asb";
const BITCOIN_MAINNET_ADDRESS: &str = "1KFHE7w8BhaENAswwryaoccDb6qcT6DbYY";
const BITCOIN_TESTNET_ADDRESS: &str = "tb1qyccwk4yun26708qg5h6g6we8kxln232wclxf5a";
const SWAP_ID: &str = "ea030832-3be9-454f-bb98-5ea9a788406b";
#[test]
fn ensure_start_command_mapping_mainnet() {
let default_mainnet_conf_path = env::Mainnet::getConfigFileDefaults().unwrap().config_path;
let mainnet_env_config = env::Mainnet::get_config();
let raw_ars = vec![BINARY_NAME, "start"];
let expected_args = Arguments {
testnet: false,
json: false,
disable_timestamp: false,
config_path: default_mainnet_conf_path,
env_config: mainnet_env_config,
cmd: Command::Start { resume_only: false },
};
let args = parse_args(raw_ars).unwrap();
assert_eq!(expected_args, args);
}
#[test]
fn ensure_history_command_mapping_mainnet() {
let default_mainnet_conf_path = env::Mainnet::getConfigFileDefaults().unwrap().config_path;
let mainnet_env_config = env::Mainnet::get_config();
let raw_ars = vec![BINARY_NAME, "history"];
let expected_args = Arguments {
testnet: false,
json: false,
disable_timestamp: false,
config_path: default_mainnet_conf_path,
env_config: mainnet_env_config,
cmd: Command::History,
};
let args = parse_args(raw_ars).unwrap();
assert_eq!(expected_args, args);
}
#[test]
fn ensure_balance_command_mapping_mainnet() {
let default_mainnet_conf_path = env::Mainnet::getConfigFileDefaults().unwrap().config_path;
let mainnet_env_config = env::Mainnet::get_config();
let raw_ars = vec![BINARY_NAME, "balance"];
let expected_args = Arguments {
testnet: false,
json: false,
disable_timestamp: false,
config_path: default_mainnet_conf_path,
env_config: mainnet_env_config,
cmd: Command::Balance,
};
let args = parse_args(raw_ars).unwrap();
assert_eq!(expected_args, args);
}
#[test]
fn ensure_withdraw_command_mapping_mainnet() {
let default_mainnet_conf_path = env::Mainnet::getConfigFileDefaults().unwrap().config_path;
let mainnet_env_config = env::Mainnet::get_config();
let raw_ars = vec![
BINARY_NAME,
"withdraw-btc",
"--address",
BITCOIN_MAINNET_ADDRESS,
];
let expected_args = Arguments {
testnet: false,
json: false,
disable_timestamp: false,
config_path: default_mainnet_conf_path,
env_config: mainnet_env_config,
cmd: Command::WithdrawBtc {
amount: None,
address: Address::from_str(BITCOIN_MAINNET_ADDRESS).unwrap(),
},
};
let args = parse_args(raw_ars).unwrap();
assert_eq!(expected_args, args);
}
#[test]
fn ensure_cancel_command_mapping_mainnet() {
let default_mainnet_conf_path = env::Mainnet::getConfigFileDefaults().unwrap().config_path;
let mainnet_env_config = env::Mainnet::get_config();
let raw_ars = vec![
BINARY_NAME,
"manual-recovery",
"cancel",
"--swap-id",
SWAP_ID,
];
let expected_args = Arguments {
testnet: false,
json: false,
disable_timestamp: false,
config_path: default_mainnet_conf_path,
env_config: mainnet_env_config,
cmd: Command::Cancel {
swap_id: Uuid::parse_str(SWAP_ID).unwrap(),
},
};
let args = parse_args(raw_ars).unwrap();
assert_eq!(expected_args, args);
}
#[test]
fn ensure_refund_command_mappin_mainnet() {
let default_mainnet_conf_path = env::Mainnet::getConfigFileDefaults().unwrap().config_path;
let mainnet_env_config = env::Mainnet::get_config();
let raw_ars = vec![
BINARY_NAME,
"manual-recovery",
"refund",
"--swap-id",
SWAP_ID,
];
let expected_args = Arguments {
testnet: false,
json: false,
disable_timestamp: false,
config_path: default_mainnet_conf_path,
env_config: mainnet_env_config,
cmd: Command::Refund {
swap_id: Uuid::parse_str(SWAP_ID).unwrap(),
},
};
let args = parse_args(raw_ars).unwrap();
assert_eq!(expected_args, args);
}
#[test]
fn ensure_punish_command_mapping_mainnet() {
let default_mainnet_conf_path = env::Mainnet::getConfigFileDefaults().unwrap().config_path;
let mainnet_env_config = env::Mainnet::get_config();
let raw_ars = vec![
BINARY_NAME,
"manual-recovery",
"punish",
"--swap-id",
SWAP_ID,
];
let expected_args = Arguments {
testnet: false,
json: false,
disable_timestamp: false,
config_path: default_mainnet_conf_path,
env_config: mainnet_env_config,
cmd: Command::Punish {
swap_id: Uuid::parse_str(SWAP_ID).unwrap(),
},
};
let args = parse_args(raw_ars).unwrap();
assert_eq!(expected_args, args);
}
#[test]
fn ensure_safely_abort_command_mapping_mainnet() {
let default_mainnet_conf_path = env::Mainnet::getConfigFileDefaults().unwrap().config_path;
let mainnet_env_config = env::Mainnet::get_config();
let raw_ars = vec![
BINARY_NAME,
"manual-recovery",
"safely-abort",
"--swap-id",
SWAP_ID,
];
let expected_args = Arguments {
testnet: false,
json: false,
disable_timestamp: false,
config_path: default_mainnet_conf_path,
env_config: mainnet_env_config,
cmd: Command::SafelyAbort {
swap_id: Uuid::parse_str(SWAP_ID).unwrap(),
},
};
let args = parse_args(raw_ars).unwrap();
assert_eq!(expected_args, args);
}
#[test]
fn ensure_start_command_mapping_for_testnet() {
let default_testnet_conf_path = env::Testnet::getConfigFileDefaults().unwrap().config_path;
let testnet_env_config = env::Testnet::get_config();
let raw_ars = vec![BINARY_NAME, "--testnet", "start"];
let expected_args = Arguments {
testnet: true,
json: false,
disable_timestamp: false,
config_path: default_testnet_conf_path,
env_config: testnet_env_config,
cmd: Command::Start { resume_only: false },
};
let args = parse_args(raw_ars).unwrap();
assert_eq!(expected_args, args);
}
#[test]
fn ensure_history_command_mapping_testnet() {
let default_testnet_conf_path = env::Testnet::getConfigFileDefaults().unwrap().config_path;
let testnet_env_config = env::Testnet::get_config();
let raw_ars = vec![BINARY_NAME, "--testnet", "history"];
let expected_args = Arguments {
testnet: true,
json: false,
disable_timestamp: false,
config_path: default_testnet_conf_path,
env_config: testnet_env_config,
cmd: Command::History,
};
let args = parse_args(raw_ars).unwrap();
assert_eq!(expected_args, args);
}
#[test]
fn ensure_balance_command_mapping_testnet() {
let default_testnet_conf_path = env::Testnet::getConfigFileDefaults().unwrap().config_path;
let testnet_env_config = env::Testnet::get_config();
let raw_ars = vec![BINARY_NAME, "--testnet", "balance"];
let expected_args = Arguments {
testnet: true,
json: false,
disable_timestamp: false,
config_path: default_testnet_conf_path,
env_config: testnet_env_config,
cmd: Command::Balance,
};
let args = parse_args(raw_ars).unwrap();
assert_eq!(expected_args, args);
}
#[test]
fn ensure_withdraw_command_mapping_testnet() {
let default_testnet_conf_path = env::Testnet::getConfigFileDefaults().unwrap().config_path;
let testnet_env_config = env::Testnet::get_config();
let raw_ars = vec![
BINARY_NAME,
"--testnet",
"withdraw-btc",
"--address",
BITCOIN_TESTNET_ADDRESS,
];
let expected_args = Arguments {
testnet: true,
json: false,
disable_timestamp: false,
config_path: default_testnet_conf_path,
env_config: testnet_env_config,
cmd: Command::WithdrawBtc {
amount: None,
address: Address::from_str(BITCOIN_TESTNET_ADDRESS).unwrap(),
},
};
let args = parse_args(raw_ars).unwrap();
assert_eq!(expected_args, args);
}
#[test]
fn ensure_cancel_command_mapping_testnet() {
let default_testnet_conf_path = env::Testnet::getConfigFileDefaults().unwrap().config_path;
let testnet_env_config = env::Testnet::get_config();
let raw_ars = vec![
BINARY_NAME,
"--testnet",
"manual-recovery",
"cancel",
"--swap-id",
SWAP_ID,
];
let expected_args = Arguments {
testnet: true,
json: false,
disable_timestamp: false,
config_path: default_testnet_conf_path,
env_config: testnet_env_config,
cmd: Command::Cancel {
swap_id: Uuid::parse_str(SWAP_ID).unwrap(),
},
};
let args = parse_args(raw_ars).unwrap();
assert_eq!(expected_args, args);
}
#[test]
fn ensure_refund_command_mapping_testnet() {
let default_testnet_conf_path = env::Testnet::getConfigFileDefaults().unwrap().config_path;
let testnet_env_config = env::Testnet::get_config();
let raw_ars = vec![
BINARY_NAME,
"--testnet",
"manual-recovery",
"refund",
"--swap-id",
SWAP_ID,
];
let expected_args = Arguments {
testnet: true,
json: false,
disable_timestamp: false,
config_path: default_testnet_conf_path,
env_config: testnet_env_config,
cmd: Command::Refund {
swap_id: Uuid::parse_str(SWAP_ID).unwrap(),
},
};
let args = parse_args(raw_ars).unwrap();
assert_eq!(expected_args, args);
}
#[test]
fn ensure_punish_command_mapping_testnet() {
let default_testnet_conf_path = env::Testnet::getConfigFileDefaults().unwrap().config_path;
let testnet_env_config = env::Testnet::get_config();
let raw_ars = vec![
BINARY_NAME,
"--testnet",
"manual-recovery",
"punish",
"--swap-id",
SWAP_ID,
];
let expected_args = Arguments {
testnet: true,
json: false,
disable_timestamp: false,
config_path: default_testnet_conf_path,
env_config: testnet_env_config,
cmd: Command::Punish {
swap_id: Uuid::parse_str(SWAP_ID).unwrap(),
},
};
let args = parse_args(raw_ars).unwrap();
assert_eq!(expected_args, args);
}
#[test]
fn ensure_safely_abort_command_mapping_testnet() {
let default_testnet_conf_path = env::Testnet::getConfigFileDefaults().unwrap().config_path;
let testnet_env_config = env::Testnet::get_config();
let raw_ars = vec![
BINARY_NAME,
"--testnet",
"manual-recovery",
"safely-abort",
"--swap-id",
SWAP_ID,
];
let expected_args = Arguments {
testnet: true,
json: false,
disable_timestamp: false,
config_path: default_testnet_conf_path,
env_config: testnet_env_config,
cmd: Command::SafelyAbort {
swap_id: Uuid::parse_str(SWAP_ID).unwrap(),
},
};
let args = parse_args(raw_ars).unwrap();
assert_eq!(expected_args, args);
}
#[test]
fn ensure_disable_timestamp_mapping() {
let default_mainnet_conf_path = env::Mainnet::getConfigFileDefaults().unwrap().config_path;
let mainnet_env_config = env::Mainnet::get_config();
let raw_ars = vec![BINARY_NAME, "--disable-timestamp", "start"];
let expected_args = Arguments {
testnet: false,
json: false,
disable_timestamp: true,
config_path: default_mainnet_conf_path,
env_config: mainnet_env_config,
cmd: Command::Start { resume_only: false },
};
let args = parse_args(raw_ars).unwrap();
assert_eq!(expected_args, args);
}
#[test]
fn given_user_provides_config_path_then_no_default_config_path_returned() {
let cp = PathBuf::from_str("/some/config/path").unwrap();
let expected = config_path(Some(cp.clone()), true).unwrap();
assert_eq!(expected, cp);
let expected = config_path(Some(cp.clone()), false).unwrap();
assert_eq!(expected, cp)
}
#[test]
fn given_bitcoin_address_network_mismatch_then_error() {
let error =
bitcoin_address(Address::from_str(BITCOIN_MAINNET_ADDRESS).unwrap(), true).unwrap_err();
assert_eq!(
error
.downcast_ref::<BitcoinAddressNetworkMismatch>()
.unwrap(),
&BitcoinAddressNetworkMismatch {
expected: bitcoin::Network::Testnet,
actual: bitcoin::Network::Bitcoin
}
);
let error = bitcoin_address(Address::from_str(BITCOIN_TESTNET_ADDRESS).unwrap(), false)
.unwrap_err();
assert_eq!(
error
.downcast_ref::<BitcoinAddressNetworkMismatch>()
.unwrap(),
&BitcoinAddressNetworkMismatch {
expected: bitcoin::Network::Bitcoin,
actual: bitcoin::Network::Testnet
}
);
}
}