diff --git a/Cargo.1.48.0.toml b/Cargo.1.48.0.toml new file mode 100644 index 000000000..07ae482c6 --- /dev/null +++ b/Cargo.1.48.0.toml @@ -0,0 +1,5 @@ +[workspace] +members = [ + "crates/chain", + "crates/file_store", +] diff --git a/Cargo.toml b/Cargo.toml index 2104196be..a02151330 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,5 +14,5 @@ members = [ "nursery/coin_select" ] -[workspace.package] -authors = ["Bitcoin Dev Kit Developers"] +# [workspace.package] +# authors = ["Bitcoin Dev Kit Developers"] diff --git a/build-msrv-crates.sh b/build-msrv-crates.sh new file mode 100755 index 000000000..aed07a59a --- /dev/null +++ b/build-msrv-crates.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env sh +trap ' + signal=$?; + cleanup + exit $signal; +' INT + +cleanup() { + mv Cargo.tmp.toml Cargo.toml 2>/dev/null +} + +cp Cargo.toml Cargo.tmp.toml +cp Cargo.1.48.0.toml Cargo.toml +cat Cargo.toml +cargo +1.48.0 build --release +cleanup diff --git a/crates/bdk/Cargo.toml b/crates/bdk/Cargo.toml index cc95099da..4cddd113e 100644 --- a/crates/bdk/Cargo.toml +++ b/crates/bdk/Cargo.toml @@ -9,8 +9,8 @@ keywords = ["bitcoin", "wallet", "descriptor", "psbt"] readme = "README.md" license = "MIT OR Apache-2.0" authors = ["Bitcoin Dev Kit Developers"] -edition = "2021" -rust-version = "1.57" +edition = "2018" +# rust-version = "1.57" [dependencies] log = "^0.4" diff --git a/crates/bdk/tests/wallet.rs b/crates/bdk/tests/wallet.rs index 0ada20d39..3cf3ef457 100644 --- a/crates/bdk/tests/wallet.rs +++ b/crates/bdk/tests/wallet.rs @@ -3050,7 +3050,7 @@ fn test_spend_coinbase() { builder.finish(), Err(Error::InsufficientFunds { needed: _, - available: 0 + available: 0, }) )); @@ -3063,7 +3063,7 @@ fn test_spend_coinbase() { builder.finish(), Err(Error::InsufficientFunds { needed: _, - available: 0 + available: 0, }) ); diff --git a/crates/chain/Cargo.toml b/crates/chain/Cargo.toml index bb4786675..98e8c285b 100644 --- a/crates/chain/Cargo.toml +++ b/crates/chain/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "bdk_chain" version = "0.4.0" -edition = "2021" -rust-version = "1.57" +edition = "2018" +# rust-version = "1.48" homepage = "https://bitcoindevkit.org" repository = "https://github.com/bitcoindevkit/bdk" documentation = "https://docs.rs/bdk_chain" @@ -28,3 +28,4 @@ rand = "0.8" default = ["std", "miniscript"] std = [] serde = ["serde_crate", "bitcoin/serde" ] +doc_include_readme = [] diff --git a/crates/chain/README.md b/crates/chain/README.md index 02b333505..1cee1cf38 100644 --- a/crates/chain/README.md +++ b/crates/chain/README.md @@ -1,3 +1,21 @@ # BDK Chain -BDK keychain tracker, tools for storing and indexing chain data. +This crate is a collection of core structures for [Bitcoin Dev Kit] (alpha release). + +The goal of this crate is to give wallets the mechanisms needed to: + +1. Figure out what data they need to fetch. +2. Process the data in a way that never leads to inconsistent states. +3. Fully index that data and expose it to be consumed without friction. + +Our design goals for these mechanisms are: + +1. Data source agnostic -- nothing in `bdk_chain` cares about where you get data from or whether + you do it synchronously or asynchronously. If you know a fact about the blockchain, you can just + tell `bdk_chain`'s APIs about it, and that information will be integrated, if it can be done + consistently. +2. Error-free APIs. +3. Data persistence agnostic -- `bdk_chain` does not care where you cache on-chain data, what you + cache or how you fetch it. + +[Bitcoin Dev Kit]: https://bitcoindevkit.org/ diff --git a/crates/chain/src/chain_graph.rs b/crates/chain/src/chain_graph.rs index 47845c5a0..6b65fca85 100644 --- a/crates/chain/src/chain_graph.rs +++ b/crates/chain/src/chain_graph.rs @@ -30,7 +30,7 @@ pub struct ChainGraph

{ graph: TxGraph, } -impl

Default for ChainGraph

{ +impl Default for ChainGraph

{ fn default() -> Self { Self { chain: Default::default(), diff --git a/crates/chain/src/indexed_tx_graph.rs b/crates/chain/src/indexed_tx_graph.rs index f69b227a2..3e69b7c2a 100644 --- a/crates/chain/src/indexed_tx_graph.rs +++ b/crates/chain/src/indexed_tx_graph.rs @@ -16,7 +16,7 @@ pub struct IndexedTxGraph { graph: TxGraph, } -impl Default for IndexedTxGraph { +impl Default for IndexedTxGraph { fn default() -> Self { Self { graph: Default::default(), @@ -25,7 +25,7 @@ impl Default for IndexedTxGraph { } } -impl IndexedTxGraph { +impl IndexedTxGraph { /// Construct a new [`IndexedTxGraph`] with a given `index`. pub fn new(index: I) -> Self { Self { @@ -183,7 +183,7 @@ pub struct IndexedAdditions { pub index_additions: IA, } -impl Default for IndexedAdditions { +impl Default for IndexedAdditions { fn default() -> Self { Self { graph_additions: Default::default(), diff --git a/crates/chain/src/keychain.rs b/crates/chain/src/keychain.rs index f4d398ab0..f2802f0a9 100644 --- a/crates/chain/src/keychain.rs +++ b/crates/chain/src/keychain.rs @@ -90,7 +90,7 @@ impl Append for DerivationAdditions { } } -impl Default for DerivationAdditions { +impl Default for DerivationAdditions { fn default() -> Self { Self(Default::default()) } @@ -111,7 +111,7 @@ pub struct KeychainScan { pub last_active_indices: BTreeMap, } -impl Default for KeychainScan { +impl Default for KeychainScan { fn default() -> Self { Self { update: Default::default(), @@ -120,7 +120,7 @@ impl Default for KeychainScan { } } -impl From> for KeychainScan { +impl From> for KeychainScan { fn from(update: ChainGraph

) -> Self { KeychainScan { update, @@ -152,7 +152,7 @@ pub struct KeychainChangeSet { pub chain_graph: chain_graph::ChangeSet

, } -impl Default for KeychainChangeSet { +impl Default for KeychainChangeSet { fn default() -> Self { Self { chain_graph: Default::default(), @@ -182,7 +182,7 @@ impl KeychainChangeSet { } } -impl From> for KeychainChangeSet { +impl From> for KeychainChangeSet { fn from(changeset: chain_graph::ChangeSet

) -> Self { Self { chain_graph: changeset, @@ -191,7 +191,7 @@ impl From> for KeychainChangeSet { } } -impl From> for KeychainChangeSet { +impl From> for KeychainChangeSet { fn from(additions: DerivationAdditions) -> Self { Self { derivation_indices: additions, diff --git a/crates/chain/src/keychain/persist.rs b/crates/chain/src/keychain/persist.rs index 1a3ffab02..71b23a577 100644 --- a/crates/chain/src/keychain/persist.rs +++ b/crates/chain/src/keychain/persist.rs @@ -23,7 +23,7 @@ pub struct Persist { stage: keychain::KeychainChangeSet, } -impl Persist { +impl Persist { /// Create a new `Persist` from a [`PersistBackend`]. pub fn new(backend: B) -> Self { Self { diff --git a/crates/chain/src/keychain/tracker.rs b/crates/chain/src/keychain/tracker.rs index fff5ee2b4..524987957 100644 --- a/crates/chain/src/keychain/tracker.rs +++ b/crates/chain/src/keychain/tracker.rs @@ -67,13 +67,16 @@ where scan: &KeychainScan, ) -> Result, chain_graph::UpdateError

> { // TODO: `KeychainTxOutIndex::determine_additions` - let mut derivation_indices = scan.last_active_indices.clone(); - derivation_indices.retain(|keychain, index| { - match self.txout_index.last_revealed_index(keychain) { - Some(existing) => *index > existing, - None => true, - } - }); + let derivation_indices = scan + .last_active_indices + .iter() + .filter_map( + |(keychain, index)| match self.txout_index.last_revealed_index(keychain) { + Some(existing) if *index <= existing => None, + _ => Some((keychain.clone(), *index)), + }, + ) + .collect::>(); Ok(KeychainChangeSet { derivation_indices: DerivationAdditions(derivation_indices), @@ -234,7 +237,7 @@ where let mut untrusted_pending = 0; let mut confirmed = 0; let last_sync_height = self.chain().latest_checkpoint().map(|latest| latest.height); - for ((keychain, _), utxo) in self.full_utxos() { + for (keychain_index, utxo) in self.full_utxos() { let chain_position = &utxo.chain_position; match chain_position.height() { @@ -253,7 +256,7 @@ where } } TxHeight::Unconfirmed => { - if should_trust(keychain) { + if should_trust(&keychain_index.0) { trusted_pending += utxo.txout.value; } else { untrusted_pending += utxo.txout.value; @@ -280,7 +283,7 @@ where } } -impl Default for KeychainTracker { +impl Default for KeychainTracker { fn default() -> Self { Self { txout_index: Default::default(), diff --git a/crates/chain/src/keychain/txout_index.rs b/crates/chain/src/keychain/txout_index.rs index 397c43386..361bb3c13 100644 --- a/crates/chain/src/keychain/txout_index.rs +++ b/crates/chain/src/keychain/txout_index.rs @@ -70,7 +70,7 @@ pub struct KeychainTxOutIndex { lookahead: BTreeMap, } -impl Default for KeychainTxOutIndex { +impl Default for KeychainTxOutIndex { fn default() -> Self { Self { inner: SpkTxOutIndex::default(), diff --git a/crates/chain/src/sparse_chain.rs b/crates/chain/src/sparse_chain.rs index b9c1e24ba..2fff7a15e 100644 --- a/crates/chain/src/sparse_chain.rs +++ b/crates/chain/src/sparse_chain.rs @@ -347,7 +347,7 @@ impl

AsRef> for SparseChain

{ } } -impl

Default for SparseChain

{ +impl Default for SparseChain

{ fn default() -> Self { Self { checkpoints: Default::default(), diff --git a/crates/chain/src/spk_iter.rs b/crates/chain/src/spk_iter.rs index 97c814417..838aa0d86 100644 --- a/crates/chain/src/spk_iter.rs +++ b/crates/chain/src/spk_iter.rs @@ -110,7 +110,7 @@ where fn nth(&mut self, n: usize) -> Option { self.next_index = self .next_index - .saturating_add(u32::try_from(n).unwrap_or(u32::MAX)); + .saturating_add(core::convert::TryFrom::try_from(n).unwrap_or(u32::MAX)); self.next() } } diff --git a/crates/chain/src/spk_txout_index.rs b/crates/chain/src/spk_txout_index.rs index 0eaec4bb7..ba59bebc9 100644 --- a/crates/chain/src/spk_txout_index.rs +++ b/crates/chain/src/spk_txout_index.rs @@ -41,7 +41,7 @@ pub struct SpkTxOutIndex { spk_txouts: BTreeSet<(I, OutPoint)>, } -impl Default for SpkTxOutIndex { +impl Default for SpkTxOutIndex { fn default() -> Self { Self { txouts: Default::default(), diff --git a/crates/chain/src/tx_graph.rs b/crates/chain/src/tx_graph.rs index 335a19197..670161011 100644 --- a/crates/chain/src/tx_graph.rs +++ b/crates/chain/src/tx_graph.rs @@ -83,7 +83,7 @@ pub struct TxGraph { empty_outspends: HashSet, } -impl Default for TxGraph { +impl Default for TxGraph { fn default() -> Self { Self { txs: Default::default(), @@ -171,7 +171,7 @@ impl TxGraph { TxNodeInternal::Partial(txouts) => Some( txouts .iter() - .map(|(&vout, txout)| (OutPoint::new(*txid, vout), txout)), + .map(move |(&vout, txout)| (OutPoint::new(*txid, vout), txout)), ), }) .flatten() @@ -384,7 +384,7 @@ impl TxGraph { update.txs.insert( outpoint.txid, ( - TxNodeInternal::Partial([(outpoint.vout, txout)].into()), + TxNodeInternal::Partial(core::iter::once((outpoint.vout, txout)).collect()), BTreeSet::new(), 0, ), @@ -989,7 +989,7 @@ pub struct Additions { pub last_seen: BTreeMap, } -impl Default for Additions { +impl Default for Additions { fn default() -> Self { Self { tx: Default::default(), diff --git a/crates/electrum/Cargo.toml b/crates/electrum/Cargo.toml index 20eac4d37..4410d273d 100644 --- a/crates/electrum/Cargo.toml +++ b/crates/electrum/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bdk_electrum" version = "0.2.0" -edition = "2021" +edition = "2018" homepage = "https://bitcoindevkit.org" repository = "https://github.com/bitcoindevkit/bdk" documentation = "https://docs.rs/bdk_electrum" diff --git a/crates/esplora/Cargo.toml b/crates/esplora/Cargo.toml index e55b6fa01..9dfd91aee 100644 --- a/crates/esplora/Cargo.toml +++ b/crates/esplora/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bdk_esplora" version = "0.2.0" -edition = "2021" +edition = "2018" homepage = "https://bitcoindevkit.org" repository = "https://github.com/bitcoindevkit/bdk" documentation = "https://docs.rs/bdk_esplora" diff --git a/crates/file_store/Cargo.toml b/crates/file_store/Cargo.toml index 791780409..edfeb3373 100644 --- a/crates/file_store/Cargo.toml +++ b/crates/file_store/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bdk_file_store" version = "0.1.0" -edition = "2021" +edition = "2018" license = "MIT OR Apache-2.0" repository = "https://github.com/bitcoindevkit/bdk" documentation = "https://docs.rs/bdk_file_store" diff --git a/example-crates/keychain_tracker_electrum/Cargo.toml b/example-crates/keychain_tracker_electrum/Cargo.toml index 10226b43a..6dbdf300d 100644 --- a/example-crates/keychain_tracker_electrum/Cargo.toml +++ b/example-crates/keychain_tracker_electrum/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "keychain_tracker_electrum_example" version = "0.1.0" -edition = "2021" +edition = "2018" [dependencies] bdk_chain = { path = "../../crates/chain", features = ["serde"] } diff --git a/example-crates/keychain_tracker_esplora/Cargo.toml b/example-crates/keychain_tracker_esplora/Cargo.toml index e0a1e62dc..a3e451406 100644 --- a/example-crates/keychain_tracker_esplora/Cargo.toml +++ b/example-crates/keychain_tracker_esplora/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "keychain_tracker_esplora_example" version = "0.1.0" -edition = "2021" +edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/example-crates/keychain_tracker_example_cli/Cargo.toml b/example-crates/keychain_tracker_example_cli/Cargo.toml index 7e51fec54..0fa78813b 100644 --- a/example-crates/keychain_tracker_example_cli/Cargo.toml +++ b/example-crates/keychain_tracker_example_cli/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "keychain_tracker_example_cli" version = "0.1.0" -edition = "2021" +edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] diff --git a/example-crates/wallet_electrum/Cargo.toml b/example-crates/wallet_electrum/Cargo.toml index da84e85f1..80569f90b 100644 --- a/example-crates/wallet_electrum/Cargo.toml +++ b/example-crates/wallet_electrum/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "wallet_electrum_example" version = "0.1.0" -edition = "2021" +edition = "2018" [dependencies] bdk = { path = "../../crates/bdk" } diff --git a/example-crates/wallet_esplora/Cargo.toml b/example-crates/wallet_esplora/Cargo.toml index 8e19cb7bd..80af838ec 100644 --- a/example-crates/wallet_esplora/Cargo.toml +++ b/example-crates/wallet_esplora/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bdk-esplora-wallet-example" version = "0.1.0" -edition = "2021" +edition = "2018" publish = false # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/example-crates/wallet_esplora_async/Cargo.toml b/example-crates/wallet_esplora_async/Cargo.toml index af368fc8d..d87dc4882 100644 --- a/example-crates/wallet_esplora_async/Cargo.toml +++ b/example-crates/wallet_esplora_async/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "wallet_esplora_async" version = "0.1.0" -edition = "2021" +edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/nursery/tmp_plan/Cargo.toml b/nursery/tmp_plan/Cargo.toml index a97e5cb73..550414123 100644 --- a/nursery/tmp_plan/Cargo.toml +++ b/nursery/tmp_plan/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bdk_tmp_plan" version = "0.1.0" -edition = "2021" +edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html