mirror of
https://github.com/aljazceru/breez-sdk-liquid.git
synced 2025-12-29 20:04:30 +01:00
LWK cache removal: remove dependency on hash tag (#102)
This commit is contained in:
@@ -24,10 +24,8 @@ use lwk_common::{singlesig_desc, Signer, Singlesig};
|
||||
use lwk_signer::{AnySigner, SwSigner};
|
||||
use lwk_wollet::{
|
||||
elements::{Address, Transaction},
|
||||
full_scan_with_electrum_client,
|
||||
hashes::{sha256t_hash_newtype, Hash},
|
||||
BlockchainBackend, ElectrumClient, ElectrumUrl, ElementsNetwork, FsPersister,
|
||||
Wollet as LwkWollet, WolletDescriptor,
|
||||
full_scan_with_electrum_client, BlockchainBackend, ElectrumClient, ElectrumUrl,
|
||||
ElementsNetwork, FsPersister, Wollet as LwkWollet, WolletDescriptor,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
@@ -37,13 +35,6 @@ use crate::{
|
||||
DEFAULT_DATA_DIR,
|
||||
};
|
||||
|
||||
sha256t_hash_newtype! {
|
||||
struct DirectoryIdTag = hash_str("LWK-FS-Directory-Id/1.0");
|
||||
|
||||
#[hash_newtype(forward)]
|
||||
struct DirectoryIdHash(_);
|
||||
}
|
||||
|
||||
pub struct Wallet {
|
||||
signer: SwSigner,
|
||||
electrum_url: ElectrumUrl,
|
||||
@@ -579,14 +570,12 @@ impl Wallet {
|
||||
Ok(txid)
|
||||
}
|
||||
|
||||
/// Empties all Liquid Wallet caches for this network type.
|
||||
pub fn empty_wallet_cache(&self) -> Result<()> {
|
||||
let mut path = PathBuf::from(self.data_dir_path.clone());
|
||||
path.push(Into::<ElementsNetwork>::into(self.network).as_str());
|
||||
path.push("enc_cache");
|
||||
|
||||
let descriptor = Wallet::get_descriptor(&self.get_signer(), self.network)?;
|
||||
path.push(DirectoryIdHash::hash(descriptor.to_string().as_bytes()).to_string());
|
||||
|
||||
fs::remove_dir_all(&path)?;
|
||||
fs::create_dir_all(path)?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user