]> Untitled Git - bdk/commitdiff
ci: bump MSRV to 1.63.0
authorSteve Myers <steve@notmandatory.org>
Mon, 4 Mar 2024 07:19:03 +0000 (01:19 -0600)
committerSteve Myers <steve@notmandatory.org>
Mon, 21 Oct 2024 17:34:01 +0000 (12:34 -0500)
Fix related clippy errors

18 files changed:
.github/workflows/cont_integration.yml
Cargo.toml
README.md
clippy.toml [new file with mode: 0644]
examples/compact_filters_balance.rs
src/blockchain/compact_filters/sync.rs
src/blockchain/electrum.rs
src/blockchain/script_sync.rs
src/database/mod.rs
src/descriptor/mod.rs
src/descriptor/template.rs
src/keys/mod.rs
src/lib.rs
src/wallet/coin_selection.rs
src/wallet/export.rs
src/wallet/mod.rs
src/wallet/signer.rs
src/wallet/tx_builder.rs

index bc2c88442ea3eb3473d80df55fa8c33d9631a55b..a3ae6f167cb20a9a2a6d14741676c6d52f05dfe6 100644 (file)
@@ -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
index ed440c4383072e079bde06380dea000411503ffe..a2deaaba0e6267a96e85ab49a3f2b7251e5fee50 100644 (file)
@@ -1,7 +1,6 @@
 [package]
 name = "bdk"
-version = "0.29.0"
-edition = "2018"
+version = "0.30.0"
 authors = ["Alekos Filini <alekos.filini@gmail.com>", "Riccardo Casatta <riccardo@casatta.it>"]
 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"]
index 42eee27952f7688929873b36fd10a1040873c663..39a1b8ea5845c4601871085951e282624983db0b 100644 (file)
--- a/README.md
+++ b/README.md
@@ -13,7 +13,7 @@
     <a href="https://github.com/bitcoindevkit/bdk/actions?query=workflow%3ACI"><img alt="CI Status" src="https://github.com/bitcoindevkit/bdk/workflows/CI/badge.svg"></a>
     <a href="https://coveralls.io/github/bitcoindevkit/bdk?branch=master"><img src="https://coveralls.io/repos/github/bitcoindevkit/bdk/badge.svg?branch=master"/></a>
     <a href="https://docs.rs/bdk"><img alt="API Docs" src="https://img.shields.io/badge/docs.rs-bdk-green"/></a>
-    <a href="https://blog.rust-lang.org/2021/12/02/Rust-1.57.0.html"><img alt="Rustc Version 1.57.0+" src="https://img.shields.io/badge/rustc-1.57.0%2B-lightgrey.svg"/></a>
+    <a href="https://blog.rust-lang.org/2022/08/11/Rust-1.63.0.html"><img alt="Rustc Version 1.63.0+" src="https://img.shields.io/badge/rustc-1.63.0%2B-lightgrey.svg"/></a>
     <a href="https://discord.gg/d7NkDKm"><img alt="Chat on Discord" src="https://img.shields.io/discord/753336465005608961?logo=discord"></a>
   </p>
 
@@ -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 (file)
index 0000000..e3b9960
--- /dev/null
@@ -0,0 +1 @@
+msrv="1.63.0"
\ No newline at end of file
index ce875b4d597d095baf1c32d34cdddbde1d706301..152ab246a82890cff666496eb4122bca73965835 100644 (file)
@@ -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(())
index 1e4e36fbe96cd6709e7c78163fd3b0e9302cd87b..97c04363ea006b0c3fb9887a17d180524c84adf8 100644 (file)
@@ -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
index ad7c9a534f05eb8b4e2620773d8b36f888a293ea..70e8eca30b5c205fa64ea492e199db78b5777f4a 100644 (file)
@@ -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::<HashSet<u32>>();
 
@@ -269,7 +269,7 @@ impl<'a, 'b, D: Database> TxCache<'a, 'b, D> {
     fn save_txs<'c>(&mut self, txids: impl Iterator<Item = &'c Txid>) -> 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<Transaction> {
-        self.cache.get(&txid).map(Clone::clone)
+        self.cache.get(&txid).cloned()
     }
 }
 
index e4c46999ca1adafbb0db7b264d7ebf6325036ac1..bb149c6b9ab3fd2770702e06d34253422219bfce 100644 (file)
@@ -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::<HashMap<_, _>>()
-        .into_iter()
-        .map(|(_, tx)| tx)
+        .into_values()
         .chain(coinbase_txs)
         .collect()
 }
index fd835300de62bbc3dade53a0aa64bc2a581560ea..ab5075d12fba28b02287611135e2a0cc32674ebd 100644 (file)
@@ -188,6 +188,7 @@ pub(crate) trait DatabaseUtils: Database {
             .map(|o| o.is_some())
     }
 
+    #[allow(unused)]
     fn get_raw_tx_or<D>(&self, txid: &Txid, default: D) -> Result<Option<Transaction>, Error>
     where
         D: FnOnce() -> Result<Option<Transaction>, Error>,
index 1ee43e306f757bd1781d9f90d12a2b82395697f5..dfb7bcc5f4e00c68483758ec94ec41e2e66118d6 100644 (file)
@@ -376,26 +376,26 @@ pub(crate) trait DescriptorMeta {
     fn is_witness(&self) -> bool;
     fn is_taproot(&self) -> bool;
     fn get_extended_keys(&self) -> Result<Vec<DescriptorXKey<ExtendedPubKey>>, DescriptorError>;
-    fn derive_from_hd_keypaths<'s>(
+    fn derive_from_hd_keypaths(
         &self,
         hd_keypaths: &HdKeyPaths,
-        secp: &'s SecpCtx,
+        secp: &SecpCtx,
     ) -> Option<DerivedDescriptor>;
-    fn derive_from_tap_key_origins<'s>(
+    fn derive_from_tap_key_origins(
         &self,
         tap_key_origins: &TapKeyOrigins,
-        secp: &'s SecpCtx,
+        secp: &SecpCtx,
     ) -> Option<DerivedDescriptor>;
-    fn derive_from_psbt_key_origins<'s>(
+    fn derive_from_psbt_key_origins(
         &self,
         key_origins: BTreeMap<Fingerprint, (&DerivationPath, SinglePubKey)>,
-        secp: &'s SecpCtx,
+        secp: &SecpCtx,
     ) -> Option<DerivedDescriptor>;
-    fn derive_from_psbt_input<'s>(
+    fn derive_from_psbt_input(
         &self,
         psbt_input: &psbt::Input,
         utxo: Option<TxOut>,
-        secp: &'s SecpCtx,
+        secp: &SecpCtx,
     ) -> Option<DerivedDescriptor>;
 }
 
@@ -430,10 +430,10 @@ impl DescriptorMeta for ExtendedDescriptor {
         Ok(answer)
     }
 
-    fn derive_from_psbt_key_origins<'s>(
+    fn derive_from_psbt_key_origins(
         &self,
         key_origins: BTreeMap<Fingerprint, (&DerivationPath, SinglePubKey)>,
-        secp: &'s SecpCtx,
+        secp: &SecpCtx,
     ) -> Option<DerivedDescriptor> {
         // Ensure that deriving `xpub` with `path` yields `expected`
         let verify_key = |xpub: &DescriptorXKey<ExtendedPubKey>,
@@ -520,10 +520,10 @@ impl DescriptorMeta for ExtendedDescriptor {
         })
     }
 
