Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/cont_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,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/tdk_wallet"><img alt="Wallet API Docs" src="https://img.shields.io/badge/docs.rs-tdk_wallet-green"/></a>
<a href="https://blog.rust-lang.org/2025/02/20/Rust-1.85.0.html"><img alt="Rustc Version 1.85.0+" src="https://img.shields.io/badge/rustc-1.85.0%2B-lightgrey.svg"/></a>
<a href="https://blog.rust-lang.org/2025/02/20/Rust-1.88.0.html"><img alt="Rustc Version 1.88.0+" src="https://img.shields.io/badge/rustc-1.88.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>

Expand Down Expand Up @@ -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:

Expand Down
6 changes: 3 additions & 3 deletions crates/electrum/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions crates/electrum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
38 changes: 15 additions & 23 deletions crates/electrum/tests/test_electrum.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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::<ConfirmationTimeHeightAnchor, _>::new({
let mut recv_index = SpkTxOutIndex::default();
recv_index.insert_spk((), spk_to_track.clone());
Expand Down Expand Up @@ -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")
Expand All @@ -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::<ConfirmationTimeHeightAnchor, _>::new({
let mut recv_index = SpkTxOutIndex::default();
recv_index.insert_spk((), spk_to_track.clone());
Expand Down
2 changes: 1 addition & 1 deletion crates/testenv/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
4 changes: 2 additions & 2 deletions crates/wallet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion example-crates/example_electrum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
8 changes: 4 additions & 4 deletions example-crates/example_electrum/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion example-crates/wallet_electrum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 2 additions & 2 deletions example-crates/wallet_electrum/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading