mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-06-01 04:56:37 -04:00
Add subcommand to print config
This subcommand has been introduced to make it easy for users to find the location of the deprecated sled database in case they wish to delete it. This feature should also resolve difficulties users were facing when trying to find where xmr-btc-swap was storing their data.
This commit is contained in:
parent
05a28dc37a
commit
394adb0a4f
6 changed files with 81 additions and 2 deletions
|
@ -65,6 +65,15 @@ where
|
|||
env_config: env_config(testnet),
|
||||
cmd: Command::Balance,
|
||||
},
|
||||
RawCommand::Config => Arguments {
|
||||
testnet,
|
||||
json,
|
||||
sled,
|
||||
disable_timestamp,
|
||||
config_path: config_path(config, testnet)?,
|
||||
env_config: env_config(testnet),
|
||||
cmd: Command::Config,
|
||||
},
|
||||
RawCommand::ManualRecovery(ManualRecovery::Redeem {
|
||||
redeem_params: RecoverCommandParams { swap_id },
|
||||
do_not_await_finality,
|
||||
|
@ -191,6 +200,7 @@ pub enum Command {
|
|||
resume_only: bool,
|
||||
},
|
||||
History,
|
||||
Config,
|
||||
WithdrawBtc {
|
||||
amount: Option<Amount>,
|
||||
address: Address,
|
||||
|
@ -270,6 +280,8 @@ pub enum RawCommand {
|
|||
},
|
||||
#[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(
|
||||
|
|
|
@ -217,6 +217,10 @@ async fn main() -> Result<()> {
|
|||
|
||||
println!("{}", table);
|
||||
}
|
||||
Command::Config => {
|
||||
let config_json = serde_json::to_string_pretty(&config)?;
|
||||
println!("{}", config_json);
|
||||
}
|
||||
Command::WithdrawBtc { amount, address } => {
|
||||
let bitcoin_wallet = init_bitcoin_wallet(&config, &seed, env_config).await?;
|
||||
|
||||
|
|
|
@ -152,7 +152,37 @@ async fn main() -> Result<()> {
|
|||
|
||||
println!("{}", table);
|
||||
}
|
||||
|
||||
Command::Config => {
|
||||
println!("Data directory: {}", data_dir.display());
|
||||
println!(
|
||||
"Log files locations: {}",
|
||||
format!("{}/wallet", data_dir.display())
|
||||
);
|
||||
println!(
|
||||
"Sled folder location: {}",
|
||||
format!("{}/database", data_dir.display())
|
||||
);
|
||||
println!(
|
||||
"Sqlite file location: {}",
|
||||
format!("{}/sqlite", data_dir.display())
|
||||
);
|
||||
println!(
|
||||
"Seed file location: {}",
|
||||
format!("{}/seed.pem", data_dir.display())
|
||||
);
|
||||
println!(
|
||||
"Monero-wallet-rpc location: {}",
|
||||
format!("{}/monero", data_dir.display())
|
||||
);
|
||||
println!(
|
||||
"Internal bitcoin wallet location: {}",
|
||||
format!("{}/wallet", data_dir.display())
|
||||
);
|
||||
println!(
|
||||
"Internal bitcoin wallet location: {}",
|
||||
format!("{}/wallet", data_dir.display())
|
||||
);
|
||||
}
|
||||
Command::WithdrawBtc {
|
||||
bitcoin_electrum_rpc_url,
|
||||
bitcoin_target_block,
|
||||
|
|
|
@ -113,6 +113,14 @@ where
|
|||
data_dir: data::data_dir_from(data, is_testnet)?,
|
||||
cmd: Command::History,
|
||||
},
|
||||
RawCommand::Config => Arguments {
|
||||
env_config: env_config_from(is_testnet),
|
||||
debug,
|
||||
json,
|
||||
sled,
|
||||
data_dir: data::data_dir_from(data, is_testnet)?,
|
||||
cmd: Command::Config,
|
||||
},
|
||||
RawCommand::Balance { bitcoin } => {
|
||||
let (bitcoin_electrum_rpc_url, bitcoin_target_block) =
|
||||
bitcoin.apply_defaults(is_testnet)?;
|
||||
|
@ -248,6 +256,7 @@ pub enum Command {
|
|||
tor_socks5_port: u16,
|
||||
},
|
||||
History,
|
||||
Config,
|
||||
WithdrawBtc {
|
||||
bitcoin_electrum_rpc_url: Url,
|
||||
bitcoin_target_block: usize,
|
||||
|
@ -355,6 +364,8 @@ enum RawCommand {
|
|||
},
|
||||
/// Show a list of past, ongoing and completed swaps
|
||||
History,
|
||||
#[structopt(about = "Prints the current config")]
|
||||
Config,
|
||||
#[structopt(about = "Allows withdrawing BTC from the internal Bitcoin wallet.")]
|
||||
WithdrawBtc {
|
||||
#[structopt(flatten)]
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
use crate::asb;
|
||||
use crate::bitcoin::{CancelTimelock, PunishTimelock};
|
||||
use serde::Serialize;
|
||||
use std::cmp::max;
|
||||
use std::time::Duration;
|
||||
use time::ext::NumericalStdDuration;
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Serialize)]
|
||||
pub struct Config {
|
||||
pub bitcoin_lock_mempool_timeout: Duration,
|
||||
pub bitcoin_lock_confirmed_timeout: Duration,
|
||||
|
@ -15,6 +16,7 @@ pub struct Config {
|
|||
pub bitcoin_network: bitcoin::Network,
|
||||
pub monero_avg_block_time: Duration,
|
||||
pub monero_finality_confirmations: u64,
|
||||
#[serde(with = "monero_network")]
|
||||
pub monero_network: monero::Network,
|
||||
}
|
||||
|
||||
|
@ -123,6 +125,23 @@ pub fn new(is_testnet: bool, asb_config: &asb::config::Config) -> Config {
|
|||
}
|
||||
}
|
||||
|
||||
mod monero_network {
|
||||
use crate::monero::Network;
|
||||
use serde::Serializer;
|
||||
|
||||
pub fn serialize<S>(x: &monero::Network, s: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
let str = match x {
|
||||
Network::Mainnet => "mainnet",
|
||||
Network::Stagenet => "stagenet",
|
||||
Network::Testnet => "testnet",
|
||||
};
|
||||
s.serialize_str(&str)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue