From 72aa517af8dd2323e0d2afcb2c7f603487b35ec9 Mon Sep 17 00:00:00 2001 From: Daniel Karzel Date: Tue, 5 Jan 2021 11:26:00 +1100 Subject: [PATCH] Work in review comments --- xmr-btc/src/bob.rs | 2 -- xmr-btc/src/config.rs | 34 +++++++++++++++++++++++++++------- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/xmr-btc/src/bob.rs b/xmr-btc/src/bob.rs index fde43449..696d3cbd 100644 --- a/xmr-btc/src/bob.rs +++ b/xmr-btc/src/bob.rs @@ -901,8 +901,6 @@ impl State5 { // NOTE: This actually generates and opens a new wallet, closing the currently // open one. - // TODO: This means that the wallet-rpc HAS to be started with the --wallet-dir - // flag, but that is mutually exclusive with --wallet-file ! monero_wallet .create_and_load_wallet_for_output(s, self.v) .await?; diff --git a/xmr-btc/src/config.rs b/xmr-btc/src/config.rs index 37e59976..e7b02d70 100644 --- a/xmr-btc/src/config.rs +++ b/xmr-btc/src/config.rs @@ -33,15 +33,15 @@ impl Config { pub fn testnet() -> Self { Self { - bob_time_to_act: *mainnet::BOB_TIME_TO_ACT, - bitcoin_finality_confirmations: mainnet::BITCOIN_FINALITY_CONFIRMATIONS, - bitcoin_avg_block_time: *mainnet::BITCOIN_AVG_BLOCK_TIME, + bob_time_to_act: *testnet::BOB_TIME_TO_ACT, + bitcoin_finality_confirmations: testnet::BITCOIN_FINALITY_CONFIRMATIONS, + bitcoin_avg_block_time: *testnet::BITCOIN_AVG_BLOCK_TIME, // We apply a scaling factor (1.5) so that the swap is not aborted when the // blockchain is slow - monero_max_finality_time: (*mainnet::MONERO_AVG_BLOCK_TIME).mul_f64(1.5) - * mainnet::MONERO_FINALITY_CONFIRMATIONS, - bitcoin_cancel_timelock: mainnet::BITCOIN_CANCEL_TIMELOCK, - bitcoin_punish_timelock: mainnet::BITCOIN_PUNISH_TIMELOCK, + monero_max_finality_time: (*testnet::MONERO_AVG_BLOCK_TIME).mul_f64(1.5) + * testnet::MONERO_FINALITY_CONFIRMATIONS, + bitcoin_cancel_timelock: testnet::BITCOIN_CANCEL_TIMELOCK, + bitcoin_punish_timelock: testnet::BITCOIN_PUNISH_TIMELOCK, bitcoin_network: ::bitcoin::Network::Testnet, monero_network: ::monero::Network::Stagenet, } @@ -83,6 +83,26 @@ mod mainnet { pub static BITCOIN_PUNISH_TIMELOCK: Timelock = Timelock::new(72); } +mod testnet { + use super::*; + + pub static BOB_TIME_TO_ACT: Lazy = Lazy::new(|| Duration::from_secs(5 * 60)); + + // This does not reflect recommended values for mainnet! + pub static BITCOIN_FINALITY_CONFIRMATIONS: u32 = 1; + + pub static BITCOIN_AVG_BLOCK_TIME: Lazy = Lazy::new(|| Duration::from_secs(5 * 60)); + + // This does not reflect recommended values for mainnet! + pub static MONERO_FINALITY_CONFIRMATIONS: u32 = 5; + + pub static MONERO_AVG_BLOCK_TIME: Lazy = Lazy::new(|| Duration::from_secs(2 * 60)); + + // This does not reflect recommended values for mainnet! + pub static BITCOIN_CANCEL_TIMELOCK: Timelock = Timelock::new(6); + pub static BITCOIN_PUNISH_TIMELOCK: Timelock = Timelock::new(6); +} + mod regtest { use super::*;