-    fn derive_from_hd_keypaths<'s>(
+    fn derive_from_hd_keypaths(
         &self,
         hd_keypaths: &HdKeyPaths,
-        secp: &'s SecpCtx,
+        secp: &SecpCtx,
     ) -> Option<DerivedDescriptor> {
         // "Convert" an hd_keypaths map to the format required by `derive_from_psbt_key_origins`
         let key_origins = hd_keypaths
@@ -538,10 +538,10 @@ impl DescriptorMeta for ExtendedDescriptor {
         self.derive_from_psbt_key_origins(key_origins, secp)
     }
 
-    fn derive_from_tap_key_origins<'s>(
+    fn derive_from_tap_key_origins(
         &self,
         tap_key_origins: &TapKeyOrigins,
-        secp: &'s SecpCtx,
+        secp: &SecpCtx,
     ) -> Option<DerivedDescriptor> {
         // "Convert" a tap_key_origins map to the format required by `derive_from_psbt_key_origins`
         let key_origins = tap_key_origins
@@ -551,11 +551,11 @@ impl DescriptorMeta for ExtendedDescriptor {
         self.derive_from_psbt_key_origins(key_origins, secp)
     }
 
-    fn derive_from_psbt_input<'s>(
+    fn derive_from_psbt_input(
         &self,
         psbt_input: &psbt::Input,
         utxo: Option<TxOut>,
-        secp: &'s SecpCtx,
+        secp: &SecpCtx,
     ) -> Option<DerivedDescriptor> {
         if let Some(derived) = self.derive_from_hd_keypaths(&psbt_input.bip32_derivation, secp) {
             return Some(derived);
index 338af696add6ca56e98e70b45efd697d64695bad..704a14a0b4124340e540c13166624f2594efb18e 100644 (file)
@@ -609,7 +609,7 @@ mod test {
 
         if let ExtendedDescriptor::Pkh(pkh) = xdesc.0 {
             let path: Vec<ChildNumber> = pkh.into_inner().full_derivation_path().unwrap().into();
-            let purpose = path.get(0).unwrap();
+            let purpose = path.first().unwrap();
             assert_matches!(purpose, Hardened { index: 44 });
             let coin_type = path.get(1).unwrap();
             assert_matches!(coin_type, Hardened { index: 0 });
@@ -623,7 +623,7 @@ mod test {
 
         if let ExtendedDescriptor::Pkh(pkh) = tdesc.0 {
             let path: Vec<ChildNumber> = pkh.into_inner().full_derivation_path().unwrap().into();
-            let purpose = path.get(0).unwrap();
+            let purpose = path.first().unwrap();
             assert_matches!(purpose, Hardened { index: 44 });
             let coin_type = path.get(1).unwrap();
             assert_matches!(coin_type, Hardened { index: 1 });
index d083f46710911799f167622341bdb77309f46fa0..ee81e8e85d2d2da36cffe8bfea36ee3faf549b5f 100644 (file)
@@ -752,7 +752,7 @@ fn expand_multi_keys<Pk: IntoDescriptorKey<Ctx>, Ctx: ScriptContext>(
     let (key_map, valid_networks) = key_maps_networks.into_iter().fold(
         (KeyMap::default(), any_network()),
         |(mut keys_acc, net_acc), (key, net)| {
-            keys_acc.extend(key.into_iter());
+            keys_acc.extend(key);
             let net_acc = merge_networks(&net_acc, &net);
 
             (keys_acc, net_acc)
index 084314552f40a9b4031ad38a5f565b7918ecbd09..93179932239a555cb9d5115e00dd406c4b1773dd 100644 (file)
@@ -206,15 +206,15 @@ extern crate serde_json;
 #[cfg(feature = "hardware-signer")]
 pub extern crate hwi;
 
-#[cfg(all(feature = "reqwest", feature = "ureq"))]
-compile_error!("Features reqwest and ureq are mutually exclusive and cannot be enabled together");
+#[cfg(all(feature = "use-esplora-async", feature = "use-esplora-blocking"))]
+compile_error!("Features use-esplora-async and use-esplora-blocking are mutually exclusive and cannot be enabled together");
 
 #[cfg(all(feature = "async-interface", feature = "electrum"))]
 compile_error!(
     "Features async-interface and electrum are mutually exclusive and cannot be enabled together"
 );
 
-#[cfg(all(feature = "async-interface", feature = "ureq"))]
+#[cfg(all(feature = "async-interface", feature = "use-esplora-blocking"))]
 compile_error!(
     "Features async-interface and ureq are mutually exclusive and cannot be enabled together"
 );
index 7ee259088cc39f64e1d915ddc3df7d970cab4379..8eaf3112170695461e044dd2f42d89f2cd1c6e77 100644 (file)
@@ -266,20 +266,18 @@ impl<D: Database> CoinSelectionAlgorithm<D> for OldestFirstCoinSelection {
             .iter()
             .map(|wu| wu.utxo.outpoint().txid)
             // fold is used so we can skip db query for txid that already exist in hashmap acc
-            .fold(Ok(HashMap::new()), |bh_result_acc, txid| {
-                bh_result_acc.and_then(|mut bh_acc| {
-                    if bh_acc.contains_key(&txid) {
-                        Ok(bh_acc)
-                    } else {
-                        database.get_tx(&txid, false).map(|details| {
-                            bh_acc.insert(
-                                txid,
-                                details.and_then(|d| d.confirmation_time.map(|ct| ct.height)),
-                            );
-                            bh_acc
-                        })
-                    }
-                })
+            .try_fold(HashMap::new(), |mut bh_acc, txid| {
+                if bh_acc.contains_key(&txid) {
+                    Ok(bh_acc)
+                } else {
+                    database.get_tx(&txid, false).map(|details| {
+                        bh_acc.insert(
+                            txid,
+                            details.and_then(|d| d.confirmation_time.map(|ct| ct.height)),
+                        );
+                        bh_acc
+                    })
+                }
             })?;
 
         // We put the "required UTXOs" first and make sure the optional UTXOs are sorted from
@@ -771,11 +769,7 @@ mod test {
     }
 
     fn get_test_utxos() -> Vec<WeightedUtxo> {
-        vec![
-            utxo(100_000, 0),
-            utxo(FEE_AMOUNT as u64 - 40, 1),
-            utxo(200_000, 2),
-        ]
+        vec![utxo(100_000, 0), utxo(FEE_AMOUNT - 40, 1), utxo(200_000, 2)]
     }
 
     fn setup_database_and_get_oldest_first_test_utxos<D: Database>(
@@ -890,7 +884,7 @@ mod test {
         let drain_script = ScriptBuf::default();
         let target_amount = 250_000 + FEE_AMOUNT;
 
-        let result = LargestFirstCoinSelection::default()
+        let result = LargestFirstCoinSelection
             .coin_select(
                 &database,
                 utxos,
@@ -913,7 +907,7 @@ mod test {
         let drain_script = ScriptBuf::default();
         let target_amount = 20_000 + FEE_AMOUNT;
 
-        let result = LargestFirstCoinSelection::default()
+        let result = LargestFirstCoinSelection
             .coin_select(
                 &database,
                 utxos,
@@ -936,7 +930,7 @@ mod test {
         let drain_script = ScriptBuf::default();
         let target_amount = 20_000 + FEE_AMOUNT;
 
-        let result = LargestFirstCoinSelection::default()
+        let result = LargestFirstCoinSelection
             .coin_select(
                 &database,
                 vec![],
@@ -960,7 +954,7 @@ mod test {
         let drain_script = ScriptBuf::default();
         let target_amount = 500_000 + FEE_AMOUNT;
 
-        LargestFirstCoinSelection::default()
+        LargestFirstCoinSelection
             .coin_select(
                 &database,
                 vec![],
@@ -980,7 +974,7 @@ mod test {
         let drain_script = ScriptBuf::default();
         let target_amount = 250_000 + FEE_AMOUNT;
 
-        LargestFirstCoinSelection::default()
+        LargestFirstCoinSelection
             .coin_select(
                 &database,
                 vec![],
@@ -999,7 +993,7 @@ mod test {
         let drain_script = ScriptBuf::default();
         let target_amount = 180_000 + FEE_AMOUNT;
 
-        let result = OldestFirstCoinSelection::default()
+        let result = OldestFirstCoinSelection
             .coin_select(
                 &database,
                 vec![],
@@ -1058,7 +1052,7 @@ mod test {
 
         let target_amount = 180_000 + FEE_AMOUNT;
 
-        let result = OldestFirstCoinSelection::default()
+        let result = OldestFirstCoinSelection
             .coin_select(
                 &database,
                 vec![],
@@ -1081,7 +1075,7 @@ mod test {
         let drain_script = ScriptBuf::default();
         let target_amount = 20_000 + FEE_AMOUNT;
 
-        let result = OldestFirstCoinSelection::default()
+        let result = OldestFirstCoinSelection
             .coin_select(
                 &database,
                 utxos,
@@ -1104,7 +1098,7 @@ mod test {
         let drain_script = ScriptBuf::default();
         let target_amount = 20_000 + FEE_AMOUNT;
 
-        let result = OldestFirstCoinSelection::default()
+        let result = OldestFirstCoinSelection
             .coin_select(
                 &database,
                 vec![],
@@ -1128,7 +1122,7 @@ mod test {
         let drain_script = ScriptBuf::default();
         let target_amount = 600_000 + FEE_AMOUNT;
 
-        OldestFirstCoinSelection::default()
+        OldestFirstCoinSelection
             .coin_select(
                 &database,
                 vec![],
@@ -1149,7 +1143,7 @@ mod test {
         let target_amount: u64 = utxos.iter().map(|wu| wu.utxo.txout().value).sum::<u64>() - 50;
         let drain_script = ScriptBuf::default();
 
-        OldestFirstCoinSelection::default()
+        OldestFirstCoinSelection
             .coin_select(
                 &database,
                 vec![],
index d7c68f7ed7872d6dedcd8ea01b23772ff793ea41..bd6595d79ee9517a9c5c9e0f015cab8efb1bee34 100644 (file)
@@ -59,6 +59,7 @@
 //! # Ok::<_, bdk::Error>(())
 //! ```
 
+use std::fmt::{Display, Formatter};
 use std::str::FromStr;
 
 use serde::{Deserialize, Serialize};
@@ -86,9 +87,9 @@ pub struct FullyNodedExport {
     pub label: String,
 }
 
-impl ToString for FullyNodedExport {
-    fn to_string(&self) -> String {
-        serde_json::to_string(self).unwrap()
+impl Display for FullyNodedExport {
+    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+        write!(f, "{}", serde_json::to_string(self).unwrap())
     }
 }
 
index 82feacecc87aee5e7b939bd043255cb23e3419cd..485cb9ce2d4d92fe83ed69e7a051382478a88974 100644 (file)
@@ -1851,7 +1851,7 @@ pub fn get_funded_wallet(
         .database
         .borrow_mut()
         .set_script_pubkey(
-            &bitcoin::Address::from_str(&tx_meta.output.get(0).unwrap().to_address)
+            &bitcoin::Address::from_str(&tx_meta.output.first().unwrap().to_address)
                 .unwrap()
                 .assume_checked()
                 .script_pubkey(),
@@ -5266,7 +5266,7 @@ pub(crate) mod test {
             .values()
             .map(|(script, version)| TapLeafHash::from_script(script, *version))
             .collect();
-        let included_script_leaves = vec![script_leaves.pop().unwrap()];
+        let included_script_leaves = [script_leaves.pop().unwrap()];
         let excluded_script_leaves = script_leaves;
 
         assert!(
index 6197040a245fe0aaa3d6365abebe277313487af9..4ecbc311253b89bc4bb1179a33a0457a221cb843 100644 (file)
@@ -805,9 +805,10 @@ pub struct SignOptions {
 }
 
 /// Customize which taproot script-path leaves the signer should sign.
-#[derive(Debug, Clone, PartialEq, Eq)]
+#[derive(Debug, Clone, PartialEq, Eq, Default)]
 pub enum TapLeavesOptions {
     /// The signer will sign all the leaves it has a key for.
+    #[default]
     All,
     /// The signer won't sign leaves other than the ones specified. Note that it could still ignore
     /// some of the specified leaves, if it doesn't have the right key to sign them.
@@ -818,12 +819,6 @@ pub enum TapLeavesOptions {
     None,
 }
 
-impl Default for TapLeavesOptions {
-    fn default() -> Self {
-        TapLeavesOptions::All
-    }
-}
-
 #[allow(clippy::derivable_impls)]
 impl Default for SignOptions {
     fn default() -> Self {
index b7eed0d4db0f4749ba5a5ee674646053fd3fe8f5..fff704072c3f0a76f46d5c70db58f92442485d23 100644 (file)
@@ -552,7 +552,7 @@ impl<'a, D: BatchDatabase, Cs: CoinSelectionAlgorithm<D>, Ctx: TxBuilderContext>
     ///
     /// This will be used to:
     /// 1. Set the nLockTime for preventing fee sniping.
-    /// **Note**: This will be ignored if you manually specify a nlocktime using [`TxBuilder::nlocktime`].
+    ///    **Note**: This will be ignored if you manually specify a nlocktime using [`TxBuilder::nlocktime`].
     /// 2. Decide whether coinbase outputs are mature or not. If the coinbase outputs are not
     ///    mature at `current_height`, we ignore them in the coin selection.
     ///    If you want to create a transaction that spends immature coinbase inputs, manually
@@ -680,9 +680,10 @@ impl<'a, D: BatchDatabase> TxBuilder<'a, D, DefaultCoinSelectionAlgorithm, BumpF
 }
 
 /// Ordering of the transaction's inputs and outputs
-#[derive(Debug, Ord, PartialOrd, Eq, PartialEq, Hash, Clone, Copy)]
+#[derive(Debug, Ord, PartialOrd, Eq, PartialEq, Hash, Clone, Copy, Default)]
 pub enum TxOrdering {
     /// Randomized (default)
+    #[default]
     Shuffle,
     /// Unchanged
     Untouched,
@@ -690,12 +691,6 @@ pub enum TxOrdering {
     Bip69Lexicographic,
 }
 
-impl Default for TxOrdering {
-    fn default() -> Self {
-        TxOrdering::Shuffle
-    }
-}
-
 impl TxOrdering {
     /// Sort transaction inputs and outputs by [`TxOrdering`] variant
     pub fn sort_tx(&self, tx: &mut Transaction) {
@@ -755,9 +750,10 @@ impl RbfValue {
 }
 
 /// Policy regarding the use of change outputs when creating a transaction
-#[derive(Debug, Ord, PartialOrd, Eq, PartialEq, Hash, Clone, Copy)]
+#[derive(Debug, Ord, PartialOrd, Eq, PartialEq, Hash, Clone, Copy, Default)]
 pub enum ChangeSpendPolicy {
     /// Use both change and non-change outputs (default)
+    #[default]
     ChangeAllowed,
     /// Only use change outputs (see [`TxBuilder::only_spend_change`])
     OnlyChange,
@@ -765,12 +761,6 @@ pub enum ChangeSpendPolicy {
     ChangeForbidden,
 }
 
-impl Default for ChangeSpendPolicy {
-    fn default() -> Self {
-        ChangeSpendPolicy::ChangeAllowed
-    }
-}
-
 impl ChangeSpendPolicy {
     pub(crate) fn is_satisfied_by(&self, utxo: &LocalUtxo) -> bool {
         match self {