This commit is contained in:
Dave Hrycyszyn
2024-06-25 15:23:52 +01:00
parent 70d1b1eed9
commit c7095ced7b

View File

@@ -95,20 +95,21 @@ impl EsploraWallet {
let now = std::time::UNIX_EPOCH.elapsed().unwrap().as_secs();
let _ = update.graph_update.update_last_seen_unconfirmed(now);
self.wallet.apply_update(update)?;
if let Some(changeset) = self.wallet.take_staged() {
self.db.write(&changeset)?;
}
println!();
self.persist_local()?;
println!("Sync complete for {}", self.name);
Ok(())
}
fn persist_local(&mut self) -> Result<(), anyhow::Error> {
Ok(if let Some(changeset) = self.wallet.take_staged() {
self.db.write(&changeset)?;
})
}
/// Gets the next unused address from the wallet.
pub(crate) fn next_unused_address(&mut self) -> Result<AddressInfo, anyhow::Error> {
let address = self.wallet.next_unused_address(KeychainKind::External);
if let Some(changeset) = self.wallet.take_staged() {
self.db.write(&changeset)?;
}
self.persist_local()?;
println!(
"Generated address: https://mutinynet.com/address/{}",
address