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,8 +89,10 @@ async fn main() -> Result<()> {
alice_peer_id, alice_peer_id,
alice_addr, alice_addr,
}, },
monero_params: MoneroParams { monero_params:
MoneroParams {
receive_monero_address, receive_monero_address,
monero_daemon_host,
}, },
} => { } => {
if receive_monero_address.network != monero_network { if receive_monero_address.network != monero_network {
@ -102,7 +104,8 @@ async fn main() -> Result<()> {
} }
let bitcoin_wallet = init_bitcoin_wallet(bitcoin_network, &config, seed).await?; 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 bitcoin_wallet = Arc::new(bitcoin_wallet);
let (event_loop, mut event_loop_handle) = EventLoop::new( let (event_loop, mut event_loop_handle) = EventLoop::new(
&seed.derive_libp2p_identity(), &seed.derive_libp2p_identity(),
@ -170,8 +173,10 @@ async fn main() -> Result<()> {
alice_peer_id, alice_peer_id,
alice_addr, alice_addr,
}, },
monero_params: MoneroParams { monero_params:
MoneroParams {
receive_monero_address, receive_monero_address,
monero_daemon_host,
}, },
} => { } => {
if receive_monero_address.network != monero_network { if receive_monero_address.network != monero_network {
@ -179,7 +184,8 @@ async fn main() -> Result<()> {
} }
let bitcoin_wallet = init_bitcoin_wallet(bitcoin_network, &config, seed).await?; 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 bitcoin_wallet = Arc::new(bitcoin_wallet);
let (event_loop, event_loop_handle) = EventLoop::new( let (event_loop, event_loop_handle) = EventLoop::new(
@ -275,13 +281,14 @@ async fn init_bitcoin_wallet(
async fn init_monero_wallet( async fn init_monero_wallet(
monero_network: monero::Network, monero_network: monero::Network,
config: &Config, config: &Config,
monero_daemon_host: String,
) -> Result<(monero::Wallet, monero::WalletRpcProcess)> { ) -> Result<(monero::Wallet, monero::WalletRpcProcess)> {
const MONERO_BLOCKCHAIN_MONITORING_WALLET_NAME: &str = "swap-tool-blockchain-monitoring-wallet"; 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 = monero::WalletRpc::new(config.data.dir.join("monero")).await?;
let monero_wallet_rpc_process = monero_wallet_rpc let monero_wallet_rpc_process = monero_wallet_rpc
.run(monero_network, "monero-stagenet.exan.tech") .run(monero_network, monero_daemon_host.as_str())
.await?; .await?;
let monero_wallet = monero::Wallet::new( 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_MULTIADDR: &str = "/dns4/xmr-btc-asb.coblox.tech/tcp/9876";
pub const DEFAULT_ALICE_PEER_ID: &str = "12D3KooWCdMKjesXMJz1SiZ7HgotrxuqhQJbP5sgBm2BwP1cqThi"; 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)] #[derive(structopt::StructOpt, Debug)]
pub struct Arguments { pub struct Arguments {
#[structopt( #[structopt(
@ -77,6 +80,12 @@ pub struct ConnectParams {
pub struct MoneroParams { pub struct MoneroParams {
#[structopt(long = "receive-address", parse(try_from_str = parse_monero_address))] #[structopt(long = "receive-address", parse(try_from_str = parse_monero_address))]
pub receive_monero_address: 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> { fn parse_monero_address(s: &str) -> Result<monero::Address> {