diff --git a/swap/src/cli.rs b/swap/src/cli.rs index b2b238b5..aa247541 100644 --- a/swap/src/cli.rs +++ b/swap/src/cli.rs @@ -18,7 +18,10 @@ pub enum Options { #[structopt(default_value = "http://127.0.0.1:8332", long = "bitcoind")] bitcoind_url: Url, - #[structopt(default_value = "http://127.0.0.1:18083/json_rpc", long = "monero_wallet_rpc")] + #[structopt( + default_value = "http://127.0.0.1:18083/json_rpc", + long = "monero_wallet_rpc" + )] monero_wallet_rpc_url: Url, #[structopt( @@ -43,7 +46,10 @@ pub enum Options { #[structopt(default_value = "http://127.0.0.1:8332", long = "bitcoind")] bitcoind_url: Url, - #[structopt(default_value = "http://127.0.0.1:18083/json_rpc", long = "monero_wallet_rpc")] + #[structopt( + default_value = "http://127.0.0.1:18083/json_rpc", + long = "monero_wallet_rpc" + )] monero_wallet_rpc_url: Url, #[structopt( @@ -63,7 +69,16 @@ pub enum Options { #[structopt(default_value = "http://127.0.0.1:8332", long = "bitcoind")] bitcoind_url: Url, - #[structopt(default_value = "http://127.0.0.1:18083/json_rpc", long = "monerod")] - monerod_url: Url, + #[structopt( + default_value = "http://127.0.0.1:18083/json_rpc", + long = "monero_wallet_rpc" + )] + monero_wallet_rpc_url: Url, + + #[structopt( + default_value = "http://127.0.0.1:18084", + long = "monero_watch_only_wallet_rpc" + )] + monero_watch_only_wallet_rpc_url: Url, }, } diff --git a/swap/src/main.rs b/swap/src/main.rs index a3ab68ed..8512afcb 100644 --- a/swap/src/main.rs +++ b/swap/src/main.rs @@ -156,13 +156,15 @@ async fn main() -> Result<()> { Options::Recover { swap_id, bitcoind_url, - monerod_url, + monero_wallet_rpc_url, + monero_watch_only_wallet_rpc_url, } => { let state = db.get_state(swap_id)?; let bitcoin_wallet = bitcoin::Wallet::new("bob", bitcoind_url) .await .expect("failed to create bitcoin wallet"); - let monero_wallet = monero::Wallet::new(monerod_url); + let monero_wallet = + monero::Facade::new(monero_wallet_rpc_url, monero_watch_only_wallet_rpc_url); recover(bitcoin_wallet, monero_wallet, state).await?; } diff --git a/swap/src/monero.rs b/swap/src/monero.rs index f757df0c..7d0129f7 100644 --- a/swap/src/monero.rs +++ b/swap/src/monero.rs @@ -2,7 +2,7 @@ use anyhow::Result; use async_trait::async_trait; use backoff::{backoff::Constant as ConstantBackoff, future::FutureOperation as _}; use futures::TryFutureExt; -use monero::{Address, Network, PrivateKey}; +use monero::{Address, Network}; use monero_harness::rpc::wallet; use std::time::Duration; use url::Url; diff --git a/swap/src/recover.rs b/swap/src/recover.rs index b71b31fd..9934dd51 100644 --- a/swap/src/recover.rs +++ b/swap/src/recover.rs @@ -29,8 +29,8 @@ use xmr_btc::bitcoin::{ }; pub async fn recover( - bitcoin_wallet: bitcoin::Wallet, - monero_wallet: monero::Wallet, + bitcoin_wallet: crate::bitcoin::Wallet, + monero_wallet: crate::monero::Facade, state: Swap, ) -> Result<()> { match state { @@ -40,8 +40,8 @@ pub async fn recover( } pub async fn alice_recover( - bitcoin_wallet: bitcoin::Wallet, - monero_wallet: monero::Wallet, + bitcoin_wallet: crate::bitcoin::Wallet, + monero_wallet: crate::monero::Facade, state: Alice, ) -> Result<()> { match state { @@ -368,7 +368,7 @@ pub async fn alice_recover( pub async fn bob_recover( bitcoin_wallet: crate::bitcoin::Wallet, - monero_wallet: crate::monero::Wallet, + monero_wallet: crate::monero::Facade, state: Bob, ) -> Result<()> { match state { diff --git a/swap/tests/e2e.rs b/swap/tests/e2e.rs index e8aa507a..34bab971 100644 --- a/swap/tests/e2e.rs +++ b/swap/tests/e2e.rs @@ -74,22 +74,26 @@ async fn swap() { let alice_behaviour = alice::Alice::default(); let alice_transport = build(alice_behaviour.identity()).unwrap(); -let db = Database::open(std::path::Path::new("../.swap-db/")).unwrap(); let alice_swap = alice::swap( + let db = Database::open(std::path::Path::new("../.swap-db/")).unwrap(); + let alice_swap = alice::swap( alice_btc_wallet.clone(), - alice_xmr_wallet.clone(),db, + alice_xmr_wallet.clone(), + db, alice_multiaddr.clone(), alice_transport, alice_behaviour, ); let db_dir = tempdir().unwrap(); - let db = Database::open(db_dir.path()).unwrap();let (cmd_tx, mut _cmd_rx) = mpsc::channel(1); + let db = Database::open(db_dir.path()).unwrap(); + let (cmd_tx, mut _cmd_rx) = mpsc::channel(1); let (mut rsp_tx, rsp_rx) = mpsc::channel(1); let bob_behaviour = bob::Bob::default(); let bob_transport = build(bob_behaviour.identity()).unwrap(); let bob_swap = bob::swap( bob_btc_wallet.clone(), - bob_xmr_wallet.clone(),db, + bob_xmr_wallet.clone(), + db, btc.as_sat(), alice_multiaddr, cmd_tx,