mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-12-23 14:39:37 -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 anyhow::Result;
|
||||
use anyhow::{bail, Result};
|
||||
use reqwest::Url;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tracing::debug;
|
||||
@ -140,6 +140,10 @@ impl Client {
|
||||
|
||||
debug!("create wallet RPC response: {}", response);
|
||||
|
||||
if response.contains("error") {
|
||||
bail!("Failed to create wallet")
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -207,6 +207,11 @@ pub trait CreateWalletForOutput {
|
||||
) -> anyhow::Result<()>;
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
pub trait CreateWallet {
|
||||
async fn create_wallet(&self, file_name: &str) -> anyhow::Result<()>;
|
||||
}
|
||||
|
||||
#[derive(thiserror::Error, Debug, Clone, PartialEq)]
|
||||
#[error("Overflow, cannot convert {0} to u64")]
|
||||
pub struct OverflowError(pub String);
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::monero::{
|
||||
Amount, CreateWalletForOutput, InsufficientFunds, PrivateViewKey, PublicViewKey, Transfer,
|
||||
TransferProof, TxHash, WatchForTransfer,
|
||||
Amount, CreateWallet, CreateWalletForOutput, InsufficientFunds, PrivateViewKey, PublicViewKey,
|
||||
Transfer, TransferProof, TxHash, WatchForTransfer,
|
||||
};
|
||||
use ::monero::{Address, Network, PrivateKey, PublicKey};
|
||||
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
|
||||
// to `ConstantBackoff`.
|
||||
#[async_trait]
|
||||
|
Loading…
Reference in New Issue
Block a user