mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-08-06 13:34:38 -04:00
Proper encapsulation of wallet boundaries through private fields
This commit is contained in:
parent
947bcb6192
commit
578d23d7fc
2 changed files with 21 additions and 13 deletions
|
@ -23,9 +23,9 @@ use url::Url;
|
|||
|
||||
#[derive(Debug)]
|
||||
pub struct Wallet {
|
||||
pub inner: Mutex<wallet::Client>,
|
||||
pub network: Network,
|
||||
pub default_wallet_name: String,
|
||||
inner: Mutex<wallet::Client>,
|
||||
network: Network,
|
||||
default_wallet_name: String,
|
||||
}
|
||||
|
||||
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.
|
||||
pub async fn get_balance(&self) -> Result<Amount> {
|
||||
let amount = self.inner.lock().await.get_balance(0).await?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue