From 04994e4f7f1073e7bef29528339369994d4b3666 Mon Sep 17 00:00:00 2001
From: Steve Myers
Date: Mon, 4 Mar 2024 01:19:03 -0600
Subject: [PATCH] ci: bump MSRV to 1.63.0
Fix related clippy errors
---
.github/workflows/cont_integration.yml | 74 ++++++++------------------
Cargo.toml | 12 ++---
README.md | 40 ++------------
clippy.toml | 1 +
examples/compact_filters_balance.rs | 2 +-
src/blockchain/compact_filters/sync.rs | 2 +-
src/blockchain/electrum.rs | 6 +--
src/blockchain/script_sync.rs | 9 ++--
src/database/mod.rs | 1 +
src/descriptor/mod.rs | 32 +++++------
src/descriptor/template.rs | 4 +-
src/keys/mod.rs | 2 +-
src/lib.rs | 6 +--
src/wallet/coin_selection.rs | 54 +++++++++----------
src/wallet/export.rs | 7 +--
src/wallet/mod.rs | 4 +-
src/wallet/signer.rs | 9 +---
src/wallet/tx_builder.rs | 20 ++-----
18 files changed, 100 insertions(+), 185 deletions(-)
create mode 100644 clippy.toml
diff --git a/.github/workflows/cont_integration.yml b/.github/workflows/cont_integration.yml
index bc2c8844..a3ae6f16 100644
--- a/.github/workflows/cont_integration.yml
+++ b/.github/workflows/cont_integration.yml
@@ -18,9 +18,9 @@ jobs:
strategy:
matrix:
rust:
- - version: 1.65.0 # STABLE
+ - version: stable
clippy: true
- - version: 1.57.0 # MSRV
+ - version: 1.63.0 # MSRV
features:
- default
- minimal
@@ -60,33 +60,17 @@ jobs:
- name: Update toolchain
run: rustup update
- name: Pin dependencies for MSRV
- if: matrix.rust.version == '1.57.0'
+ if: matrix.rust.version == '1.63.0'
run: |
- cargo update -p log --precise "0.4.18"
- cargo update -p tempfile --precise "3.6.0"
- cargo update -p hashlink --precise "0.8.1"
cargo update -p regex --precise "1.7.3"
- cargo update -p zip:0.6.6 --precise "0.6.3"
- cargo update -p rustix --precise "0.37.23"
- cargo update -p tokio --precise "1.29.1"
- cargo update -p tokio-util --precise "0.7.8"
- cargo update -p cc --precise "1.0.81"
- cargo update -p rustls:0.20.9 --precise "0.20.8"
- cargo update -p rustls:0.21.7 --precise "0.21.1"
- cargo update -p flate2:1.0.27 --precise "1.0.26"
- cargo update -p reqwest --precise "0.11.18"
- cargo update -p h2 --precise "0.3.20"
- cargo update -p rustls-webpki:0.100.3 --precise "0.100.1"
- cargo update -p rustls-webpki:0.101.6 --precise "0.101.1"
- cargo update -p byteorder --precise "1.4.3"
- cargo update -p webpki --precise "0.22.2"
+ cargo update -p home --precise "0.5.5"
- name: Build
- run: cargo build --features ${{ matrix.features }} --no-default-features
+ run: cargo build --features bitcoin/std,miniscript/std,${{ matrix.features }} --no-default-features
- name: Clippy
if: ${{ matrix.rust.clippy }}
- run: cargo clippy --all-targets --features ${{ matrix.features }} --no-default-features -- -D warnings
+ run: cargo clippy --all-targets --features bitcoin/std,miniscript/std,${{ matrix.features }} --no-default-features -- -D warnings
- name: Test
- run: cargo test --features ${{ matrix.features }} --no-default-features
+ run: cargo test --features bitcoin/std,miniscript/std,${{ matrix.features }} --no-default-features
test-readme-examples:
name: Test README.md examples
@@ -109,7 +93,7 @@ jobs:
- name: Update toolchain
run: rustup update
- name: Test
- run: cargo test --features test-md-docs --no-default-features -- doctest::ReadmeDoctests
+ run: cargo test --features bitcoin/std,miniscript/std,test-md-docs --no-default-features -- doctest::ReadmeDoctests
test-blockchains:
name: Blockchain ${{ matrix.blockchain.features }}
@@ -120,19 +104,19 @@ jobs:
blockchain:
- name: electrum
testprefix: blockchain::electrum::test
- features: test-electrum,verify
+ features: test-electrum,verify,bitcoin/std,miniscript/std
- name: rpc
testprefix: blockchain::rpc::test
- features: test-rpc
+ features: test-rpc,bitcoin/std,miniscript/std
- name: rpc-legacy
testprefix: blockchain::rpc::test
- features: test-rpc-legacy
+ features: test-rpc-legacy,bitcoin/std,miniscript/std
- name: esplora
testprefix: esplora
- features: test-esplora,use-esplora-async,verify
+ features: test-esplora,use-esplora-async,verify,bitcoin/std,miniscript/std
- name: esplora
testprefix: esplora
- features: test-esplora,use-esplora-blocking,verify
+ features: test-esplora,use-esplora-blocking,verify,bitcoin/std,miniscript/std
steps:
- name: Checkout
uses: actions/checkout@v2
@@ -150,7 +134,7 @@ jobs:
toolchain: stable
override: true
- name: Test
- run: cargo test --no-default-features --features ${{ matrix.blockchain.features }} ${{ matrix.blockchain.testprefix }}::bdk_blockchain_tests
+ run: cargo test --no-default-features --features bitcoin/std,miniscript/std,${{ matrix.blockchain.features }} ${{ matrix.blockchain.testprefix }}::bdk_blockchain_tests
check-wasm:
name: Check WASM
@@ -175,7 +159,7 @@ jobs:
- run: sudo apt-get update || exit 1
- run: sudo apt-get install -y libclang-common-10-dev clang-10 libc6-dev-i386 || exit 1
- name: Set default toolchain
- run: rustup default 1.65.0 # STABLE
+ run: rustup default stable
- name: Set profile
run: rustup set profile minimal
- name: Add target wasm32
@@ -183,7 +167,7 @@ jobs:
- name: Update toolchain
run: rustup update
- name: Check
- run: cargo check --target wasm32-unknown-unknown --features async-interface,use-esplora-async,dev-getrandom-wasm --no-default-features
+ run: cargo check --target wasm32-unknown-unknown --features bitcoin/no-std,miniscript/no-std,async-interface,use-esplora-async,dev-getrandom-wasm --no-default-features
fmt:
name: Rust fmt
@@ -207,8 +191,8 @@ jobs:
strategy:
matrix:
rust:
- - version: 1.65.0 # STABLE
- - version: 1.57.0 # MSRV
+ - version: stable
+ - version: 1.63.0 # MSRV
steps:
- name: Checkout
uses: actions/checkout@v3
@@ -229,25 +213,9 @@ jobs:
- name: Update toolchain
run: rustup update
- name: Pin dependencies for MSRV
- if: matrix.rust.version == '1.57.0'
+ if: matrix.rust.version == '1.63.0'
run: |
- cargo update -p log --precise "0.4.18"
- cargo update -p tempfile --precise "3.6.0"
- cargo update -p hashlink --precise "0.8.1"
- cargo update -p regex --precise "1.7.3"
- cargo update -p zip:0.6.6 --precise "0.6.3"
- cargo update -p rustix --precise "0.37.23"
- cargo update -p tokio --precise "1.29.1"
- cargo update -p tokio-util --precise "0.7.8"
- cargo update -p cc --precise "1.0.81"
- cargo update -p rustls:0.20.9 --precise "0.20.8"
- cargo update -p rustls:0.21.7 --precise "0.21.1"
- cargo update -p flate2:1.0.27 --precise "1.0.26"
- cargo update -p reqwest --precise "0.11.18"
- cargo update -p h2 --precise "0.3.20"
- cargo update -p rustls-webpki:0.100.3 --precise "0.100.1"
- cargo update -p rustls-webpki:0.101.6 --precise "0.101.1"
- cargo update -p byteorder --precise "1.4.3"
- cargo update -p webpki --precise "0.22.2"
+ cargo update -p regex --precise "1.7.3"
+ cargo update -p home --precise "0.5.5"
- name: Test
run: cargo test --features test-hardware-signer
diff --git a/Cargo.toml b/Cargo.toml
index ed440c43..a2deaaba 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,7 +1,6 @@
[package]
name = "bdk"
-version = "0.29.0"
-edition = "2018"
+version = "0.30.0"
authors = ["Alekos Filini ", "Riccardo Casatta "]
homepage = "https://bitcoindevkit.org"
repository = "https://github.com/bitcoindevkit/bdk"
@@ -10,6 +9,8 @@ description = "A modern, lightweight, descriptor-based wallet library"
keywords = ["bitcoin", "wallet", "descriptor", "psbt"]
readme = "README.md"
license = "MIT OR Apache-2.0"
+edition = "2021"
+rust-version = "1.63"
[dependencies]
bdk-macros = "^0.6"
@@ -24,11 +25,10 @@ rand = "^0.8"
sled = { version = "0.34", optional = true }
electrum-client = { version = "0.18", optional = true }
esplora-client = { version = "0.6", default-features = false, optional = true }
-rusqlite = { version = "0.28.0", optional = true }
-ahash = { version = "0.7.6", optional = true }
+rusqlite = { version = "0.27.0", optional = true }
futures = { version = "0.3", optional = true }
async-trait = { version = "0.1", optional = true }
-rocksdb = { version = "0.14", default-features = false, features = ["snappy"], optional = true }
+rocksdb = { version = "0.18", default-features = false, features = ["snappy"], optional = true }
cc = { version = ">=1.0.64", optional = true }
socks = { version = "0.3", optional = true }
hwi = { version = "0.7", optional = true, features = ["miniscript"] }
@@ -56,7 +56,7 @@ default = ["std", "key-value-db", "electrum"]
# std feature is always required unless building for wasm32-unknown-unknown target
# if building for wasm user must add dependencies bitcoin/no-std,miniscript/no-std
std = ["bitcoin/std", "miniscript/std"]
-sqlite = ["rusqlite", "ahash"]
+sqlite = ["rusqlite"]
sqlite-bundled = ["sqlite", "rusqlite/bundled"]
compact_filters = ["rocksdb", "socks", "cc"]
key-value-db = ["sled"]
diff --git a/README.md b/README.md
index 42eee279..39a1b8ea 100644
--- a/README.md
+++ b/README.md
@@ -13,7 +13,7 @@
-
+
@@ -204,45 +204,11 @@ dual licensed as above, without any additional terms or conditions.
## Minimum Supported Rust Version (MSRV)
-This library should compile with any combination of features with Rust 1.57.0.
+This library should compile with any combination of features with Rust 1.63.0.
To build with the MSRV you will need to pin dependencies as follows:
```shell
-# log 0.4.19 has MSRV 1.60.0
-cargo update -p log --precise "0.4.18"
-# tempfile 3.7.0 has MSRV 1.63.0
-cargo update -p tempfile --precise "3.6.0"
-# required for sqlite feature, hashlink 0.8.2 has MSRV 1.61.0
-cargo update -p hashlink --precise "0.8.1"
-# required for compact_filters feature, regex after 1.7.3 has MSRV 1.60.0
cargo update -p regex --precise "1.7.3"
-# zip 0.6.3 has MSRV 1.59.0 but still works
-cargo update -p zip:0.6.6 --precise "0.6.3"
-# rustix 0.38.0 has MSRV 1.65.0
-cargo update -p rustix --precise "0.37.23"
-# tokio 1.30 has MSRV 1.63.0+
-cargo update -p tokio --precise "1.29.1"
-# tokio-util 0.7.9 doesn't build with MSRV 1.57.0
-cargo update -p tokio-util --precise "0.7.8"
-# cc 1.0.82 is throwing error with rust 1.57.0, "error[E0599]: no method named `retain_mut`..."
-cargo update -p cc --precise "1.0.81"
-# rustls 0.20.9 has MSRV 1.60.0+
-cargo update -p rustls:0.20.9 --precise "0.20.8"
-# rustls 0.21.2 has MSRV 1.60.0+
-cargo update -p rustls:0.21.7 --precise "0.21.1"
-# flate2 1.0.27 has MSRV 1.63.0+
-cargo update -p flate2:1.0.27 --precise "1.0.26"
-# reqwest 0.11.19 has MSRV 1.63.0+
-cargo update -p reqwest --precise "0.11.18"
-# h2 0.3.21 has MSRV 1.63.0+
-cargo update -p h2 --precise "0.3.20"
-# rustls-webpki 0.100.2 has MSRV 1.60+
-cargo update -p rustls-webpki:0.100.3 --precise "0.100.1"
-# rustls-webpki 0.101.6 has MSRV 1.60+
-cargo update -p rustls-webpki:0.101.6 --precise "0.101.1"
-# byteorder 1.5.0 has MSRV 1.60.0+
-cargo update -p byteorder --precise "1.4.3"
-# webpki 0.22.4 requires `ring:0.17.2` which has MSRV 1.61.0+
-cargo update -p webpki --precise "0.22.2"
+cargo update -p home --precise "0.5.5"
```
diff --git a/clippy.toml b/clippy.toml
new file mode 100644
index 00000000..e3b99604
--- /dev/null
+++ b/clippy.toml
@@ -0,0 +1 @@
+msrv="1.63.0"
\ No newline at end of file
diff --git a/examples/compact_filters_balance.rs b/examples/compact_filters_balance.rs
index ce875b4d..152ab246 100644
--- a/examples/compact_filters_balance.rs
+++ b/examples/compact_filters_balance.rs
@@ -34,7 +34,7 @@ fn main() -> Result<(), CompactFiltersError> {
let descriptor = "wpkh(tpubD6NzVbkrYhZ4X2yy78HWrr1M9NT8dKeWfzNiQqDdMqqa9UmmGztGGz6TaLFGsLfdft5iu32gxq1T4eMNxExNNWzVCpf9Y6JZi5TnqoC9wJq/*)";
let database = MemoryDatabase::default();
- let wallet = Arc::new(Wallet::new(descriptor, None, Network::Testnet, database).unwrap());
+ let wallet = Wallet::new(descriptor, None, Network::Testnet, database).unwrap();
wallet.sync(&blockchain, SyncOptions::default()).unwrap();
info!("balance: {}", wallet.get_balance()?);
Ok(())
diff --git a/src/blockchain/compact_filters/sync.rs b/src/blockchain/compact_filters/sync.rs
index 1e4e36fb..97c04363 100644
--- a/src/blockchain/compact_filters/sync.rs
+++ b/src/blockchain/compact_filters/sync.rs
@@ -166,7 +166,7 @@ impl CfSync {
let filters = cf_filters
.into_iter()
.enumerate()
- .chain(filters_map.into_iter())
+ .chain(filters_map)
.collect();
status = self
.cf_store
diff --git a/src/blockchain/electrum.rs b/src/blockchain/electrum.rs
index ad7c9a53..70e8eca3 100644
--- a/src/blockchain/electrum.rs
+++ b/src/blockchain/electrum.rs
@@ -168,7 +168,7 @@ impl WalletSync for ElectrumBlockchain {
let needs_block_height = conftime_req
.request()
.filter_map(|txid| txid_to_height.get(txid).cloned())
- .filter(|height| block_times.get(height).is_none())
+ .filter(|height| block_times.contains_key(height))
.take(chunk_size)
.collect::>();
@@ -269,7 +269,7 @@ impl<'a, 'b, D: Database> TxCache<'a, 'b, D> {
fn save_txs<'c>(&mut self, txids: impl Iterator- ) -> Result<(), Error> {
let mut need_fetch = vec![];
for txid in txids {
- if self.cache.get(txid).is_some() {
+ if self.cache.contains_key(txid) {
continue;
} else if let Some(transaction) = self.db.get_raw_tx(txid)? {
self.cache.insert(*txid, transaction);
@@ -295,7 +295,7 @@ impl<'a, 'b, D: Database> TxCache<'a, 'b, D> {
}
fn get(&self, txid: Txid) -> Option {
- self.cache.get(&txid).map(Clone::clone)
+ self.cache.get(&txid).cloned()
}
}
diff --git a/src/blockchain/script_sync.rs b/src/blockchain/script_sync.rs
index e4c46999..bb149c6b 100644
--- a/src/blockchain/script_sync.rs
+++ b/src/blockchain/script_sync.rs
@@ -419,7 +419,7 @@ impl<'a, D: BatchDatabase> State<'a, D> {
txout: output.clone(),
keychain,
// Is this UTXO in the spent_utxos set?
- is_spent: spent_utxos.get(&outpoint).is_some(),
+ is_spent: spent_utxos.contains(&outpoint),
})?;
}
}
@@ -464,11 +464,10 @@ fn make_txs_consistent(txs: &[TransactionDetails]) -> Vec<&TransactionDetails> {
}
utxo_index
- .into_iter()
- .map(|(_, tx)| (tx.txid, tx))
+ .into_values()
+ .map(|tx| (tx.txid, tx))
.collect::>()
- .into_iter()
- .map(|(_, tx)| tx)
+ .into_values()
.chain(coinbase_txs)
.collect()
}
diff --git a/src/database/mod.rs b/src/database/mod.rs
index fd835300..ab5075d1 100644
--- a/src/database/mod.rs
+++ b/src/database/mod.rs
@@ -188,6 +188,7 @@ pub(crate) trait DatabaseUtils: Database {
.map(|o| o.is_some())
}
+ #[allow(unused)]
fn get_raw_tx_or(&self, txid: &Txid, default: D) -> Result