2021-02-01 23:39:34 +00:00
|
|
|
mod bitcoind;
|
|
|
|
mod electrs;
|
|
|
|
|
2021-01-15 00:26:32 +00:00
|
|
|
use crate::testutils;
|
2021-02-01 23:39:34 +00:00
|
|
|
use anyhow::{Context, Result};
|
|
|
|
use bitcoin_harness::{BitcoindRpcApi, Client};
|
2021-03-04 00:28:58 +00:00
|
|
|
use futures::Future;
|
2021-01-15 00:26:32 +00:00
|
|
|
use get_port::get_port;
|
2021-03-04 00:28:58 +00:00
|
|
|
use libp2p::core::Multiaddr;
|
2021-03-23 05:56:04 +00:00
|
|
|
use libp2p::{PeerId, Swarm};
|
2020-12-10 03:59:09 +00:00
|
|
|
use monero_harness::{image, Monero};
|
2021-03-04 00:28:58 +00:00
|
|
|
use std::path::{Path, PathBuf};
|
|
|
|
use std::sync::Arc;
|
|
|
|
use std::time::Duration;
|
2021-03-05 02:52:24 +00:00
|
|
|
use swap::asb::FixedRate;
|
2021-03-04 00:28:58 +00:00
|
|
|
use swap::bitcoin::{CancelTimelock, PunishTimelock};
|
|
|
|
use swap::database::Database;
|
2021-03-17 03:55:42 +00:00
|
|
|
use swap::env::{Config, GetConfig};
|
2021-03-23 05:56:04 +00:00
|
|
|
use swap::network::swarm;
|
2021-03-16 06:08:19 +00:00
|
|
|
use swap::protocol::alice::{AliceState, Swap};
|
2021-03-04 00:28:58 +00:00
|
|
|
use swap::protocol::bob::BobState;
|
|
|
|
use swap::protocol::{alice, bob};
|
|
|
|
use swap::seed::Seed;
|
2021-03-17 03:55:42 +00:00
|
|
|
use swap::{bitcoin, env, monero};
|
2020-12-10 03:59:09 +00:00
|
|
|
use tempfile::tempdir;
|
2021-03-04 00:28:58 +00:00
|
|
|
use testcontainers::clients::Cli;
|
|
|
|
use testcontainers::{Container, Docker, RunArgs};
|
|
|
|
use tokio::sync::mpsc;
|
|
|
|
use tokio::task::JoinHandle;
|
|
|
|
use tokio::time::interval;
|
2021-02-22 01:25:41 +00:00
|
|
|
use tracing::dispatcher::DefaultGuard;
|
2021-02-01 23:39:34 +00:00
|
|
|
use url::Url;
|
2021-01-15 00:26:32 +00:00
|
|
|
use uuid::Uuid;
|
|
|
|
|
2021-03-02 23:58:47 +00:00
|
|
|
const MONERO_WALLET_NAME_BOB: &str = "bob";
|
|
|
|
const MONERO_WALLET_NAME_ALICE: &str = "alice";
|
|
|
|
const BITCOIN_TEST_WALLET_NAME: &str = "testwallet";
|
2021-02-01 23:39:34 +00:00
|
|
|
|
2021-01-19 03:48:07 +00:00
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
pub struct StartingBalances {
|
|
|
|
pub xmr: monero::Amount,
|
|
|
|
pub btc: bitcoin::Amount,
|
|
|
|
}
|
|
|
|
|
2021-01-20 10:42:35 +00:00
|
|
|
struct BobParams {
|
|
|
|
seed: Seed,
|
|
|
|
db_path: PathBuf,
|
|
|
|
swap_id: Uuid,
|
|
|
|
bitcoin_wallet: Arc<bitcoin::Wallet>,
|
|
|
|
monero_wallet: Arc<monero::Wallet>,
|
|
|
|
alice_address: Multiaddr,
|
|
|
|
alice_peer_id: PeerId,
|
2021-03-17 03:55:42 +00:00
|
|
|
env_config: Config,
|
2021-01-20 10:42:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl BobParams {
|
2021-03-02 11:07:48 +00:00
|
|
|
pub async fn builder(&self, event_loop_handle: bob::EventLoopHandle) -> Result<bob::Builder> {
|
2021-03-16 08:24:41 +00:00
|
|
|
let receive_address = self.monero_wallet.get_main_address();
|
2021-03-02 11:07:48 +00:00
|
|
|
|
|
|
|
Ok(bob::Builder::new(
|
2021-02-11 04:21:34 +00:00
|
|
|
Database::open(&self.db_path.clone().as_path()).unwrap(),
|
2021-01-20 10:42:35 +00:00
|
|
|
self.swap_id,
|
|
|
|
self.bitcoin_wallet.clone(),
|
|
|
|
self.monero_wallet.clone(),
|
2021-03-17 03:55:42 +00:00
|
|
|
self.env_config,
|
2021-03-03 02:56:25 +00:00
|
|
|
event_loop_handle,
|
2021-03-02 11:07:48 +00:00
|
|
|
receive_address,
|
|
|
|
))
|
2021-03-03 02:56:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn new_eventloop(&self) -> Result<(bob::EventLoop, bob::EventLoopHandle)> {
|
2021-03-23 05:56:04 +00:00
|
|
|
let mut swarm = swarm::new::<bob::Behaviour>(&self.seed)?;
|
|
|
|
swarm.add_address(self.alice_peer_id, self.alice_address.clone());
|
|
|
|
|
|
|
|
bob::EventLoop::new(swarm, self.alice_peer_id, self.bitcoin_wallet.clone())
|
2021-01-20 10:42:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-18 07:00:02 +00:00
|
|
|
pub struct BobEventLoopJoinHandle(JoinHandle<()>);
|
2021-01-22 02:33:31 +00:00
|
|
|
|
2021-02-09 00:15:55 +00:00
|
|
|
impl BobEventLoopJoinHandle {
|
|
|
|
pub fn abort(&self) {
|
|
|
|
self.0.abort()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-22 02:33:31 +00:00
|
|
|
pub struct AliceEventLoopJoinHandle(JoinHandle<()>);
|
|
|
|
|
2021-01-19 23:40:40 +00:00
|
|
|
pub struct TestContext {
|
2021-02-15 02:01:38 +00:00
|
|
|
btc_amount: bitcoin::Amount,
|
|
|
|
xmr_amount: monero::Amount,
|
2021-01-19 04:03:30 +00:00
|
|
|
|
2021-01-19 03:48:07 +00:00
|
|
|
alice_starting_balances: StartingBalances,
|
2021-01-19 04:03:30 +00:00
|
|
|
alice_bitcoin_wallet: Arc<bitcoin::Wallet>,
|
|
|
|
alice_monero_wallet: Arc<monero::Wallet>,
|
2021-03-16 06:08:19 +00:00
|
|
|
alice_swap_handle: mpsc::Receiver<Swap>,
|
2021-01-19 04:03:30 +00:00
|
|
|
|
2021-01-20 10:42:35 +00:00
|
|
|
bob_params: BobParams,
|
2021-01-19 03:36:24 +00:00
|
|
|
bob_starting_balances: StartingBalances,
|
2021-01-19 04:09:05 +00:00
|
|
|
bob_bitcoin_wallet: Arc<bitcoin::Wallet>,
|
|
|
|
bob_monero_wallet: Arc<monero::Wallet>,
|
2021-01-18 08:56:43 +00:00
|
|
|
}
|
|
|
|
|
2021-01-19 23:40:40 +00:00
|
|
|
impl TestContext {
|
2021-03-16 06:08:19 +00:00
|
|
|
pub async fn alice_next_swap(&mut self) -> alice::Swap {
|
|
|
|
self.alice_swap_handle.recv().await.unwrap()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub async fn bob_swap(&mut self) -> (bob::Swap, BobEventLoopJoinHandle) {
|
2021-03-03 02:56:25 +00:00
|
|
|
let (event_loop, event_loop_handle) = self.bob_params.new_eventloop().unwrap();
|
|
|
|
|
|
|
|
let swap = self
|
2021-01-20 10:42:35 +00:00
|
|
|
.bob_params
|
2021-03-03 02:56:25 +00:00
|
|
|
.builder(event_loop_handle)
|
2021-03-02 11:07:48 +00:00
|
|
|
.await
|
|
|
|
.unwrap()
|
2021-02-15 02:01:38 +00:00
|
|
|
.with_init_params(self.btc_amount)
|
2021-01-19 04:21:40 +00:00
|
|
|
.build()
|
2021-01-18 10:57:17 +00:00
|
|
|
.unwrap();
|
2021-01-18 08:56:43 +00:00
|
|
|
|
2021-03-03 02:36:37 +00:00
|
|
|
let join_handle = tokio::spawn(event_loop.run());
|
2021-01-18 08:56:43 +00:00
|
|
|
|
2021-01-22 02:33:31 +00:00
|
|
|
(swap, BobEventLoopJoinHandle(join_handle))
|
2021-01-18 08:56:43 +00:00
|
|
|
}
|
|
|
|
|
2021-01-22 02:33:31 +00:00
|
|
|
pub async fn stop_and_resume_bob_from_db(
|
|
|
|
&mut self,
|
|
|
|
join_handle: BobEventLoopJoinHandle,
|
2021-02-01 07:13:08 +00:00
|
|
|
) -> (bob::Swap, BobEventLoopJoinHandle) {
|
2021-02-09 00:15:55 +00:00
|
|
|
join_handle.abort();
|
2021-01-22 02:33:31 +00:00
|
|
|
|
2021-03-03 02:56:25 +00:00
|
|
|
let (event_loop, event_loop_handle) = self.bob_params.new_eventloop().unwrap();
|
|
|
|
|
2021-03-02 11:07:48 +00:00
|
|
|
let swap = self
|
|
|
|
.bob_params
|
|
|
|
.builder(event_loop_handle)
|
|
|
|
.await
|
|
|
|
.unwrap()
|
|
|
|
.build()
|
|
|
|
.unwrap();
|
2021-01-18 08:56:43 +00:00
|
|
|
|
2021-03-03 02:36:37 +00:00
|
|
|
let join_handle = tokio::spawn(event_loop.run());
|
2021-01-18 08:56:43 +00:00
|
|
|
|
2021-02-01 07:13:08 +00:00
|
|
|
(swap, BobEventLoopJoinHandle(join_handle))
|
2021-01-18 08:56:43 +00:00
|
|
|
}
|
|
|
|
|
2021-03-16 06:08:19 +00:00
|
|
|
pub async fn assert_alice_redeemed(&mut self, state: AliceState) {
|
2021-01-18 08:56:43 +00:00
|
|
|
assert!(matches!(state, AliceState::BtcRedeemed));
|
|
|
|
|
2021-03-04 06:07:02 +00:00
|
|
|
self.alice_bitcoin_wallet.sync().await.unwrap();
|
2021-02-01 23:39:34 +00:00
|
|
|
|
2021-01-19 04:03:30 +00:00
|
|
|
let btc_balance_after_swap = self.alice_bitcoin_wallet.as_ref().balance().await.unwrap();
|
2021-01-18 08:56:43 +00:00
|
|
|
assert_eq!(
|
|
|
|
btc_balance_after_swap,
|
2021-02-15 02:01:38 +00:00
|
|
|
self.alice_starting_balances.btc + self.btc_amount
|
2021-01-18 08:56:43 +00:00
|
|
|
- bitcoin::Amount::from_sat(bitcoin::TX_FEE)
|
|
|
|
);
|
|
|
|
|
|
|
|
let xmr_balance_after_swap = self
|
2021-01-19 04:03:30 +00:00
|
|
|
.alice_monero_wallet
|
2021-01-18 08:56:43 +00:00
|
|
|
.as_ref()
|
|
|
|
.get_balance()
|
|
|
|
.await
|
|
|
|
.unwrap();
|
2021-02-18 22:57:46 +00:00
|
|
|
assert!(
|
|
|
|
xmr_balance_after_swap <= self.alice_starting_balances.xmr - self.xmr_amount,
|
|
|
|
"{} !< {} - {}",
|
|
|
|
xmr_balance_after_swap,
|
|
|
|
self.alice_starting_balances.xmr,
|
|
|
|
self.xmr_amount
|
|
|
|
);
|
2021-01-18 08:56:43 +00:00
|
|
|
}
|
|
|
|
|
2021-03-16 06:08:19 +00:00
|
|
|
pub async fn assert_alice_refunded(&mut self, state: AliceState) {
|
2021-02-15 05:13:29 +00:00
|
|
|
assert!(matches!(state, AliceState::XmrRefunded));
|
2021-01-18 08:56:43 +00:00
|
|
|
|
2021-03-04 06:07:02 +00:00
|
|
|
self.alice_bitcoin_wallet.sync().await.unwrap();
|
2021-02-01 23:39:34 +00:00
|
|
|
|
2021-01-19 04:03:30 +00:00
|
|
|
let btc_balance_after_swap = self.alice_bitcoin_wallet.as_ref().balance().await.unwrap();
|
2021-01-19 03:48:07 +00:00
|
|
|
assert_eq!(btc_balance_after_swap, self.alice_starting_balances.btc);
|
2021-01-18 08:56:43 +00:00
|
|
|
|
|
|
|
// Ensure that Alice's balance is refreshed as we use a newly created wallet
|
2021-02-24 05:34:04 +00:00
|
|
|
self.alice_monero_wallet.as_ref().refresh().await.unwrap();
|
2021-01-18 08:56:43 +00:00
|
|
|
let xmr_balance_after_swap = self
|
2021-01-19 04:03:30 +00:00
|
|
|
.alice_monero_wallet
|
2021-01-18 08:56:43 +00:00
|
|
|
.as_ref()
|
|
|
|
.get_balance()
|
|
|
|
.await
|
|
|
|
.unwrap();
|
2021-03-16 08:24:41 +00:00
|
|
|
|
|
|
|
// Alice pays fees - comparison does not take exact lock fee into account
|
|
|
|
assert!(
|
|
|
|
xmr_balance_after_swap > self.alice_starting_balances.xmr - self.xmr_amount,
|
|
|
|
"{} > {} - {}",
|
|
|
|
xmr_balance_after_swap,
|
|
|
|
self.alice_starting_balances.xmr,
|
|
|
|
self.xmr_amount
|
|
|
|
);
|
2021-01-18 08:56:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub async fn assert_alice_punished(&self, state: AliceState) {
|
|
|
|
assert!(matches!(state, AliceState::BtcPunished));
|
|
|
|
|
2021-03-04 06:07:02 +00:00
|
|
|
self.alice_bitcoin_wallet.sync().await.unwrap();
|
2021-02-01 23:39:34 +00:00
|
|
|
|
2021-01-19 04:03:30 +00:00
|
|
|
let btc_balance_after_swap = self.alice_bitcoin_wallet.as_ref().balance().await.unwrap();
|
2021-01-18 08:56:43 +00:00
|
|
|
assert_eq!(
|
|
|
|
btc_balance_after_swap,
|
2021-02-15 02:01:38 +00:00
|
|
|
self.alice_starting_balances.btc + self.btc_amount
|
2021-01-18 08:56:43 +00:00
|
|
|
- bitcoin::Amount::from_sat(2 * bitcoin::TX_FEE)
|
|
|
|
);
|
|
|
|
|
|
|
|
let xmr_balance_after_swap = self
|
2021-01-19 04:03:30 +00:00
|
|
|
.alice_monero_wallet
|
2021-01-18 08:56:43 +00:00
|
|
|
.as_ref()
|
|
|
|
.get_balance()
|
|
|
|
.await
|
|
|
|
.unwrap();
|
2021-02-15 02:01:38 +00:00
|
|
|
assert!(xmr_balance_after_swap <= self.alice_starting_balances.xmr - self.xmr_amount);
|
2021-01-18 08:56:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub async fn assert_bob_redeemed(&self, state: BobState) {
|
2021-03-04 06:07:02 +00:00
|
|
|
self.bob_bitcoin_wallet.sync().await.unwrap();
|
2021-02-01 23:39:34 +00:00
|
|
|
|
2021-01-18 08:56:43 +00:00
|
|
|
let lock_tx_id = if let BobState::XmrRedeemed { tx_lock_id } = state {
|
|
|
|
tx_lock_id
|
|
|
|
} else {
|
2021-01-27 02:41:08 +00:00
|
|
|
panic!("Bob in not in xmr redeemed state: {:?}", state);
|
2021-01-18 08:56:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
let lock_tx_bitcoin_fee = self
|
2021-01-19 04:09:05 +00:00
|
|
|
.bob_bitcoin_wallet
|
2021-01-18 08:56:43 +00:00
|
|
|
.transaction_fee(lock_tx_id)
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
|
2021-01-19 04:09:05 +00:00
|
|
|
let btc_balance_after_swap = self.bob_bitcoin_wallet.as_ref().balance().await.unwrap();
|
2021-01-18 08:56:43 +00:00
|
|
|
assert_eq!(
|
|
|
|
btc_balance_after_swap,
|
2021-02-15 02:01:38 +00:00
|
|
|
self.bob_starting_balances.btc - self.btc_amount - lock_tx_bitcoin_fee
|
2021-01-18 08:56:43 +00:00
|
|
|
);
|
|
|
|
|
2021-03-02 11:07:48 +00:00
|
|
|
// unload the generated wallet by opening the original wallet
|
2021-03-16 08:24:41 +00:00
|
|
|
self.bob_monero_wallet.re_open().await.unwrap();
|
2021-03-02 11:07:48 +00:00
|
|
|
// refresh the original wallet to make sure the balance is caught up
|
|
|
|
self.bob_monero_wallet.refresh().await.unwrap();
|
|
|
|
|
2021-01-18 08:56:43 +00:00
|
|
|
// Ensure that Bob's balance is refreshed as we use a newly created wallet
|
2021-02-24 05:34:04 +00:00
|
|
|
self.bob_monero_wallet.as_ref().refresh().await.unwrap();
|
2021-01-19 04:09:05 +00:00
|
|
|
let xmr_balance_after_swap = self.bob_monero_wallet.as_ref().get_balance().await.unwrap();
|
2021-03-02 11:07:48 +00:00
|
|
|
assert!(xmr_balance_after_swap > self.bob_starting_balances.xmr);
|
2021-01-18 08:56:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub async fn assert_bob_refunded(&self, state: BobState) {
|
2021-03-04 06:07:02 +00:00
|
|
|
self.bob_bitcoin_wallet.sync().await.unwrap();
|
2021-02-01 23:39:34 +00:00
|
|
|
|
2021-01-18 08:56:43 +00:00
|
|
|
let lock_tx_id = if let BobState::BtcRefunded(state4) = state {
|
|
|
|
state4.tx_lock_id()
|
|
|
|
} else {
|
2021-01-27 02:41:08 +00:00
|
|
|
panic!("Bob in not in btc refunded state: {:?}", state);
|
2021-01-18 08:56:43 +00:00
|
|
|
};
|
|
|
|
let lock_tx_bitcoin_fee = self
|
2021-01-19 04:09:05 +00:00
|
|
|
.bob_bitcoin_wallet
|
2021-01-18 08:56:43 +00:00
|
|
|
.transaction_fee(lock_tx_id)
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
|
2021-01-19 04:09:05 +00:00
|
|
|
let btc_balance_after_swap = self.bob_bitcoin_wallet.as_ref().balance().await.unwrap();
|
2021-01-18 08:56:43 +00:00
|
|
|
|
|
|
|
let alice_submitted_cancel = btc_balance_after_swap
|
2021-01-19 03:36:24 +00:00
|
|
|
== self.bob_starting_balances.btc
|
2021-01-18 08:56:43 +00:00
|
|
|
- lock_tx_bitcoin_fee
|
|
|
|
- bitcoin::Amount::from_sat(bitcoin::TX_FEE);
|
|
|
|
|
|
|
|
let bob_submitted_cancel = btc_balance_after_swap
|
2021-01-19 03:36:24 +00:00
|
|
|
== self.bob_starting_balances.btc
|
2021-01-18 08:56:43 +00:00
|
|
|
- lock_tx_bitcoin_fee
|
|
|
|
- bitcoin::Amount::from_sat(2 * bitcoin::TX_FEE);
|
|
|
|
|
|
|
|
// The cancel tx can be submitted by both Alice and Bob.
|
|
|
|
// Since we cannot be sure who submitted it we have to assert accordingly
|
|
|
|
assert!(alice_submitted_cancel || bob_submitted_cancel);
|
|
|
|
|
2021-01-19 04:09:05 +00:00
|
|
|
let xmr_balance_after_swap = self.bob_monero_wallet.as_ref().get_balance().await.unwrap();
|
2021-01-19 03:36:24 +00:00
|
|
|
assert_eq!(xmr_balance_after_swap, self.bob_starting_balances.xmr);
|
2021-01-18 08:56:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub async fn assert_bob_punished(&self, state: BobState) {
|
2021-03-04 06:07:02 +00:00
|
|
|
self.bob_bitcoin_wallet.sync().await.unwrap();
|
2021-02-01 23:39:34 +00:00
|
|
|
|
2021-01-18 08:56:43 +00:00
|
|
|
let lock_tx_id = if let BobState::BtcPunished { tx_lock_id } = state {
|
|
|
|
tx_lock_id
|
|
|
|
} else {
|
2021-01-27 02:41:08 +00:00
|
|
|
panic!("Bob in not in btc punished state: {:?}", state);
|
2021-01-18 08:56:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
let lock_tx_bitcoin_fee = self
|
2021-01-19 04:09:05 +00:00
|
|
|
.bob_bitcoin_wallet
|
2021-01-18 08:56:43 +00:00
|
|
|
.transaction_fee(lock_tx_id)
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
|
2021-01-19 04:09:05 +00:00
|
|
|
let btc_balance_after_swap = self.bob_bitcoin_wallet.as_ref().balance().await.unwrap();
|
2021-01-18 08:56:43 +00:00
|
|
|
assert_eq!(
|
|
|
|
btc_balance_after_swap,
|
2021-02-15 02:01:38 +00:00
|
|
|
self.bob_starting_balances.btc - self.btc_amount - lock_tx_bitcoin_fee
|
2021-01-18 08:56:43 +00:00
|
|
|
);
|
|
|
|
|
2021-01-19 04:09:05 +00:00
|
|
|
let xmr_balance_after_swap = self.bob_monero_wallet.as_ref().get_balance().await.unwrap();
|
2021-01-19 03:36:24 +00:00
|
|
|
assert_eq!(xmr_balance_after_swap, self.bob_starting_balances.xmr);
|
2021-01-18 08:56:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-29 02:52:05 +00:00
|
|
|
pub async fn setup_test<T, F, C>(_config: C, testfn: T)
|
2021-01-18 02:03:56 +00:00
|
|
|
where
|
2021-01-19 23:40:40 +00:00
|
|
|
T: Fn(TestContext) -> F,
|
2021-03-16 06:08:19 +00:00
|
|
|
F: Future<Output = Result<()>>,
|
2021-03-17 03:55:42 +00:00
|
|
|
C: GetConfig,
|
2021-01-18 02:03:56 +00:00
|
|
|
{
|
|
|
|
let cli = Cli::default();
|
|
|
|
|
|
|
|
let _guard = init_tracing();
|
|
|
|
|
2021-03-17 03:55:42 +00:00
|
|
|
let env_config = C::get_config();
|
2021-01-29 02:52:05 +00:00
|
|
|
|
2021-01-18 02:03:56 +00:00
|
|
|
let (monero, containers) = testutils::init_containers(&cli).await;
|
|
|
|
|
2021-02-15 02:01:38 +00:00
|
|
|
let btc_amount = bitcoin::Amount::from_sat(1_000_000);
|
2021-03-05 02:52:24 +00:00
|
|
|
let xmr_amount = monero::Amount::from_monero(btc_amount.as_btc() / FixedRate::RATE).unwrap();
|
2021-01-18 02:03:56 +00:00
|
|
|
|
|
|
|
let alice_starting_balances = StartingBalances {
|
2021-02-15 02:01:38 +00:00
|
|
|
xmr: xmr_amount * 10,
|
2021-01-18 02:03:56 +00:00
|
|
|
btc: bitcoin::Amount::ZERO,
|
|
|
|
};
|
2021-01-18 10:24:13 +00:00
|
|
|
|
|
|
|
let port = get_port().expect("Failed to find a free port");
|
|
|
|
|
2021-02-15 04:00:47 +00:00
|
|
|
let alice_listen_address: Multiaddr = format!("/ip4/127.0.0.1/tcp/{}", port)
|
2021-01-18 10:24:13 +00:00
|
|
|
.parse()
|
|
|
|
.expect("failed to parse Alice's address");
|
|
|
|
|
2021-02-01 23:39:34 +00:00
|
|
|
let electrs_rpc_port = containers
|
|
|
|
.electrs
|
|
|
|
.get_host_port(testutils::electrs::RPC_PORT)
|
|
|
|
.expect("Could not map electrs rpc port");
|
|
|
|
|
2021-02-09 06:23:13 +00:00
|
|
|
let alice_seed = Seed::random().unwrap();
|
|
|
|
let bob_seed = Seed::random().unwrap();
|
|
|
|
|
2021-01-27 02:33:32 +00:00
|
|
|
let (alice_bitcoin_wallet, alice_monero_wallet) = init_test_wallets(
|
2021-03-02 23:58:47 +00:00
|
|
|
MONERO_WALLET_NAME_ALICE,
|
2021-02-01 23:39:34 +00:00
|
|
|
containers.bitcoind_url.clone(),
|
2021-01-18 10:24:13 +00:00
|
|
|
&monero,
|
|
|
|
alice_starting_balances.clone(),
|
2021-02-01 23:39:34 +00:00
|
|
|
tempdir().unwrap().path(),
|
|
|
|
electrs_rpc_port,
|
2021-02-09 06:23:13 +00:00
|
|
|
alice_seed,
|
2021-03-17 03:55:42 +00:00
|
|
|
env_config,
|
2021-01-18 10:24:13 +00:00
|
|
|
)
|
|
|
|
.await;
|
|
|
|
|
2021-02-09 00:15:55 +00:00
|
|
|
let db_path = tempdir().unwrap();
|
|
|
|
let alice_db = Arc::new(Database::open(db_path.path()).unwrap());
|
|
|
|
|
2021-02-15 04:00:47 +00:00
|
|
|
let alice_seed = Seed::random().unwrap();
|
2021-01-18 02:03:56 +00:00
|
|
|
|
|
|
|
let bob_starting_balances = StartingBalances {
|
|
|
|
xmr: monero::Amount::ZERO,
|
2021-02-15 02:01:38 +00:00
|
|
|
btc: btc_amount * 10,
|
2021-01-18 02:03:56 +00:00
|
|
|
};
|
|
|
|
|
2021-01-27 02:33:32 +00:00
|
|
|
let (bob_bitcoin_wallet, bob_monero_wallet) = init_test_wallets(
|
2021-03-02 23:58:47 +00:00
|
|
|
MONERO_WALLET_NAME_BOB,
|
2021-02-01 23:39:34 +00:00
|
|
|
containers.bitcoind_url,
|
2021-01-18 10:57:17 +00:00
|
|
|
&monero,
|
|
|
|
bob_starting_balances.clone(),
|
2021-02-01 23:39:34 +00:00
|
|
|
tempdir().unwrap().path(),
|
|
|
|
electrs_rpc_port,
|
2021-02-09 06:23:13 +00:00
|
|
|
bob_seed,
|
2021-03-17 03:55:42 +00:00
|
|
|
env_config,
|
2021-01-18 10:57:17 +00:00
|
|
|
)
|
|
|
|
.await;
|
|
|
|
|
2021-03-23 05:56:04 +00:00
|
|
|
let mut alice_swarm = swarm::new::<alice::Behaviour>(&alice_seed).unwrap();
|
|
|
|
Swarm::listen_on(&mut alice_swarm, alice_listen_address.clone()).unwrap();
|
|
|
|
|
2021-03-03 02:36:37 +00:00
|
|
|
let (alice_event_loop, alice_swap_handle) = alice::EventLoop::new(
|
2021-03-23 05:56:04 +00:00
|
|
|
alice_swarm,
|
2021-03-17 03:55:42 +00:00
|
|
|
env_config,
|
2021-02-09 00:15:55 +00:00
|
|
|
alice_bitcoin_wallet.clone(),
|
|
|
|
alice_monero_wallet.clone(),
|
|
|
|
alice_db,
|
2021-03-05 02:52:24 +00:00
|
|
|
FixedRate::default(),
|
2021-03-02 05:22:39 +00:00
|
|
|
bitcoin::Amount::ONE_BTC,
|
2021-02-09 00:15:55 +00:00
|
|
|
)
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
let alice_peer_id = alice_event_loop.peer_id();
|
|
|
|
|
2021-03-03 02:36:37 +00:00
|
|
|
tokio::spawn(alice_event_loop.run());
|
2021-02-09 00:15:55 +00:00
|
|
|
|
2021-01-20 10:42:35 +00:00
|
|
|
let bob_params = BobParams {
|
|
|
|
seed: Seed::random().unwrap(),
|
|
|
|
db_path: tempdir().unwrap().path().to_path_buf(),
|
|
|
|
swap_id: Uuid::new_v4(),
|
|
|
|
bitcoin_wallet: bob_bitcoin_wallet.clone(),
|
|
|
|
monero_wallet: bob_monero_wallet.clone(),
|
2021-02-15 04:00:47 +00:00
|
|
|
alice_address: alice_listen_address,
|
2021-02-09 00:15:55 +00:00
|
|
|
alice_peer_id,
|
2021-03-17 03:55:42 +00:00
|
|
|
env_config,
|
2021-01-20 10:42:35 +00:00
|
|
|
};
|
2021-01-18 02:03:56 +00:00
|
|
|
|
2021-01-19 23:40:40 +00:00
|
|
|
let test = TestContext {
|
2021-02-15 02:01:38 +00:00
|
|
|
btc_amount,
|
|
|
|
xmr_amount,
|
2021-01-19 03:48:07 +00:00
|
|
|
alice_starting_balances,
|
2021-01-19 04:03:30 +00:00
|
|
|
alice_bitcoin_wallet,
|
|
|
|
alice_monero_wallet,
|
2021-02-15 04:00:47 +00:00
|
|
|
alice_swap_handle,
|
2021-01-20 10:42:35 +00:00
|
|
|
bob_params,
|
2021-01-19 03:36:24 +00:00
|
|
|
bob_starting_balances,
|
2021-01-19 04:09:05 +00:00
|
|
|
bob_bitcoin_wallet,
|
|
|
|
bob_monero_wallet,
|
2021-01-18 08:56:43 +00:00
|
|
|
};
|
2021-01-15 07:34:46 +00:00
|
|
|
|
2021-03-16 06:08:19 +00:00
|
|
|
testfn(test).await.unwrap()
|
2021-01-15 00:26:32 +00:00
|
|
|
}
|
|
|
|
|
2021-02-01 23:39:34 +00:00
|
|
|
fn random_prefix() -> String {
|
2021-03-04 00:28:58 +00:00
|
|
|
use rand::distributions::Alphanumeric;
|
|
|
|
use rand::{thread_rng, Rng};
|
2021-02-01 23:39:34 +00:00
|
|
|
use std::iter;
|
|
|
|
const LEN: usize = 8;
|
|
|
|
let mut rng = thread_rng();
|
|
|
|
let chars: String = iter::repeat(())
|
|
|
|
.map(|()| rng.sample(Alphanumeric))
|
|
|
|
.map(char::from)
|
|
|
|
.take(LEN)
|
|
|
|
.collect();
|
|
|
|
chars
|
|
|
|
}
|
|
|
|
|
2021-01-18 01:57:27 +00:00
|
|
|
async fn init_containers(cli: &Cli) -> (Monero, Containers<'_>) {
|
2021-02-01 23:39:34 +00:00
|
|
|
let prefix = random_prefix();
|
|
|
|
let bitcoind_name = format!("{}_{}", prefix, "bitcoind");
|
|
|
|
let (bitcoind, bitcoind_url) =
|
|
|
|
init_bitcoind_container(&cli, prefix.clone(), bitcoind_name.clone(), prefix.clone())
|
|
|
|
.await
|
|
|
|
.expect("could not init bitcoind");
|
|
|
|
let electrs = init_electrs_container(&cli, prefix.clone(), bitcoind_name, prefix)
|
|
|
|
.await
|
|
|
|
.expect("could not init electrs");
|
|
|
|
let (monero, monerods) = init_monero_container(&cli).await;
|
|
|
|
(monero, Containers {
|
|
|
|
bitcoind_url,
|
|
|
|
bitcoind,
|
|
|
|
monerods,
|
|
|
|
electrs,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
async fn init_bitcoind_container(
|
|
|
|
cli: &Cli,
|
|
|
|
volume: String,
|
|
|
|
name: String,
|
|
|
|
network: String,
|
|
|
|
) -> Result<(Container<'_, Cli, bitcoind::Bitcoind>, Url)> {
|
2021-03-12 01:50:42 +00:00
|
|
|
let image = bitcoind::Bitcoind::default().with_volume(volume);
|
2021-02-01 23:39:34 +00:00
|
|
|
|
|
|
|
let run_args = RunArgs::default().with_name(name).with_network(network);
|
|
|
|
|
|
|
|
let docker = cli.run_with_args(image, run_args);
|
|
|
|
let a = docker
|
|
|
|
.get_host_port(testutils::bitcoind::RPC_PORT)
|
|
|
|
.context("Could not map bitcoind rpc port")?;
|
|
|
|
|
|
|
|
let bitcoind_url = {
|
|
|
|
let input = format!(
|
|
|
|
"http://{}:{}@localhost:{}",
|
|
|
|
bitcoind::RPC_USER,
|
|
|
|
bitcoind::RPC_PASSWORD,
|
|
|
|
a
|
|
|
|
);
|
|
|
|
Url::parse(&input).unwrap()
|
|
|
|
};
|
|
|
|
|
|
|
|
init_bitcoind(bitcoind_url.clone(), 5).await?;
|
|
|
|
|
|
|
|
Ok((docker, bitcoind_url.clone()))
|
|
|
|
}
|
|
|
|
|
|
|
|
pub async fn init_electrs_container(
|
|
|
|
cli: &Cli,
|
|
|
|
volume: String,
|
|
|
|
bitcoind_container_name: String,
|
|
|
|
network: String,
|
|
|
|
) -> Result<Container<'_, Cli, electrs::Electrs>> {
|
|
|
|
let bitcoind_rpc_addr = format!(
|
|
|
|
"{}:{}",
|
|
|
|
bitcoind_container_name,
|
|
|
|
testutils::bitcoind::RPC_PORT
|
|
|
|
);
|
|
|
|
let image = electrs::Electrs::default()
|
|
|
|
.with_volume(volume)
|
|
|
|
.with_daemon_rpc_addr(bitcoind_rpc_addr)
|
|
|
|
.with_tag("latest");
|
|
|
|
|
|
|
|
let run_args = RunArgs::default().with_network(network);
|
|
|
|
|
|
|
|
let docker = cli.run_with_args(image, run_args);
|
|
|
|
|
|
|
|
Ok(docker)
|
|
|
|
}
|
|
|
|
|
|
|
|
async fn mine(bitcoind_client: Client, reward_address: bitcoin::Address) -> Result<()> {
|
|
|
|
loop {
|
|
|
|
tokio::time::sleep(Duration::from_secs(1)).await;
|
|
|
|
bitcoind_client
|
|
|
|
.generatetoaddress(1, reward_address.clone(), None)
|
|
|
|
.await?;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async fn init_bitcoind(node_url: Url, spendable_quantity: u32) -> Result<Client> {
|
|
|
|
let bitcoind_client = Client::new(node_url.clone());
|
|
|
|
|
|
|
|
bitcoind_client
|
2021-03-02 23:58:47 +00:00
|
|
|
.createwallet(BITCOIN_TEST_WALLET_NAME, None, None, None, None)
|
2021-02-01 23:39:34 +00:00
|
|
|
.await?;
|
|
|
|
|
|
|
|
let reward_address = bitcoind_client
|
2021-03-02 23:58:47 +00:00
|
|
|
.with_wallet(BITCOIN_TEST_WALLET_NAME)?
|
2021-02-01 23:39:34 +00:00
|
|
|
.getnewaddress(None, None)
|
|
|
|
.await?;
|
|
|
|
|
|
|
|
bitcoind_client
|
|
|
|
.generatetoaddress(101 + spendable_quantity, reward_address.clone(), None)
|
|
|
|
.await?;
|
|
|
|
let _ = tokio::spawn(mine(bitcoind_client.clone(), reward_address));
|
|
|
|
Ok(bitcoind_client)
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Send Bitcoin to the specified address, limited to the spendable bitcoin
|
|
|
|
/// quantity.
|
|
|
|
pub async fn mint(node_url: Url, address: bitcoin::Address, amount: bitcoin::Amount) -> Result<()> {
|
|
|
|
let bitcoind_client = Client::new(node_url.clone());
|
|
|
|
|
|
|
|
bitcoind_client
|
2021-03-02 23:58:47 +00:00
|
|
|
.send_to_address(BITCOIN_TEST_WALLET_NAME, address.clone(), amount)
|
2021-02-01 23:39:34 +00:00
|
|
|
.await?;
|
|
|
|
|
|
|
|
// Confirm the transaction
|
|
|
|
let reward_address = bitcoind_client
|
2021-03-02 23:58:47 +00:00
|
|
|
.with_wallet(BITCOIN_TEST_WALLET_NAME)?
|
2021-02-01 23:39:34 +00:00
|
|
|
.getnewaddress(None, None)
|
|
|
|
.await?;
|
|
|
|
bitcoind_client
|
|
|
|
.generatetoaddress(1, reward_address, None)
|
|
|
|
.await?;
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
async fn init_monero_container(
|
|
|
|
cli: &Cli,
|
|
|
|
) -> (
|
|
|
|
Monero,
|
|
|
|
Vec<Container<'_, Cli, monero_harness::image::Monero>>,
|
|
|
|
) {
|
2021-03-02 23:58:47 +00:00
|
|
|
let (monero, monerods) = Monero::new(&cli, vec![
|
|
|
|
MONERO_WALLET_NAME_ALICE.to_string(),
|
|
|
|
MONERO_WALLET_NAME_BOB.to_string(),
|
|
|
|
])
|
|
|
|
.await
|
|
|
|
.unwrap();
|
2020-12-14 10:48:42 +00:00
|
|
|
|
2021-02-01 23:39:34 +00:00
|
|
|
(monero, monerods)
|
2020-12-14 10:48:42 +00:00
|
|
|
}
|
|
|
|
|
2021-02-09 06:23:13 +00:00
|
|
|
#[allow(clippy::too_many_arguments)]
|
2021-01-27 02:33:32 +00:00
|
|
|
async fn init_test_wallets(
|
2020-12-14 10:48:42 +00:00
|
|
|
name: &str,
|
2021-02-01 23:39:34 +00:00
|
|
|
bitcoind_url: Url,
|
2020-12-10 03:59:09 +00:00
|
|
|
monero: &Monero,
|
2021-01-15 08:03:11 +00:00
|
|
|
starting_balances: StartingBalances,
|
2021-02-01 23:39:34 +00:00
|
|
|
datadir: &Path,
|
|
|
|
electrum_rpc_port: u16,
|
2021-02-09 06:23:13 +00:00
|
|
|
seed: Seed,
|
2021-03-17 03:55:42 +00:00
|
|
|
env_config: Config,
|
2020-12-14 10:48:42 +00:00
|
|
|
) -> (Arc<bitcoin::Wallet>, Arc<monero::Wallet>) {
|
2021-01-15 08:03:11 +00:00
|
|
|
monero
|
|
|
|
.init(vec![(name, starting_balances.xmr.as_piconero())])
|
|
|
|
.await
|
|
|
|
.unwrap();
|
2020-12-10 03:59:09 +00:00
|
|
|
|
2021-03-16 08:24:41 +00:00
|
|
|
let xmr_wallet = swap::monero::Wallet::connect(
|
2021-02-24 23:30:24 +00:00
|
|
|
monero.wallet(name).unwrap().client(),
|
2021-03-02 23:56:49 +00:00
|
|
|
name.to_string(),
|
2021-03-17 03:55:42 +00:00
|
|
|
env_config,
|
2021-03-16 08:24:41 +00:00
|
|
|
)
|
|
|
|
.await
|
|
|
|
.unwrap();
|
2020-12-10 03:59:09 +00:00
|
|
|
|
2021-02-01 23:39:34 +00:00
|
|
|
let electrum_rpc_url = {
|
|
|
|
let input = format!("tcp://@localhost:{}", electrum_rpc_port);
|
|
|
|
Url::parse(&input).unwrap()
|
|
|
|
};
|
|
|
|
|
|
|
|
let btc_wallet = swap::bitcoin::Wallet::new(
|
|
|
|
electrum_rpc_url,
|
|
|
|
datadir,
|
2021-03-17 03:55:42 +00:00
|
|
|
seed.derive_extended_private_key(env_config.bitcoin_network)
|
2021-03-02 06:10:29 +00:00
|
|
|
.expect("Could not create extended private key from seed"),
|
2021-03-17 03:55:42 +00:00
|
|
|
env_config,
|
2021-02-01 23:39:34 +00:00
|
|
|
)
|
|
|
|
.await
|
|
|
|
.expect("could not init btc wallet");
|
2020-12-10 03:59:09 +00:00
|
|
|
|
2021-01-15 08:03:11 +00:00
|
|
|
if starting_balances.btc != bitcoin::Amount::ZERO {
|
2021-02-01 23:39:34 +00:00
|
|
|
mint(
|
|
|
|
bitcoind_url,
|
|
|
|
btc_wallet.new_address().await.unwrap(),
|
|
|
|
starting_balances.btc,
|
|
|
|
)
|
|
|
|
.await
|
|
|
|
.expect("could not mint btc starting balance");
|
|
|
|
|
2021-02-22 00:36:14 +00:00
|
|
|
let mut interval = interval(Duration::from_secs(1u64));
|
|
|
|
let mut retries = 0u8;
|
|
|
|
let max_retries = 30u8;
|
|
|
|
loop {
|
|
|
|
retries += 1;
|
2021-03-04 06:07:02 +00:00
|
|
|
btc_wallet.sync().await.unwrap();
|
2021-02-22 00:36:14 +00:00
|
|
|
|
|
|
|
let btc_balance = btc_wallet.balance().await.unwrap();
|
|
|
|
|
|
|
|
if btc_balance == starting_balances.btc {
|
|
|
|
break;
|
|
|
|
} else if retries == max_retries {
|
|
|
|
panic!(
|
|
|
|
"Bitcoin wallet initialization failed, reached max retries upon balance sync"
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
interval.tick().await;
|
|
|
|
}
|
|
|
|
}
|
2021-02-01 23:39:34 +00:00
|
|
|
|
|
|
|
(Arc::new(btc_wallet), Arc::new(xmr_wallet))
|
2020-12-10 03:59:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// This is just to keep the containers alive
|
|
|
|
#[allow(dead_code)]
|
2021-01-18 01:57:27 +00:00
|
|
|
struct Containers<'a> {
|
2021-02-01 23:39:34 +00:00
|
|
|
bitcoind_url: Url,
|
|
|
|
bitcoind: Container<'a, Cli, bitcoind::Bitcoind>,
|
2021-01-18 01:57:27 +00:00
|
|
|
monerods: Vec<Container<'a, Cli, image::Monero>>,
|
2021-02-01 23:39:34 +00:00
|
|
|
electrs: Container<'a, Cli, electrs::Electrs>,
|
2020-12-10 03:59:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Utility function to initialize logging in the test environment.
|
|
|
|
/// Note that you have to keep the `_guard` in scope after calling in test:
|
|
|
|
///
|
|
|
|
/// ```rust
|
|
|
|
/// let _guard = init_tracing();
|
|
|
|
/// ```
|
2021-02-01 23:39:34 +00:00
|
|
|
pub fn init_tracing() -> DefaultGuard {
|
2020-12-10 03:59:09 +00:00
|
|
|
use tracing_subscriber::util::SubscriberInitExt as _;
|
|
|
|
tracing_subscriber::fmt()
|
2021-03-12 05:26:23 +00:00
|
|
|
.with_env_filter("warn,swap=debug,monero_harness=debug,monero_rpc=info,bitcoin_harness=info,testcontainers=info")
|
2020-12-10 03:59:09 +00:00
|
|
|
.set_default()
|
|
|
|
}
|
2021-01-21 08:37:52 +00:00
|
|
|
|
|
|
|
pub mod alice_run_until {
|
|
|
|
use swap::protocol::alice::AliceState;
|
|
|
|
|
|
|
|
pub fn is_xmr_locked(state: &AliceState) -> bool {
|
2021-02-03 05:20:59 +00:00
|
|
|
matches!(state, AliceState::XmrLocked { .. })
|
2021-01-21 08:37:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_encsig_learned(state: &AliceState) -> bool {
|
2021-02-03 05:20:59 +00:00
|
|
|
matches!(state, AliceState::EncSigLearned { .. })
|
2021-01-21 08:37:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub mod bob_run_until {
|
|
|
|
use swap::protocol::bob::BobState;
|
|
|
|
|
|
|
|
pub fn is_btc_locked(state: &BobState) -> bool {
|
|
|
|
matches!(state, BobState::BtcLocked(..))
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_lock_proof_received(state: &BobState) -> bool {
|
|
|
|
matches!(state, BobState::XmrLockProofReceived { .. })
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_xmr_locked(state: &BobState) -> bool {
|
|
|
|
matches!(state, BobState::XmrLocked(..))
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_encsig_sent(state: &BobState) -> bool {
|
|
|
|
matches!(state, BobState::EncSigSent(..))
|
|
|
|
}
|
|
|
|
}
|
2021-01-27 06:03:52 +00:00
|
|
|
|
|
|
|
pub struct SlowCancelConfig;
|
|
|
|
|
2021-03-17 03:55:42 +00:00
|
|
|
impl GetConfig for SlowCancelConfig {
|
|
|
|
fn get_config() -> Config {
|
|
|
|
Config {
|
2021-02-15 01:19:43 +00:00
|
|
|
bitcoin_cancel_timelock: CancelTimelock::new(180),
|
2021-03-17 03:55:42 +00:00
|
|
|
..env::Regtest::get_config()
|
2021-01-27 06:03:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct FastCancelConfig;
|
|
|
|
|
2021-03-17 03:55:42 +00:00
|
|
|
impl GetConfig for FastCancelConfig {
|
|
|
|
fn get_config() -> Config {
|
|
|
|
Config {
|
2021-02-15 01:19:43 +00:00
|
|
|
bitcoin_cancel_timelock: CancelTimelock::new(1),
|
2021-03-17 03:55:42 +00:00
|
|
|
..env::Regtest::get_config()
|
2021-01-27 06:03:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct FastPunishConfig;
|
|
|
|
|
2021-03-17 03:55:42 +00:00
|
|
|
impl GetConfig for FastPunishConfig {
|
|
|
|
fn get_config() -> Config {
|
|
|
|
Config {
|
2021-02-15 01:19:43 +00:00
|
|
|
bitcoin_cancel_timelock: CancelTimelock::new(1),
|
|
|
|
bitcoin_punish_timelock: PunishTimelock::new(1),
|
2021-03-17 03:55:42 +00:00
|
|
|
..env::Regtest::get_config()
|
2021-01-27 06:03:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|