Make monero daemon host configurable

This commit is contained in:
Daniel Karzel 2021-03-05 16:10:45 +11:00
parent f091402c7a
commit f8b61e2e0e
2 changed files with 25 additions and 9 deletions

View File

@ -89,9 +89,11 @@ async fn main() -> Result<()> {
alice_peer_id,
alice_addr,
},
monero_params: MoneroParams {
receive_monero_address,
},
monero_params:
MoneroParams {
receive_monero_address,
monero_daemon_host,
},
} => {
if receive_monero_address.network != monero_network {
bail!(
@ -102,7 +104,8 @@ async fn main() -> Result<()> {
}
let bitcoin_wallet = init_bitcoin_wallet(bitcoin_network, &config, seed).await?;
let (monero_wallet, _process) = init_monero_wallet(monero_network, &config).await?;
let (monero_wallet, _process) =
init_monero_wallet(monero_network, &config, monero_daemon_host).await?;
let bitcoin_wallet = Arc::new(bitcoin_wallet);
let (event_loop, mut event_loop_handle) = EventLoop::new(
&seed.derive_libp2p_identity(),
@ -170,16 +173,19 @@ async fn main() -> Result<()> {
alice_peer_id,
alice_addr,
},
monero_params: MoneroParams {
receive_monero_address,
},
monero_params:
MoneroParams {
receive_monero_address,
monero_daemon_host,
},
} => {
if receive_monero_address.network != monero_network {
bail!("The given monero address is on network {:?}, expected address of network {:?}.", receive_monero_address.network, monero_network)
}
let bitcoin_wallet = init_bitcoin_wallet(bitcoin_network, &config, seed).await?;
let (monero_wallet, _process) = init_monero_wallet(monero_network, &config).await?;
let (monero_wallet, _process) =
init_monero_wallet(monero_network, &config, monero_daemon_host).await?;
let bitcoin_wallet = Arc::new(bitcoin_wallet);
let (event_loop, event_loop_handle) = EventLoop::new(
@ -275,13 +281,14 @@ async fn init_bitcoin_wallet(
async fn init_monero_wallet(
monero_network: monero::Network,
config: &Config,
monero_daemon_host: String,
) -> Result<(monero::Wallet, monero::WalletRpcProcess)> {
const MONERO_BLOCKCHAIN_MONITORING_WALLET_NAME: &str = "swap-tool-blockchain-monitoring-wallet";
let monero_wallet_rpc = monero::WalletRpc::new(config.data.dir.join("monero")).await?;
let monero_wallet_rpc_process = monero_wallet_rpc
.run(monero_network, "monero-stagenet.exan.tech")
.run(monero_network, monero_daemon_host.as_str())
.await?;
let monero_wallet = monero::Wallet::new(

View File

@ -8,6 +8,9 @@ use uuid::Uuid;
pub const DEFAULT_ALICE_MULTIADDR: &str = "/dns4/xmr-btc-asb.coblox.tech/tcp/9876";
pub const DEFAULT_ALICE_PEER_ID: &str = "12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi";
// Port is assumed to be stagenet standard port 38081
pub const DEFAULT_STAGENET_MONERO_DAEMON_HOST: &str = "monero-stagenet.exan.tech";
#[derive(structopt::StructOpt, Debug)]
pub struct Arguments {
#[structopt(
@ -77,6 +80,12 @@ pub struct ConnectParams {
pub struct MoneroParams {
#[structopt(long = "receive-address", parse(try_from_str = parse_monero_address))]
pub receive_monero_address: monero::Address,
#[structopt(
long = "monero-daemon-host",
default_value = DEFAULT_STAGENET_MONERO_DAEMON_HOST
)]
pub monero_daemon_host: String,
}
fn parse_monero_address(s: &str) -> Result<monero::Address> {