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`.
This commit is contained in:
Daniel Karzel 2021-05-11 12:37:13 +10:00
parent 343badbb4b
commit 1cdc23de32
No known key found for this signature in database
GPG Key ID: 30C3FC2E438ADB6E
4 changed files with 16 additions and 15 deletions

View File

@ -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

View File

@ -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(

View File

@ -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: <host>:<port>",
default_value = DEFAULT_STAGENET_MONERO_DAEMON_ADDRESS
)]
pub monero_daemon_host: String,
pub monero_daemon_address: String,
}
#[derive(structopt::StructOpt, Debug)]

View File

@ -115,7 +115,7 @@ impl WalletRpc {
Ok(monero_wallet_rpc)
}
pub async fn run(&self, network: Network, daemon_host: &str) -> Result<WalletRpcProcess> {
pub async fn run(&self, network: Network, daemon_address: &str) -> Result<WalletRpcProcess> {
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")