diff --git a/clippy.toml b/clippy.toml index fec36d9d..e3b99604 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1,2 +1 @@ -msrv="1.63.0" -type-complexity-threshold = 275 +msrv="1.63.0" \ No newline at end of file diff --git a/crates/chain/src/keychain/txout_index.rs b/crates/chain/src/keychain/txout_index.rs index 846b6c24..6d0b7623 100644 --- a/crates/chain/src/keychain/txout_index.rs +++ b/crates/chain/src/keychain/txout_index.rs @@ -3,10 +3,10 @@ use crate::{ indexed_tx_graph::Indexer, miniscript::{Descriptor, DescriptorPublicKey}, spk_iter::BIP32_MAX_INDEX, - DescriptorExt, DescriptorId, SpkIterator, SpkTxOutIndex, + DescriptorExt, DescriptorId, IndexSpk, SpkIterator, SpkTxOutIndex, }; use alloc::{borrow::ToOwned, vec::Vec}; -use bitcoin::{Amount, OutPoint, Script, ScriptBuf, SignedAmount, Transaction, TxOut, Txid}; +use bitcoin::{Amount, OutPoint, Script, SignedAmount, Transaction, TxOut, Txid}; use core::{ fmt::Debug, ops::{Bound, RangeBounds}, @@ -739,9 +739,9 @@ impl KeychainTxOutIndex { &mut self, keychain: &K, target_index: u32, - ) -> Option<(Vec<(u32, ScriptBuf)>, ChangeSet)> { + ) -> Option<(Vec, ChangeSet)> { let mut changeset = ChangeSet::default(); - let mut spks: Vec<(u32, ScriptBuf)> = vec![]; + let mut spks: Vec = vec![]; while let Some((i, new)) = self.next_index(keychain) { if !new || i > target_index { break; diff --git a/crates/chain/src/spk_client.rs b/crates/chain/src/spk_client.rs index d65ecdba..cf78e7bd 100644 --- a/crates/chain/src/spk_client.rs +++ b/crates/chain/src/spk_client.rs @@ -1,7 +1,7 @@ //! Helper types for spk-based blockchain clients. use crate::{ - collections::BTreeMap, local_chain::CheckPoint, ConfirmationTimeHeightAnchor, TxGraph, + collections::BTreeMap, local_chain::CheckPoint, ConfirmationTimeHeightAnchor, IndexSpk, TxGraph, }; use alloc::{boxed::Box, vec::Vec}; use bitcoin::{OutPoint, Script, ScriptBuf, Txid}; @@ -195,7 +195,7 @@ pub struct FullScanRequest { /// [`LocalChain::tip`]: crate::local_chain::LocalChain::tip pub chain_tip: CheckPoint, /// Iterators of script pubkeys indexed by the keychain index. - pub spks_by_keychain: BTreeMap + Send>>, + pub spks_by_keychain: BTreeMap + Send>>, } impl FullScanRequest { @@ -238,7 +238,7 @@ impl FullScanRequest { pub fn set_spks_for_keychain( mut self, keychain: K, - spks: impl IntoIterator + Send + 'static>, + spks: impl IntoIterator + Send + 'static>, ) -> Self { self.spks_by_keychain .insert(keychain, Box::new(spks.into_iter())); @@ -252,7 +252,7 @@ impl FullScanRequest { pub fn chain_spks_for_keychain( mut self, keychain: K, - spks: impl IntoIterator + Send + 'static>, + spks: impl IntoIterator + Send + 'static>, ) -> Self { match self.spks_by_keychain.remove(&keychain) { // clippy here suggests to remove `into_iter` from `spks.into_iter()`, but doing so diff --git a/crates/chain/src/spk_iter.rs b/crates/chain/src/spk_iter.rs index 91c271c7..8285036b 100644 --- a/crates/chain/src/spk_iter.rs +++ b/crates/chain/src/spk_iter.rs @@ -7,6 +7,9 @@ use core::{borrow::Borrow, ops::Bound, ops::RangeBounds}; /// Maximum [BIP32](https://bips.xyz/32) derivation index. pub const BIP32_MAX_INDEX: u32 = (1 << 31) - 1; +/// A tuple of keychain index and corresponding [`ScriptBuf`]. +pub type IndexSpk = (u32, ScriptBuf); + /// An iterator for derived script pubkeys. /// /// [`SpkIterator`] is an implementation of the [`Iterator`] trait which possesses its own `next()` @@ -97,7 +100,7 @@ impl Iterator for SpkIterator where D: Borrow>, { - type Item = (u32, ScriptBuf); + type Item = IndexSpk; fn next(&mut self) -> Option { // For non-wildcard descriptors, we expect the first element to be Some((0, spk)), then None after. diff --git a/crates/esplora/src/async_ext.rs b/crates/esplora/src/async_ext.rs index 304dedb3..a7dbc24f 100644 --- a/crates/esplora/src/async_ext.rs +++ b/crates/esplora/src/async_ext.rs @@ -2,13 +2,13 @@ use std::collections::BTreeSet; use async_trait::async_trait; use bdk_chain::spk_client::{FullScanRequest, FullScanResult, SyncRequest, SyncResult}; -use bdk_chain::Anchor; use bdk_chain::{ bitcoin::{BlockHash, OutPoint, ScriptBuf, TxOut, Txid}, collections::BTreeMap, local_chain::CheckPoint, BlockId, ConfirmationTimeHeightAnchor, TxGraph, }; +use bdk_chain::{Anchor, IndexSpk}; use esplora_client::{Amount, TxStatus}; use futures::{stream::FuturesOrdered, TryStreamExt}; @@ -236,7 +236,7 @@ async fn full_scan_for_index_and_graph( client: &esplora_client::AsyncClient, keychain_spks: BTreeMap< K, - impl IntoIterator + Send> + Send, + impl IntoIterator + Send> + Send, >, stop_gap: usize, parallel_requests: usize, diff --git a/crates/esplora/src/blocking_ext.rs b/crates/esplora/src/blocking_ext.rs index 09ad9c0a..0b173c3a 100644 --- a/crates/esplora/src/blocking_ext.rs +++ b/crates/esplora/src/blocking_ext.rs @@ -4,12 +4,12 @@ use std::usize; use bdk_chain::collections::BTreeMap; use bdk_chain::spk_client::{FullScanRequest, FullScanResult, SyncRequest, SyncResult}; -use bdk_chain::Anchor; use bdk_chain::{ bitcoin::{Amount, BlockHash, OutPoint, ScriptBuf, TxOut, Txid}, local_chain::CheckPoint, BlockId, ConfirmationTimeHeightAnchor, TxGraph, }; +use bdk_chain::{Anchor, IndexSpk}; use esplora_client::TxStatus; use crate::anchor_from_status; @@ -217,7 +217,7 @@ fn chain_update( /// [`KeychainTxOutIndex`](bdk_chain::keychain::KeychainTxOutIndex). fn full_scan_for_index_and_graph_blocking( client: &esplora_client::BlockingClient, - keychain_spks: BTreeMap>, + keychain_spks: BTreeMap>, stop_gap: usize, parallel_requests: usize, ) -> Result<(TxGraph, BTreeMap), Error> { diff --git a/crates/wallet/src/wallet/mod.rs b/crates/wallet/src/wallet/mod.rs index de7f19b0..18498412 100644 --- a/crates/wallet/src/wallet/mod.rs +++ b/crates/wallet/src/wallet/mod.rs @@ -29,7 +29,7 @@ use bdk_chain::{ spk_client::{FullScanRequest, FullScanResult, SyncRequest, SyncResult}, tx_graph::{CanonicalTx, TxGraph}, Append, BlockId, ChainPosition, ConfirmationTime, ConfirmationTimeHeightAnchor, FullTxOut, - IndexedTxGraph, + IndexSpk, IndexedTxGraph, }; use bdk_persist::{Persist, PersistBackend}; use bitcoin::secp256k1::{All, Secp256k1}; @@ -910,7 +910,7 @@ impl Wallet { /// script pubkeys the wallet is storing internally). pub fn all_unbounded_spk_iters( &self, - ) -> BTreeMap + Clone> { + ) -> BTreeMap + Clone> { self.indexed_graph.index.all_unbounded_spk_iters() } @@ -922,7 +922,7 @@ impl Wallet { pub fn unbounded_spk_iter( &self, keychain: KeychainKind, - ) -> impl Iterator + Clone { + ) -> impl Iterator + Clone { self.indexed_graph .index .unbounded_spk_iter(&keychain)