mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-12-24 23:19:34 -05:00
Add CreateWallet trait to expose create_wallet
This commit is contained in:
parent
27bb9498d5
commit
62605a318a
@ -1,6 +1,6 @@
|
|||||||
use crate::rpc::{Request, Response};
|
use crate::rpc::{Request, Response};
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::{bail, Result};
|
||||||
use reqwest::Url;
|
use reqwest::Url;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
@ -140,6 +140,10 @@ impl Client {
|
|||||||
|
|
||||||
debug!("create wallet RPC response: {}", response);
|
debug!("create wallet RPC response: {}", response);
|
||||||
|
|
||||||
|
if response.contains("error") {
|
||||||
|
bail!("Failed to create wallet")
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,6 +207,11 @@ pub trait CreateWalletForOutput {
|
|||||||
) -> anyhow::Result<()>;
|
) -> anyhow::Result<()>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
pub trait CreateWallet {
|
||||||
|
async fn create_wallet(&self, file_name: &str) -> anyhow::Result<()>;
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(thiserror::Error, Debug, Clone, PartialEq)]
|
#[derive(thiserror::Error, Debug, Clone, PartialEq)]
|
||||||
#[error("Overflow, cannot convert {0} to u64")]
|
#[error("Overflow, cannot convert {0} to u64")]
|
||||||
pub struct OverflowError(pub String);
|
pub struct OverflowError(pub String);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::monero::{
|
use crate::monero::{
|
||||||
Amount, CreateWalletForOutput, InsufficientFunds, PrivateViewKey, PublicViewKey, Transfer,
|
Amount, CreateWallet, CreateWalletForOutput, InsufficientFunds, PrivateViewKey, PublicViewKey,
|
||||||
TransferProof, TxHash, WatchForTransfer,
|
Transfer, TransferProof, TxHash, WatchForTransfer,
|
||||||
};
|
};
|
||||||
use ::monero::{Address, Network, PrivateKey, PublicKey};
|
use ::monero::{Address, Network, PrivateKey, PublicKey};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
@ -94,6 +94,14 @@ impl CreateWalletForOutput for Wallet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
impl CreateWallet for Wallet {
|
||||||
|
async fn create_wallet(&self, file_name: &str) -> Result<()> {
|
||||||
|
self.inner.create_wallet(file_name).await?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: For retry, use `backoff::ExponentialBackoff` in production as opposed
|
// TODO: For retry, use `backoff::ExponentialBackoff` in production as opposed
|
||||||
// to `ConstantBackoff`.
|
// to `ConstantBackoff`.
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
|
Loading…
Reference in New Issue
Block a user