diff --git a/.github/workflows/cont_integration.yml b/.github/workflows/cont_integration.yml index 56167ef8..7d2f2957 100644 --- a/.github/workflows/cont_integration.yml +++ b/.github/workflows/cont_integration.yml @@ -15,7 +15,7 @@ jobs: rust: - version: stable clippy: true - - version: 1.85.0 # MSRV + - version: 1.88.0 # MSRV features: - --no-default-features --features tapyrus/no-std,miniscript/no-std,hashbrown,blocking,async - --all-features --features miniscript/std @@ -31,7 +31,7 @@ jobs: - name: Rust Cache uses: Swatinem/rust-cache@v2.2.1 - name: Pin dependencies for MSRV - if: matrix.rust.version == '1.85.0' + if: matrix.rust.version == '1.88.0' run: | cargo update -p home --precise "0.5.11" - name: Build @@ -122,7 +122,7 @@ jobs: - uses: actions/checkout@v1 - uses: actions-rs/toolchain@v1 with: - toolchain: 1.85.0 + toolchain: 1.88.0 components: clippy override: true - name: Rust Cache diff --git a/README.md b/README.md index d96ffcf0..33d5f8c4 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ CI Status Wallet API Docs - Rustc Version 1.85.0+ + Rustc Version 1.88.0+ Chat on Discord

