diff --git a/ci/pin-msrv.sh b/ci/pin-msrv.sh index 61fc4878..72658e55 100755 --- a/ci/pin-msrv.sh +++ b/ci/pin-msrv.sh @@ -10,13 +10,4 @@ set -euo pipefail # cargo clean # rustup override set 1.63.0 -cargo update -p home --precise "0.5.5" -cargo update -p url --precise "2.5.0" -cargo update -p tokio --precise "1.38.1" -cargo update -p tokio-util --precise "0.7.11" -cargo update -p indexmap --precise "2.5.0" -cargo update -p security-framework-sys --precise "2.11.1" -cargo update -p ring --precise "0.17.12" cargo update -p once_cell --precise "1.20.3" -cargo update -p minreq --precise "2.13.2" -cargo update -p native-tls --precise "0.2.13" \ No newline at end of file diff --git a/examples/example_wallet_electrum/Cargo.toml b/examples/example_wallet_electrum/Cargo.toml index 9e0e4605..6f467029 100644 --- a/examples/example_wallet_electrum/Cargo.toml +++ b/examples/example_wallet_electrum/Cargo.toml @@ -5,5 +5,5 @@ edition = "2021" [dependencies] bdk_wallet = { path = "../../wallet", features = ["file_store"] } -bdk_electrum = { version = "0.21" } +bdk_electrum = { version = "0.22.0" } anyhow = "1" diff --git a/examples/example_wallet_electrum/src/main.rs b/examples/example_wallet_electrum/src/main.rs index 5942714e..91ef5636 100644 --- a/examples/example_wallet_electrum/src/main.rs +++ b/examples/example_wallet_electrum/src/main.rs @@ -22,7 +22,7 @@ const ELECTRUM_URL: &str = "ssl://electrum.blockstream.info:60002"; fn main() -> Result<(), anyhow::Error> { let db_path = "bdk-electrum-example.db"; - let mut db = Store::::open_or_create_new(DB_MAGIC.as_bytes(), db_path)?; + let (mut db, _) = Store::::load_or_create(DB_MAGIC.as_bytes(), db_path)?; let wallet_opt = Wallet::load() .descriptor(KeychainKind::External, Some(EXTERNAL_DESC)) diff --git a/examples/example_wallet_esplora_async/Cargo.toml b/examples/example_wallet_esplora_async/Cargo.toml index 4d15e323..fbcdad23 100644 --- a/examples/example_wallet_esplora_async/Cargo.toml +++ b/examples/example_wallet_esplora_async/Cargo.toml @@ -7,6 +7,6 @@ edition = "2021" [dependencies] bdk_wallet = { path = "../../wallet", features = ["rusqlite"] } -bdk_esplora = { version = "0.20", features = ["async-https", "tokio"] } +bdk_esplora = { version = "0.21.0", features = ["async-https", "tokio"] } tokio = { version = "1.38.1", features = ["rt", "rt-multi-thread", "macros"] } anyhow = "1" diff --git a/examples/example_wallet_esplora_blocking/Cargo.toml b/examples/example_wallet_esplora_blocking/Cargo.toml index b8bf20c4..8ba1cf5b 100644 --- a/examples/example_wallet_esplora_blocking/Cargo.toml +++ b/examples/example_wallet_esplora_blocking/Cargo.toml @@ -8,5 +8,5 @@ publish = false [dependencies] bdk_wallet = { path = "../../wallet", features = ["file_store"] } -bdk_esplora = { version = "0.20", features = ["blocking"] } +bdk_esplora = { version = "0.21.0", features = ["blocking"] } anyhow = "1" diff --git a/examples/example_wallet_esplora_blocking/src/main.rs b/examples/example_wallet_esplora_blocking/src/main.rs index 7966f19f..735f2a78 100644 --- a/examples/example_wallet_esplora_blocking/src/main.rs +++ b/examples/example_wallet_esplora_blocking/src/main.rs @@ -19,7 +19,7 @@ const INTERNAL_DESC: &str = "wpkh(tprv8ZgxMBicQKsPdy6LMhUtFHAgpocR8GC6QmwMSFpZs7 const ESPLORA_URL: &str = "http://signet.bitcoindevkit.net"; fn main() -> Result<(), anyhow::Error> { - let mut db = Store::::open_or_create_new(DB_MAGIC.as_bytes(), DB_PATH)?; + let (mut db, _) = Store::::load_or_create(DB_MAGIC.as_bytes(), DB_PATH)?; let wallet_opt = Wallet::load() .descriptor(KeychainKind::External, Some(EXTERNAL_DESC)) diff --git a/examples/example_wallet_rpc/Cargo.toml b/examples/example_wallet_rpc/Cargo.toml index 011080fc..ef7a7dd3 100644 --- a/examples/example_wallet_rpc/Cargo.toml +++ b/examples/example_wallet_rpc/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" [dependencies] bdk_wallet = { path = "../../wallet", features = ["file_store"] } -bdk_bitcoind_rpc = { version = "0.18" } +bdk_bitcoind_rpc = { version = "0.19.0" } anyhow = "1" clap = { version = "4.5.17", features = ["derive", "env"] } diff --git a/examples/example_wallet_rpc/src/main.rs b/examples/example_wallet_rpc/src/main.rs index b8046927..5526e666 100644 --- a/examples/example_wallet_rpc/src/main.rs +++ b/examples/example_wallet_rpc/src/main.rs @@ -1,14 +1,19 @@ use bdk_bitcoind_rpc::{ bitcoincore_rpc::{Auth, Client, RpcApi}, - Emitter, + Emitter, MempoolEvent, }; use bdk_wallet::{ - bitcoin::{Block, Network, Transaction}, + bitcoin::{Block, Network}, file_store::Store, KeychainKind, Wallet, }; use clap::{self, Parser}; -use std::{path::PathBuf, sync::mpsc::sync_channel, thread::spawn, time::Instant}; +use std::{ + path::PathBuf, + sync::{mpsc::sync_channel, Arc}, + thread::spawn, + time::Instant, +}; const DB_MAGIC: &str = "bdk-rpc-wallet-example"; @@ -73,21 +78,21 @@ impl Args { enum Emission { SigTerm, Block(bdk_bitcoind_rpc::BlockEvent), - Mempool(Vec<(Transaction, u64)>), + Mempool(MempoolEvent), } fn main() -> anyhow::Result<()> { let args = Args::parse(); - let rpc_client = args.client()?; + let rpc_client = Arc::new(args.client()?); println!( "Connected to Bitcoin Core RPC at {:?}", rpc_client.get_blockchain_info().unwrap() ); let start_load_wallet = Instant::now(); - let mut db = - Store::::open_or_create_new(DB_MAGIC.as_bytes(), args.db_path)?; + let (mut db, _) = + Store::::load_or_create(DB_MAGIC.as_bytes(), args.db_path)?; let wallet_opt = Wallet::load() .descriptor(KeychainKind::External, Some(args.descriptor.clone())) .descriptor(KeychainKind::Internal, args.change_descriptor.clone()) @@ -129,9 +134,15 @@ fn main() -> anyhow::Result<()> { .expect("failed to send sigterm") }); - let emitter_tip = wallet_tip.clone(); + let mut emitter = Emitter::new( + rpc_client, + wallet_tip, + args.start_height, + wallet + .transactions() + .filter(|tx| tx.chain_position.is_unconfirmed()), + ); spawn(move || -> Result<(), anyhow::Error> { - let mut emitter = Emitter::new(&rpc_client, emitter_tip, args.start_height); while let Some(emission) = emitter.next_block()? { sender.send(Emission::Block(emission))?; } @@ -160,9 +171,10 @@ fn main() -> anyhow::Result<()> { hash, height, elapsed ); } - Emission::Mempool(mempool_emission) => { + Emission::Mempool(event) => { let start_apply_mempool = Instant::now(); - wallet.apply_unconfirmed_txs(mempool_emission); + wallet.apply_evicted_txs(event.evicted_ats()); + wallet.apply_unconfirmed_txs(event.new_txs); wallet.persist(&mut db)?; println!( "Applied unconfirmed transactions in {}s", diff --git a/wallet/Cargo.toml b/wallet/Cargo.toml index dd0b4841..23aa94af 100644 --- a/wallet/Cargo.toml +++ b/wallet/Cargo.toml @@ -21,11 +21,11 @@ miniscript = { version = "12.3.1", features = [ "serde" ], default-features = fa bitcoin = { version = "0.32.4", features = [ "serde", "base64" ], default-features = false } serde = { version = "^1.0", features = ["derive"] } serde_json = { version = "^1.0" } -bdk_chain = { version = "0.21.1", features = [ "miniscript", "serde" ], default-features = false } -bdk_file_store = { version = "0.18.1", optional = true } +bdk_chain = { version = "0.22.0", features = [ "miniscript", "serde" ], default-features = false } # Optional dependencies bip39 = { version = "2.0", optional = true } +bdk_file_store = { version = "0.20.0", optional = true } [features] default = ["std"] @@ -40,9 +40,8 @@ test-utils = ["std"] [dev-dependencies] assert_matches = "1.5.0" tempfile = "3" -bdk_chain = { version = "0.21.1", features = ["rusqlite"] } +bdk_chain = { version = "0.22.0", features = ["rusqlite"] } bdk_wallet = { path = ".", features = ["rusqlite", "file_store", "test-utils"] } -bdk_file_store = { version = "0.18.1" } anyhow = "1" rand = "^0.8" diff --git a/wallet/README.md b/wallet/README.md index bf5b644d..f4538288 100644 --- a/wallet/README.md +++ b/wallet/README.md @@ -65,13 +65,12 @@ To persist `Wallet` state data use a data store crate that reads and writes [`Ch **Example** - ```rust,no_run use bdk_wallet::{bitcoin::Network, KeychainKind, ChangeSet, Wallet}; // Open or create a new file store for wallet data. -let mut db = - bdk_file_store::Store::::open_or_create_new(b"magic_bytes", "/tmp/my_wallet.db") +let (mut db, _changeset) = + bdk_file_store::Store::::load_or_create(b"magic_bytes", "/tmp/my_wallet.db") .expect("create store"); // Create a wallet with initial wallet data read from the file store. diff --git a/wallet/src/test_utils.rs b/wallet/src/test_utils.rs index 7e1778fa..4807dc5d 100644 --- a/wallet/src/test_utils.rs +++ b/wallet/src/test_utils.rs @@ -4,7 +4,7 @@ use alloc::string::ToString; use alloc::sync::Arc; use core::str::FromStr; -use bdk_chain::{tx_graph, BlockId, ConfirmationBlockTime}; +use bdk_chain::{BlockId, ConfirmationBlockTime, TxUpdate}; use bitcoin::{ absolute, hashes::Hash, transaction, Address, Amount, BlockHash, FeeRate, Network, OutPoint, Transaction, TxIn, TxOut, Txid, @@ -312,43 +312,45 @@ pub fn insert_checkpoint(wallet: &mut Wallet, block: BlockId) { .unwrap(); } -/// Insert transaction +/// Inserts a transaction into the local view, assuming it is currently present in the mempool. +/// +/// This can be used, for example, to track a transaction immediately after it is broadcast. pub fn insert_tx(wallet: &mut Wallet, tx: Transaction) { + let txid = tx.compute_txid(); + let seen_at = std::time::UNIX_EPOCH.elapsed().unwrap().as_secs(); + let mut tx_update = TxUpdate::default(); + tx_update.txs = vec![Arc::new(tx)]; + tx_update.seen_ats = [(txid, seen_at)].into(); wallet .apply_update(Update { - tx_update: bdk_chain::TxUpdate { - txs: vec![Arc::new(tx)], - ..Default::default() - }, + tx_update, ..Default::default() }) - .unwrap(); + .expect("failed to apply update"); } /// Simulates confirming a tx with `txid` by applying an update to the wallet containing /// the given `anchor`. Note: to be considered confirmed the anchor block must exist in /// the current active chain. pub fn insert_anchor(wallet: &mut Wallet, txid: Txid, anchor: ConfirmationBlockTime) { + let mut tx_update = TxUpdate::default(); + tx_update.anchors = [(anchor, txid)].into(); wallet .apply_update(Update { - tx_update: tx_graph::TxUpdate { - anchors: [(anchor, txid)].into(), - ..Default::default() - }, + tx_update, ..Default::default() }) - .unwrap(); + .expect("failed to apply update"); } /// Marks the given `txid` seen as unconfirmed at `seen_at` pub fn insert_seen_at(wallet: &mut Wallet, txid: Txid, seen_at: u64) { + let mut tx_update = TxUpdate::default(); + tx_update.seen_ats = [(txid, seen_at)].into(); wallet - .apply_update(crate::Update { - tx_update: tx_graph::TxUpdate { - seen_ats: [(txid, seen_at)].into_iter().collect(), - ..Default::default() - }, + .apply_update(Update { + tx_update, ..Default::default() }) - .unwrap(); + .expect("failed to apply update"); } diff --git a/wallet/src/wallet/mod.rs b/wallet/src/wallet/mod.rs index e4dc6d05..b958d3c5 100644 --- a/wallet/src/wallet/mod.rs +++ b/wallet/src/wallet/mod.rs @@ -30,8 +30,8 @@ use bdk_chain::{ SyncResponse, }, tx_graph::{CalculateFeeError, CanonicalTx, TxGraph, TxUpdate}, - BlockId, ChainPosition, ConfirmationBlockTime, DescriptorExt, FullTxOut, Indexed, - IndexedTxGraph, Indexer, Merge, + BlockId, CanonicalizationParams, ChainPosition, ConfirmationBlockTime, DescriptorExt, + FullTxOut, Indexed, IndexedTxGraph, Indexer, Merge, }; use bitcoin::{ absolute, @@ -816,6 +816,7 @@ impl Wallet { .filter_chain_unspents( &self.chain, self.chain.tip().block_id(), + CanonicalizationParams::default(), self.indexed_graph.index.outpoints().iter().cloned(), ) .map(|((k, i), full_txo)| new_local_utxo(k, i, full_txo)) @@ -830,6 +831,7 @@ impl Wallet { .filter_chain_txouts( &self.chain, self.chain.tip().block_id(), + CanonicalizationParams::default(), self.indexed_graph.index.outpoints().iter().cloned(), ) .map(|((k, i), full_txo)| new_local_utxo(k, i, full_txo)) @@ -883,6 +885,7 @@ impl Wallet { .filter_chain_unspents( &self.chain, self.chain.tip().block_id(), + CanonicalizationParams::default(), core::iter::once(((), op)), ) .map(|(_, full_txo)| new_local_utxo(keychain, index, full_txo)) @@ -1058,7 +1061,11 @@ impl Wallet { pub fn get_tx(&self, txid: Txid) -> Option { let graph = self.indexed_graph.graph(); graph - .list_canonical_txs(&self.chain, self.chain.tip().block_id()) + .list_canonical_txs( + &self.chain, + self.chain.tip().block_id(), + CanonicalizationParams::default(), + ) .find(|tx| tx.tx_node.txid == txid) } @@ -1077,7 +1084,11 @@ impl Wallet { let tx_graph = self.indexed_graph.graph(); let tx_index = &self.indexed_graph.index; tx_graph - .list_canonical_txs(&self.chain, self.chain.tip().block_id()) + .list_canonical_txs( + &self.chain, + self.chain.tip().block_id(), + CanonicalizationParams::default(), + ) .filter(|c_tx| tx_index.is_tx_relevant(&c_tx.tx_node.tx)) } @@ -1112,6 +1123,7 @@ impl Wallet { self.indexed_graph.graph().balance( &self.chain, self.chain.tip().block_id(), + CanonicalizationParams::default(), self.indexed_graph.index.outpoints().iter().cloned(), |&(k, _), _| k == KeychainKind::Internal, ) @@ -1590,7 +1602,7 @@ impl Wallet { let txout_index = &self.indexed_graph.index; let chain_tip = self.chain.tip().block_id(); let chain_positions = graph - .list_canonical_txs(&self.chain, chain_tip) + .list_canonical_txs(&self.chain, chain_tip, CanonicalizationParams::default()) .map(|canon_tx| (canon_tx.tx_node.txid, canon_tx.chain_position)) .collect::>(); @@ -1858,7 +1870,7 @@ impl Wallet { let confirmation_heights = self .indexed_graph .graph() - .list_canonical_txs(&self.chain, chain_tip) + .list_canonical_txs(&self.chain, chain_tip, CanonicalizationParams::default()) .filter(|canon_tx| prev_txids.contains(&canon_tx.tx_node.txid)) // This is for a small performance gain. Although `.filter` filters out excess txs, it // will still consume the internal `CanonicalIter` entirely. Having a `.take` here @@ -2010,6 +2022,7 @@ impl Wallet { .filter_chain_unspents( &self.chain, self.chain.tip().block_id(), + CanonicalizationParams::default(), self.indexed_graph.index.outpoints().iter().cloned(), ) // only create LocalOutput if UTxO is mature @@ -2219,31 +2232,7 @@ impl Wallet { /// /// After applying updates you should persist the staged wallet changes. For an example of how /// to persist staged wallet changes see [`Wallet::reveal_next_address`]. - #[cfg(feature = "std")] - #[cfg_attr(docsrs, doc(cfg(feature = "std")))] pub fn apply_update(&mut self, update: impl Into) -> Result<(), CannotConnectError> { - use std::time::*; - let now = SystemTime::now() - .duration_since(UNIX_EPOCH) - .expect("time now must surpass epoch anchor"); - self.apply_update_at(update, now.as_secs()) - } - - /// Applies an `update` alongside a `seen_at` timestamp and stages the changes. - /// - /// `seen_at` represents when the update is seen (in unix seconds). It is used to determine the - /// `last_seen`s for all transactions in the update which have no corresponding anchor(s). The - /// `last_seen` value is used internally to determine precedence of conflicting unconfirmed - /// transactions (where the transaction with the lower `last_seen` value is omitted from the - /// canonical history). - /// - /// Use [`apply_update`](Wallet::apply_update) to have the `seen_at` value automatically set to - /// the current time. - pub fn apply_update_at( - &mut self, - update: impl Into, - seen_at: u64, - ) -> Result<(), CannotConnectError> { let update = update.into(); let mut changeset = match update.chain { Some(chain_update) => ChangeSet::from(self.chain.apply_update(chain_update)?), @@ -2255,11 +2244,7 @@ impl Wallet { .index .reveal_to_target_multi(&update.last_active_indices); changeset.merge(index_changeset.into()); - changeset.merge( - self.indexed_graph - .apply_update_at(update.tx_update, Some(seen_at)) - .into(), - ); + changeset.merge(self.indexed_graph.apply_update(update.tx_update).into()); self.stage.merge(changeset); Ok(()) } @@ -2382,6 +2367,35 @@ impl Wallet { self.stage.merge(indexed_graph_changeset.into()); } + /// Apply evictions of the given txids with their associated timestamps. + /// + /// This means that any pending unconfirmed tx in this set will no longer be canonical by + /// default. Note that an evicted tx can become canonical if it is later seen again or + /// observed on-chain. + /// + /// This stages the changes which need to be persisted. + pub fn apply_evicted_txs(&mut self, evicted_txs: impl IntoIterator) { + let chain = &self.chain; + let canon_txids: Vec = self + .indexed_graph + .graph() + .list_canonical_txs( + chain, + chain.tip().block_id(), + CanonicalizationParams::default(), + ) + .map(|c| c.tx_node.txid) + .collect(); + + let changeset = self.indexed_graph.batch_insert_relevant_evicted_at( + evicted_txs + .into_iter() + .filter(|(txid, _)| canon_txids.contains(txid)), + ); + + self.stage.merge(changeset.into()); + } + /// Used internally to ensure that all methods requiring a [`KeychainKind`] will use a /// keychain with an associated descriptor. For example in case the wallet was created /// with only one keychain, passing [`KeychainKind::Internal`] here will instead return @@ -2397,16 +2411,48 @@ impl Wallet { /// Methods to construct sync/full-scan requests for spk-based chain sources. impl Wallet { + /// Create a partial [`SyncRequest`] for all revealed spks at `start_time`. + /// + /// The `start_time` is used to record the time that a mempool transaction was last seen + /// (or evicted). See [`Wallet::start_sync_with_revealed_spks`] for more. + pub fn start_sync_with_revealed_spks_at( + &self, + start_time: u64, + ) -> SyncRequestBuilder<(KeychainKind, u32)> { + use bdk_chain::keychain_txout::SyncRequestBuilderExt; + SyncRequest::builder_at(start_time) + .chain_tip(self.chain.tip()) + .revealed_spks_from_indexer(&self.indexed_graph.index, ..) + .expected_spk_txids(self.indexed_graph.list_expected_spk_txids( + &self.chain, + self.chain.tip().block_id(), + .., + )) + } + /// Create a partial [`SyncRequest`] for this wallet for all revealed spks. /// /// This is the first step when performing a spk-based wallet partial sync, the returned /// [`SyncRequest`] collects all revealed script pubkeys from the wallet keychain needed to /// start a blockchain sync with a spk based blockchain client. + /// + /// The time of the sync is the current system time and is used to record the + /// tx last-seen for mempool transactions. Or if an expected transaction is missing + /// or evicted, it is the time of the eviction. Note that timestamps may only increase + /// to be counted by the tx graph. To supply your own start time see + /// [`Wallet::start_sync_with_revealed_spks_at`]. + #[cfg_attr(docsrs, doc(cfg(feature = "std")))] + #[cfg(feature = "std")] pub fn start_sync_with_revealed_spks(&self) -> SyncRequestBuilder<(KeychainKind, u32)> { use bdk_chain::keychain_txout::SyncRequestBuilderExt; SyncRequest::builder() .chain_tip(self.chain.tip()) .revealed_spks_from_indexer(&self.indexed_graph.index, ..) + .expected_spk_txids(self.indexed_graph.list_expected_spk_txids( + &self.chain, + self.chain.tip().block_id(), + .., + )) } /// Create a [`FullScanRequest] for this wallet. @@ -2417,12 +2463,25 @@ impl Wallet { /// /// This operation is generally only used when importing or restoring a previously used wallet /// in which the list of used scripts is not known. + /// + /// The time of the scan is the current system time and is used to record the tx last-seen for + /// mempool transactions. To supply your own start time see [`Wallet::start_full_scan_at`]. + #[cfg_attr(docsrs, doc(cfg(feature = "std")))] + #[cfg(feature = "std")] pub fn start_full_scan(&self) -> FullScanRequestBuilder { use bdk_chain::keychain_txout::FullScanRequestBuilderExt; FullScanRequest::builder() .chain_tip(self.chain.tip()) .spks_from_indexer(&self.indexed_graph.index) } + + /// Create a [`FullScanRequest`] builder at `start_time`. + pub fn start_full_scan_at(&self, start_time: u64) -> FullScanRequestBuilder { + use bdk_chain::keychain_txout::FullScanRequestBuilderExt; + FullScanRequest::builder_at(start_time) + .chain_tip(self.chain.tip()) + .spks_from_indexer(&self.indexed_graph.index) + } } impl AsRef> for Wallet { diff --git a/wallet/src/wallet/persisted.rs b/wallet/src/wallet/persisted.rs index 28a6ec78..71236989 100644 --- a/wallet/src/wallet/persisted.rs +++ b/wallet/src/wallet/persisted.rs @@ -291,7 +291,7 @@ impl WalletPersister for bdk_chain::rusqlite::Connection { #[derive(Debug)] pub enum FileStoreError { /// Error when loading from the store. - Load(bdk_file_store::AggregateChangesetsError), + Load(bdk_file_store::StoreErrorWithDump), /// Error when writing to the store. Write(std::io::Error), } @@ -316,15 +316,13 @@ impl WalletPersister for bdk_file_store::Store { fn initialize(persister: &mut Self) -> Result { persister - .aggregate_changesets() + .dump() .map(Option::unwrap_or_default) .map_err(FileStoreError::Load) } fn persist(persister: &mut Self, changeset: &ChangeSet) -> Result<(), Self::Error> { - persister - .append_changeset(changeset) - .map_err(FileStoreError::Write) + persister.append(changeset).map_err(FileStoreError::Write) } } diff --git a/wallet/tests/wallet.rs b/wallet/tests/wallet.rs index 35cbd85d..e7fe88d1 100644 --- a/wallet/tests/wallet.rs +++ b/wallet/tests/wallet.rs @@ -4,7 +4,7 @@ use std::sync::Arc; use anyhow::Context; use assert_matches::assert_matches; -use bdk_chain::{BlockId, ChainPosition, ConfirmationBlockTime}; +use bdk_chain::{BlockId, CanonicalizationParams, ChainPosition, ConfirmationBlockTime}; use bdk_wallet::coin_selection::{self, LargestFirstCoinSelection}; use bdk_wallet::descriptor::{calc_checksum, DescriptorError, IntoWalletDescriptor}; use bdk_wallet::error::CreateTxError; @@ -117,8 +117,8 @@ fn wallet_is_persisted() -> anyhow::Result<()> { run( "store.db", - |path| Ok(bdk_file_store::Store::create_new(DB_MAGIC, path)?), - |path| Ok(bdk_file_store::Store::open(DB_MAGIC, path)?), + |path| Ok(bdk_file_store::Store::create(DB_MAGIC, path)?), + |path| Ok(bdk_file_store::Store::load(DB_MAGIC, path)?.0), )?; run::( "store.sqlite", @@ -209,12 +209,8 @@ fn wallet_load_checks() -> anyhow::Result<()> { run( "store.db", - |path| { - Ok(bdk_file_store::Store::::create_new( - DB_MAGIC, path, - )?) - }, - |path| Ok(bdk_file_store::Store::::open(DB_MAGIC, path)?), + |path| Ok(bdk_file_store::Store::::create(DB_MAGIC, path)?), + |path| Ok(bdk_file_store::Store::::load(DB_MAGIC, path)?.0), )?; run( "store.sqlite", @@ -4275,7 +4271,11 @@ fn test_wallet_transactions_relevant() { let chain_tip = test_wallet.local_chain().tip().block_id(); let canonical_tx_count_before = test_wallet .tx_graph() - .list_canonical_txs(test_wallet.local_chain(), chain_tip) + .list_canonical_txs( + test_wallet.local_chain(), + chain_tip, + CanonicalizationParams::default(), + ) .count(); // add not relevant transaction to test wallet @@ -4292,7 +4292,11 @@ fn test_wallet_transactions_relevant() { let full_tx_count_after = test_wallet.tx_graph().full_txs().count(); let canonical_tx_count_after = test_wallet .tx_graph() - .list_canonical_txs(test_wallet.local_chain(), chain_tip) + .list_canonical_txs( + test_wallet.local_chain(), + chain_tip, + CanonicalizationParams::default(), + ) .count(); assert_eq!(relevant_tx_count_before, relevant_tx_count_after); @@ -4301,7 +4305,11 @@ fn test_wallet_transactions_relevant() { .any(|wallet_tx| wallet_tx.tx_node.txid == other_txid)); assert!(test_wallet .tx_graph() - .list_canonical_txs(test_wallet.local_chain(), chain_tip) + .list_canonical_txs( + test_wallet.local_chain(), + chain_tip, + CanonicalizationParams::default() + ) .any(|wallet_tx| wallet_tx.tx_node.txid == other_txid)); assert!(full_tx_count_before < full_tx_count_after); assert!(canonical_tx_count_before < canonical_tx_count_after);