Skip to content

Commit

Permalink
LWK cache removal: remove dependency on hash tag (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
ok300 authored Apr 23, 2024
1 parent f138f6a commit 6f598b7
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions lib/ls-sdk-core/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand All @@ -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,
Expand Down Expand Up @@ -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)?;

Expand Down

0 comments on commit 6f598b7

Please sign in to comment.