@@ -63,7 +63,7 @@ Fully working examples of how to use these components are in `/example-crates`: [`tdk_chain`]: https://docs.rs/bdk-chain/ ## Minimum Supported Rust Version (MSRV) -This library should compile with any combination of features with Rust 1.85.0. +This library should compile with any combination of features with Rust 1.88.0. To build with the MSRV you will need to pin dependencies as follows: diff --git a/crates/chain/src/keychain/txout_index.rs b/crates/chain/src/keychain/txout_index.rs index e6151067..9d1b00d8 100644 --- a/crates/chain/src/keychain/txout_index.rs +++ b/crates/chain/src/keychain/txout_index.rs @@ -579,7 +579,7 @@ impl KeychainTxOutIndex { next_store_index..next_reveal_index + lookahead, ) { let _inserted = self.inner.insert_spk((descriptor_id, new_index), new_spk); - debug_assert!(_inserted, "replenish lookahead: must not have existing spk: keychain={:?}, lookahead={}, next_store_index={}, next_reveal_index={}", keychain, lookahead, next_store_index, next_reveal_index); + debug_assert!(_inserted, "replenish lookahead: must not have existing spk: keychain={keychain:?}, lookahead={lookahead}, next_store_index={next_store_index}, next_reveal_index={next_reveal_index}"); } } } diff --git a/crates/chain/src/tx_graph.rs b/crates/chain/src/tx_graph.rs index b8380341..e00aa286 100644 --- a/crates/chain/src/tx_graph.rs +++ b/crates/chain/src/tx_graph.rs @@ -192,8 +192,7 @@ impl fmt::Display for CalculateFeeError { match self { CalculateFeeError::MissingTxOut(outpoints) => write!( f, - "missing `TxOut` for one or more of the inputs of the tx: {:?}", - outpoints + "missing `TxOut` for one or more of the inputs of the tx: {outpoints:?}" ), CalculateFeeError::NegativeFee(fee) => write!( f, @@ -388,7 +387,7 @@ impl TxGraph { /// The supplied closure takes in two inputs `(depth, ancestor_tx)`: /// /// * `depth` is the distance between the starting `Transaction` and the `ancestor_tx`. I.e., if - /// the `Transaction` is spending an output of the `ancestor_tx` then `depth` will be 1. + /// the `Transaction` is spending an output of the `ancestor_tx` then `depth` will be 1. /// * `ancestor_tx` is the `Transaction`'s ancestor which we are considering to walk. /// /// The supplied closure returns an `Option`, allowing the caller to map each `Transaction` @@ -406,7 +405,7 @@ impl TxGraph { /// The supplied closure takes in two inputs `(depth, descendant_txid)`: /// /// * `depth` is the distance between the starting `txid` and the `descendant_txid`. I.e., if the - /// descendant is spending an output of the starting `txid` then `depth` will be 1. + /// descendant is spending an output of the starting `txid` then `depth` will be 1. /// * `descendant_txid` is the descendant's txid which we are considering to walk. /// /// The supplied closure returns an `Option`, allowing the caller to map each node it visits diff --git a/crates/chain/tests/test_indexed_tx_graph.rs b/crates/chain/tests/test_indexed_tx_graph.rs index c80e451b..56601996 100644 --- a/crates/chain/tests/test_indexed_tx_graph.rs +++ b/crates/chain/tests/test_indexed_tx_graph.rs @@ -255,7 +255,7 @@ fn test_list_owned_txouts() { let chain_tip = local_chain .get(height) .map(|cp| cp.block_id()) - .unwrap_or_else(|| panic!("block must exist at {}", height)); + .unwrap_or_else(|| panic!("block must exist at {height}")); let txouts = graph .graph() .filter_chain_txouts(&local_chain, chain_tip, graph.index.outpoints()) diff --git a/crates/chain/tests/test_local_chain.rs b/crates/chain/tests/test_local_chain.rs index 64f32f4a..8bd88f20 100644 --- a/crates/chain/tests/test_local_chain.rs +++ b/crates/chain/tests/test_local_chain.rs @@ -375,10 +375,9 @@ fn local_chain_insert_block() { assert_eq!( chain.insert_block(t.insert.into()), t.expected_result, - "[{}] unexpected result when inserting block", - i, + "[{i}] unexpected result when inserting block", ); - assert_eq!(chain, t.expected_final, "[{}] unexpected final chain", i,); + assert_eq!(chain, t.expected_final, "[{i}] unexpected final chain",); } } diff --git a/crates/chain/tests/test_tx_graph.rs b/crates/chain/tests/test_tx_graph.rs index b29cb84a..275d5cef 100644 --- a/crates/chain/tests/test_tx_graph.rs +++ b/crates/chain/tests/test_tx_graph.rs @@ -535,7 +535,7 @@ fn test_calculate_fee_on_coinbase() { fn test_walk_ancestors() { let local_chain = LocalChain::from_blocks( (0..=20) - .map(|ht| (ht, BlockHash::hash(format!("Block Hash {}", ht).as_bytes()))) + .map(|ht| (ht, BlockHash::hash(format!("Block Hash {ht}").as_bytes()))) .collect(), ) .expect("must contain genesis hash"); @@ -872,7 +872,7 @@ fn test_descendants_no_repeat() { fn test_chain_spends() { let local_chain = LocalChain::from_blocks( (0..=100) - .map(|ht| (ht, BlockHash::hash(format!("Block Hash {}", ht).as_bytes()))) + .map(|ht| (ht, BlockHash::hash(format!("Block Hash {ht}").as_bytes()))) .collect(), ) .expect("must have genesis hash"); diff --git a/crates/electrum/Cargo.toml b/crates/electrum/Cargo.toml index 1b962389..6a4f07f8 100644 --- a/crates/electrum/Cargo.toml +++ b/crates/electrum/Cargo.toml @@ -1,10 +1,10 @@ [package] -name = "bdk_electrum" +name = "tdk_electrum" version = "0.14.0" edition = "2021" homepage = "https://bitcoindevkit.org" repository = "https://github.com/bitcoindevkit/bdk" -documentation = "https://docs.rs/bdk_electrum" +documentation = "https://docs.rs/tdk_electrum" description = "Fetch data from electrum in the form BDK accepts" license = "MIT OR Apache-2.0" readme = "README.md" @@ -13,7 +13,7 @@ readme = "README.md" [dependencies] tdk_chain = { path = "../chain", version = "0.15.0" } -electrum-client = { version = "0.19" } +electrum-client = { git = "https://github.com/chaintope/rust-electrum-client", branch = "work_on_tapyrus" } #rustls = { version = "=0.21.1", optional = true, features = ["dangerous_configuration"] } [dev-dependencies] diff --git a/crates/electrum/src/lib.rs b/crates/electrum/src/lib.rs index 6209ff12..32fd995e 100644 --- a/crates/electrum/src/lib.rs +++ b/crates/electrum/src/lib.rs @@ -15,8 +15,8 @@ #![warn(missing_docs)] -mod bdk_electrum_client; -pub use bdk_electrum_client::*; +mod tdk_electrum_client; +pub use tdk_electrum_client::*; pub use electrum_client; pub use tdk_chain; diff --git a/crates/electrum/src/bdk_electrum_client.rs b/crates/electrum/src/tdk_electrum_client.rs similarity index 99% rename from crates/electrum/src/bdk_electrum_client.rs rename to crates/electrum/src/tdk_electrum_client.rs index 53735518..5ef153d5 100644 --- a/crates/electrum/src/bdk_electrum_client.rs +++ b/crates/electrum/src/tdk_electrum_client.rs @@ -2,10 +2,10 @@ use core::str::FromStr; use electrum_client::{ElectrumApi, Error, HeaderNotification}; use std::sync::{Arc, Mutex}; use tdk_chain::{ - bitcoin::{MalFixTxid, OutPoint, ScriptBuf, Transaction}, collections::{BTreeMap, HashMap, HashSet}, local_chain::CheckPoint, spk_client::{FullScanRequest, FullScanResult, SyncRequest, SyncResult}, + tapyrus::{MalFixTxid, OutPoint, ScriptBuf, Transaction}, tx_graph::TxGraph, BlockId, ConfirmationHeightAnchor, ConfirmationTimeHeightAnchor, }; diff --git a/crates/electrum/tests/test_electrum.rs b/crates/electrum/tests/test_electrum.rs index 241855d5..d41a4a4c 100644 --- a/crates/electrum/tests/test_electrum.rs +++ b/crates/electrum/tests/test_electrum.rs @@ -1,13 +1,13 @@ -use bdk_electrum::BdkElectrumClient; use tdk_chain::{ - bitcoin::{hashes::Hash, Address, Amount, ScriptBuf, WScriptHash}, keychain::Balance, local_chain::LocalChain, spk_client::SyncRequest, tapyrus::script::color_identifier::ColorIdentifier, + tapyrus::{hashes::Hash, Address, Amount, ScriptBuf, ScriptHash}, ConfirmationTimeHeightAnchor, IndexedTxGraph, SpkTxOutIndex, }; -use tdk_testenv::{anyhow, bitcoincore_rpc::RpcApi, TestEnv}; +use tdk_electrum::BdkElectrumClient; +use tdk_testenv::{anyhow, tapyruscore_rpc::RpcApi, TestEnv}; fn get_balance( recv_chain: &LocalChain, @@ -31,23 +31,19 @@ fn get_balance( /// 4. Check [`Balance`] to ensure tx is confirmed. #[test] fn scan_detects_confirmed_tx() -> anyhow::Result<()> { - const SEND_AMOUNT: Amount = Amount::from_sat(10_000); + const SEND_AMOUNT: Amount = Amount::from_tap(10_000); let env = TestEnv::new()?; let electrum_client = electrum_client::Client::new(env.electrsd.electrum_url.as_str())?; let client = BdkElectrumClient::new(electrum_client); // Setup addresses. - let addr_to_mine = env - .bitcoind - .client - .get_new_address(None, None)? - .assume_checked(); - let spk_to_track = ScriptBuf::new_p2wsh(&WScriptHash::all_zeros()); - let addr_to_track = Address::from_script(&spk_to_track, tdk_chain::bitcoin::Network::Regtest)?; + let addr_to_mine = env.tapyrusd.client.get_new_address(None)?.assume_checked(); + let spk_to_track = ScriptBuf::new_p2sh(&ScriptHash::all_zeros()); + let addr_to_track = Address::from_script(&spk_to_track, tdk_chain::tapyrus::Network::Dev)?; // Setup receiver. - let (mut recv_chain, _) = LocalChain::from_genesis_hash(env.bitcoind.client.get_block_hash(0)?); + let (mut recv_chain, _) = LocalChain::from_genesis_hash(env.tapyrusd.client.get_block_hash(0)?); let mut recv_graph = IndexedTxGraph::::new({ let mut recv_index = SpkTxOutIndex::default(); recv_index.insert_spk((), spk_to_track.clone()); @@ -96,9 +92,9 @@ fn scan_detects_confirmed_tx() -> anyhow::Result<()> { .calculate_fee(&tx.tx) .expect("fee must exist"); - // Retrieve the fee in the transaction data from `bitcoind`. + // Retrieve the fee in the transaction data from `tapyrusd`. let tx_fee = env - .bitcoind + .tapyrusd .client .get_transaction(&tx.txid, None) .expect("Tx must exist") @@ -124,23 +120,19 @@ fn scan_detects_confirmed_tx() -> anyhow::Result<()> { #[test] fn tx_can_become_unconfirmed_after_reorg() -> anyhow::Result<()> { const REORG_COUNT: usize = 8; - const SEND_AMOUNT: Amount = Amount::from_sat(10_000); + const SEND_AMOUNT: Amount = Amount::from_tap(10_000); let env = TestEnv::new()?; let electrum_client = electrum_client::Client::new(env.electrsd.electrum_url.as_str())?; let client = BdkElectrumClient::new(electrum_client); // Setup addresses. - let addr_to_mine = env - .bitcoind - .client - .get_new_address(None, None)? - .assume_checked(); - let spk_to_track = ScriptBuf::new_p2wsh(&WScriptHash::all_zeros()); - let addr_to_track = Address::from_script(&spk_to_track, tdk_chain::bitcoin::Network::Regtest)?; + let addr_to_mine = env.tapyrusd.client.get_new_address(None)?.assume_checked(); + let spk_to_track = ScriptBuf::new_p2sh(&ScriptHash::all_zeros()); + let addr_to_track = Address::from_script(&spk_to_track, tdk_chain::tapyrus::Network::Dev)?; // Setup receiver. - let (mut recv_chain, _) = LocalChain::from_genesis_hash(env.bitcoind.client.get_block_hash(0)?); + let (mut recv_chain, _) = LocalChain::from_genesis_hash(env.tapyrusd.client.get_block_hash(0)?); let mut recv_graph = IndexedTxGraph::::new({ let mut recv_index = SpkTxOutIndex::default(); recv_index.insert_spk((), spk_to_track.clone()); diff --git a/crates/testenv/README.md b/crates/testenv/README.md index ab300675..6ef9b407 100644 --- a/crates/testenv/README.md +++ b/crates/testenv/README.md @@ -2,5 +2,5 @@ This crate sets up a regtest environment with a single [`bitcoind`] node connected to an [`electrs`] instance. This framework provides the infrastructure -for testing chain source crates, e.g., [`tdk_chain`], [`bdk_electrum`], +for testing chain source crates, e.g., [`tdk_chain`], [`tdk_electrum`], [`tdk_esplora`], etc. \ No newline at end of file diff --git a/crates/wallet/README.md b/crates/wallet/README.md index 61d64dea..f260e758 100644 --- a/crates/wallet/README.md +++ b/crates/wallet/README.md @@ -45,7 +45,7 @@ that the `Wallet` can use to update its view of the chain. **Blockchain Data Sources** * [`tdk_esplora`]: Grabs blockchain data from Esplora for updating BDK structures. -* [`bdk_electrum`]: Grabs blockchain data from Electrum for updating BDK structures. +* [`tdk_electrum`]: Grabs blockchain data from Electrum for updating BDK structures. * [`bdk_bitcoind_rpc`]: Grabs blockchain data from Bitcoin Core for updating BDK structures. **Examples** @@ -223,7 +223,7 @@ conditions. [`PersistBackend`]: https://docs.rs/tdk_chain/latest/tdk_chain/trait.PersistBackend.html [`tdk_chain`]: https://docs.rs/tdk_chain/latest [`tdk_file_store`]: https://docs.rs/tdk_file_store/latest -[`bdk_electrum`]: https://docs.rs/bdk_electrum/latest +[`tdk_electrum`]: https://docs.rs/tdk_electrum/latest [`bdk_esplora`]: https://docs.rs/bdk_esplora/latest [`bdk_bitcoind_rpc`]: https://docs.rs/bdk_bitcoind_rpc/latest [`rust-miniscript`]: https://docs.rs/miniscript/latest/miniscript/index.html diff --git a/example-crates/example_electrum/Cargo.toml b/example-crates/example_electrum/Cargo.toml index b189bd5b..2ef331d2 100644 --- a/example-crates/example_electrum/Cargo.toml +++ b/example-crates/example_electrum/Cargo.toml @@ -7,5 +7,5 @@ edition = "2021" [dependencies] tdk_chain = { path = "../../crates/chain", features = ["serde"] } -bdk_electrum = { path = "../../crates/electrum" } +tdk_electrum = { path = "../../crates/electrum" } example_cli = { path = "../example_cli" } diff --git a/example-crates/example_electrum/src/main.rs b/example-crates/example_electrum/src/main.rs index 9e8c79aa..8dace5ab 100644 --- a/example-crates/example_electrum/src/main.rs +++ b/example-crates/example_electrum/src/main.rs @@ -3,10 +3,6 @@ use std::{ sync::Mutex, }; -use bdk_electrum::{ - electrum_client::{self, Client, ElectrumApi}, - BdkElectrumClient, -}; use example_cli::{ anyhow::{self, Context}, clap::{self, Parser, Subcommand}, @@ -21,6 +17,10 @@ use tdk_chain::{ spk_client::{FullScanRequest, SyncRequest}, Append, ConfirmationHeightAnchor, }; +use tdk_electrum::{ + electrum_client::{self, Client, ElectrumApi}, + BdkElectrumClient, +}; const DB_MAGIC: &[u8] = b"bdk_example_electrum"; const DB_PATH: &str = ".bdk_example_electrum.db"; diff --git a/example-crates/wallet_electrum/Cargo.toml b/example-crates/wallet_electrum/Cargo.toml index 760e77bd..c7f99c43 100644 --- a/example-crates/wallet_electrum/Cargo.toml +++ b/example-crates/wallet_electrum/Cargo.toml @@ -5,6 +5,6 @@ edition = "2021" [dependencies] tdk_wallet = { path = "../../crates/wallet" } -bdk_electrum = { path = "../../crates/electrum" } +tdk_electrum = { path = "../../crates/electrum" } tdk_file_store = { path = "../../crates/file_store" } anyhow = "1" diff --git a/example-crates/wallet_electrum/src/main.rs b/example-crates/wallet_electrum/src/main.rs index 2a8ecc82..409bac11 100644 --- a/example-crates/wallet_electrum/src/main.rs +++ b/example-crates/wallet_electrum/src/main.rs @@ -6,8 +6,8 @@ const BATCH_SIZE: usize = 5; use std::io::Write; use std::str::FromStr; -use bdk_electrum::electrum_client; -use bdk_electrum::BdkElectrumClient; +use tdk_electrum::electrum_client; +use tdk_electrum::BdkElectrumClient; use tdk_file_store::Store; use tdk_wallet::bitcoin::{Address, Amount}; use tdk_wallet::chain::collections::HashSet;