From 1cdc23de3234e315d568918ba1feea871a6fefdb Mon Sep 17 00:00:00 2001 From: Daniel Karzel Date: Tue, 11 May 2021 12:37:13 +1000 Subject: [PATCH] Explicitly specify `monero-wallet-rpc` deamon port In order to allow people to plug into public nodes / be more flexible with their own setup we now enforce specifying the monero daemon port to be used by the `monero-wallet-rpc`. --- CHANGELOG.md | 2 ++ swap/src/bin/swap.rs | 12 ++++++------ swap/src/cli/command.rs | 11 +++++------ swap/src/monero/wallet_rpc.rs | 6 +++--- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5914aabe..44f23bb0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 1. Balance of ASB too low 2. Buy amount sent by CLI exceeds maximum buy amount accepted by ASB 3. ASB is running in resume-only mode and does not accept incoming swap requests +- An issue where the monero daemon port used by the `monero-wallet-rpc` could not be specified. + The CLI parameter `--monero-daemon-host` was changed to `--monero-daemon-address` where host and port have to be specified. ### Changed diff --git a/swap/src/bin/swap.rs b/swap/src/bin/swap.rs index 7b5596fe..1db7bac0 100644 --- a/swap/src/bin/swap.rs +++ b/swap/src/bin/swap.rs @@ -53,7 +53,7 @@ async fn main() -> Result<()> { monero: Monero { receive_monero_address, - monero_daemon_host, + monero_daemon_address, }, tor: Tor { tor_socks5_port }, } => { @@ -84,7 +84,7 @@ async fn main() -> Result<()> { ) .await?; let (monero_wallet, _process) = - init_monero_wallet(data_dir, monero_daemon_host, env_config).await?; + init_monero_wallet(data_dir, monero_daemon_address, env_config).await?; let bitcoin_wallet = Arc::new(bitcoin_wallet); let mut swarm = swarm::bob(&seed, seller_peer_id, tor_socks5_port).await?; @@ -160,7 +160,7 @@ async fn main() -> Result<()> { monero: Monero { receive_monero_address, - monero_daemon_host, + monero_daemon_address, }, tor: Tor { tor_socks5_port }, } => { @@ -185,7 +185,7 @@ async fn main() -> Result<()> { ) .await?; let (monero_wallet, _process) = - init_monero_wallet(data_dir, monero_daemon_host, env_config).await?; + init_monero_wallet(data_dir, monero_daemon_address, env_config).await?; let bitcoin_wallet = Arc::new(bitcoin_wallet); let seller_peer_id = db.get_peer_id(swap_id)?; @@ -315,7 +315,7 @@ async fn init_bitcoin_wallet( async fn init_monero_wallet( data_dir: PathBuf, - monero_daemon_host: String, + monero_daemon_address: String, env_config: Config, ) -> Result<(monero::Wallet, monero::WalletRpcProcess)> { let network = env_config.monero_network; @@ -325,7 +325,7 @@ async fn init_monero_wallet( let monero_wallet_rpc = monero::WalletRpc::new(data_dir.join("monero")).await?; let monero_wallet_rpc_process = monero_wallet_rpc - .run(network, monero_daemon_host.as_str()) + .run(network, monero_daemon_address.as_str()) .await?; let monero_wallet = monero::Wallet::open_or_create( diff --git a/swap/src/cli/command.rs b/swap/src/cli/command.rs index a2454cbc..6ceddcf4 100644 --- a/swap/src/cli/command.rs +++ b/swap/src/cli/command.rs @@ -7,8 +7,7 @@ use std::str::FromStr; use url::Url; use uuid::Uuid; -// Port is assumed to be stagenet standard port 38081 -pub const DEFAULT_STAGENET_MONERO_DAEMON_HOST: &str = "monero-stagenet.exan.tech"; +pub const DEFAULT_STAGENET_MONERO_DAEMON_ADDRESS: &str = "monero-stagenet.exan.tech:38081"; const DEFAULT_ELECTRUM_RPC_URL: &str = "ssl://electrum.blockstream.info:60002"; const DEFAULT_BITCOIN_CONFIRMATION_TARGET: &str = "3"; @@ -103,11 +102,11 @@ pub struct Monero { pub receive_monero_address: monero::Address, #[structopt( - long = "monero-daemon-host", - help = "Specify to connect to a monero daemon of your choice", - default_value = DEFAULT_STAGENET_MONERO_DAEMON_HOST + long = "monero-daemon-address", + help = "Specify to connect to a monero daemon of your choice: :", + default_value = DEFAULT_STAGENET_MONERO_DAEMON_ADDRESS )] - pub monero_daemon_host: String, + pub monero_daemon_address: String, } #[derive(structopt::StructOpt, Debug)] diff --git a/swap/src/monero/wallet_rpc.rs b/swap/src/monero/wallet_rpc.rs index f84a943f..24495530 100644 --- a/swap/src/monero/wallet_rpc.rs +++ b/swap/src/monero/wallet_rpc.rs @@ -115,7 +115,7 @@ impl WalletRpc { Ok(monero_wallet_rpc) } - pub async fn run(&self, network: Network, daemon_host: &str) -> Result { + pub async fn run(&self, network: Network, daemon_address: &str) -> Result { let port = tokio::net::TcpListener::bind("127.0.0.1:0") .await? .local_addr()? @@ -135,8 +135,8 @@ impl WalletRpc { Network::Stagenet => "--stagenet", Network::Testnet => "--testnet", }) - .arg("--daemon-host") - .arg(daemon_host) + .arg("--daemon-address") + .arg(daemon_address) .arg("--rpc-bind-port") .arg(format!("{}", port)) .arg("--disable-rpc-login")