mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-08-18 03:00:53 -04:00
Use language agnostic heuristic to check if monero_wallet_rpc is ready
Our strategy of searching for a english string to determine if monero_wallet_rpc is ready is not compatible with languages other than english. Instead we assume the monero rpc is ready if it has stopped writing to stdout. We make a json rpc request to confirm this. A better solution would have been to configure the monero_wallet_rpc to always output in english but there is not command line argument to configure the language. Closes #353.
This commit is contained in:
parent
2c3c4936c6
commit
bc902ea63a
3 changed files with 39 additions and 4 deletions
|
@ -357,6 +357,24 @@ impl Client {
|
|||
let r = serde_json::from_str::<Response<SweepAll>>(&response)?;
|
||||
Ok(r.result)
|
||||
}
|
||||
|
||||
pub async fn get_version(&self) -> Result<Version> {
|
||||
let request = Request::new("get_version", "");
|
||||
|
||||
let response = self
|
||||
.inner
|
||||
.post(self.url.clone())
|
||||
.json(&request)
|
||||
.send()
|
||||
.await?
|
||||
.text()
|
||||
.await?;
|
||||
|
||||
debug!("get_version RPC response: {}", response);
|
||||
|
||||
let r = serde_json::from_str::<Response<Version>>(&response)?;
|
||||
Ok(r.result)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug, Clone)]
|
||||
|
@ -512,6 +530,11 @@ pub struct SweepAll {
|
|||
weight_list: Vec<u32>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Deserialize)]
|
||||
pub struct Version {
|
||||
version: u32,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue