mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-10-01 01:45:40 -04:00
Proper encapsulation of wallet boundaries through private fields
This commit is contained in:
parent
947bcb6192
commit
578d23d7fc
@ -23,9 +23,9 @@ use url::Url;
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Wallet {
|
pub struct Wallet {
|
||||||
pub inner: Mutex<wallet::Client>,
|
inner: Mutex<wallet::Client>,
|
||||||
pub network: Network,
|
network: Network,
|
||||||
pub default_wallet_name: String,
|
default_wallet_name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Wallet {
|
impl Wallet {
|
||||||
@ -37,6 +37,18 @@ impl Wallet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn new_with_client(
|
||||||
|
client: wallet::Client,
|
||||||
|
network: Network,
|
||||||
|
default_wallet_name: String,
|
||||||
|
) -> Self {
|
||||||
|
Self {
|
||||||
|
inner: Mutex::new(client),
|
||||||
|
network,
|
||||||
|
default_wallet_name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Get the balance of the primary account.
|
/// Get the balance of the primary account.
|
||||||
pub async fn get_balance(&self) -> Result<Amount> {
|
pub async fn get_balance(&self) -> Result<Amount> {
|
||||||
let amount = self.inner.lock().await.get_balance(0).await?;
|
let amount = self.inner.lock().await.get_balance(0).await?;
|
||||||
|
@ -27,11 +27,7 @@ use swap::{
|
|||||||
};
|
};
|
||||||
use tempfile::tempdir;
|
use tempfile::tempdir;
|
||||||
use testcontainers::{clients::Cli, Container, Docker, RunArgs};
|
use testcontainers::{clients::Cli, Container, Docker, RunArgs};
|
||||||
use tokio::{
|
use tokio::{sync::mpsc, task::JoinHandle, time::interval};
|
||||||
sync::{mpsc, Mutex},
|
|
||||||
task::JoinHandle,
|
|
||||||
time::interval,
|
|
||||||
};
|
|
||||||
use tracing::dispatcher::DefaultGuard;
|
use tracing::dispatcher::DefaultGuard;
|
||||||
use tracing_log::LogTracer;
|
use tracing_log::LogTracer;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
@ -589,11 +585,11 @@ async fn init_test_wallets(
|
|||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let xmr_wallet = swap::monero::Wallet {
|
let xmr_wallet = swap::monero::Wallet::new_with_client(
|
||||||
inner: Mutex::new(monero.wallet(name).unwrap().client()),
|
monero.wallet(name).unwrap().client(),
|
||||||
network: monero::Network::default(),
|
monero::Network::default(),
|
||||||
default_wallet_name: "irrelevant_for_tests".to_string(),
|
"irrelevant_for_tests".to_string(),
|
||||||
};
|
);
|
||||||
|
|
||||||
let electrum_rpc_url = {
|
let electrum_rpc_url = {
|
||||||
let input = format!("tcp://@localhost:{}", electrum_rpc_port);
|
let input = format!("tcp://@localhost:{}", electrum_rpc_port);
|
||||||
|
Loading…
Reference in New Issue
Block a user