SilentPaymentWallet::save() takes an already unlocked wallet as argument
This commit is contained in:
parent
0be7a65599
commit
b5258a119f
@ -147,9 +147,9 @@ impl SilentPaymentWallet {
|
||||
self.sp_wallet.lock_anyhow()
|
||||
}
|
||||
|
||||
pub fn save(&self) -> Result<()> {
|
||||
let wallet = self.sp_wallet.lock_anyhow()?.clone();
|
||||
let value = serde_json::from_str(&serde_json::to_string(&wallet)?)?;
|
||||
// This is terrible design
|
||||
pub fn save(&self, unlocked_wallet: MutexGuard<SpWallet>) -> Result<()> {
|
||||
let value = serde_json::from_str(&serde_json::to_string(&unlocked_wallet.clone())?)?;
|
||||
self.storage.lock_anyhow()?.save(&value)
|
||||
}
|
||||
}
|
||||
@ -467,7 +467,7 @@ async fn main() -> Result<()> {
|
||||
})
|
||||
.expect("Failed to initialize WALLET");
|
||||
|
||||
WALLET.get().unwrap().save().unwrap();
|
||||
WALLET.get().unwrap().save(WALLET.get().unwrap().get_wallet()?).unwrap();
|
||||
|
||||
CACHEDPROCESSES
|
||||
.set(Mutex::new(cached_processes))
|
||||
|
@ -93,7 +93,7 @@ pub fn check_transaction_alone(tx: &Transaction, tweak_data: &PublicKey) -> Resu
|
||||
};
|
||||
|
||||
if updates.len() > 0 {
|
||||
sp_wallet.save()?;
|
||||
WALLET.get().unwrap().save(wallet)?;
|
||||
}
|
||||
|
||||
Ok(updates)
|
||||
@ -339,7 +339,7 @@ pub fn scan_blocks(mut n_blocks_to_scan: u32, electrum_url: &str) -> anyhow::Res
|
||||
.get_wallet()?
|
||||
.get_mut_outputs()
|
||||
.update_last_scan(end);
|
||||
sp_wallet.save()?;
|
||||
WALLET.get().unwrap().save(wallet)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user