From a3e85526c6bc0484d18c4bfd67309b908cf9c0bc Mon Sep 17 00:00:00 2001 From: rishflab Date: Thu, 25 Mar 2021 19:51:53 +1100 Subject: [PATCH] Specify LANG env variable for monero wallet rpc for unix systems By specifying the language we can look for a specific string to check if monero wallet rpc is ready --- swap/src/monero/wallet_rpc.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/swap/src/monero/wallet_rpc.rs b/swap/src/monero/wallet_rpc.rs index fdb367cd..96138098 100644 --- a/swap/src/monero/wallet_rpc.rs +++ b/swap/src/monero/wallet_rpc.rs @@ -8,7 +8,6 @@ use reqwest::Url; use std::io::ErrorKind; use std::path::{Path, PathBuf}; use std::process::Stdio; -use std::time::Duration; use tokio::fs::{remove_file, OpenOptions}; use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader}; use tokio::process::{Child, Command}; @@ -125,6 +124,7 @@ impl WalletRpc { tracing::debug!("Starting monero-wallet-rpc on port {}", port); let mut child = Command::new(self.exec_path()) + .env("LANG", "en_AU.UTF-8") .stdout(Stdio::piped()) .kill_on_drop(true) .arg(match network { @@ -148,9 +148,18 @@ impl WalletRpc { let mut reader = BufReader::new(stdout).lines(); + #[cfg(not(target_os = "windows"))] + while let Some(line) = reader.next_line().await? { + if line.contains("Starting wallet RPC server") { + break; + } + } + // If we do not hear from the monero_wallet_rpc process for 3 seconds we assume // it is is ready - while let Ok(line) = tokio::time::timeout(Duration::from_secs(3), reader.next_line()).await + #[cfg(target_os = "windows")] + while let Ok(line) = + tokio::time::timeout(std::time::Duration::from_secs(3), reader.next_line()).await { line?; }