Skip to content

Commit 884bc09

Browse files
authored
Merge pull request #110 from sdmg15/feat/cbf-data-source
feat: integrate compact block filter
2 parents df52878 + 7f8f97c commit 884bc09

9 files changed

Lines changed: 338 additions & 16 deletions

File tree

Cargo.lock

Lines changed: 89 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ bdk_electrum = { version = "0.23.2", default-features = false, features = ["use-
1010
rustls = { version = "0.23.35", default-features = false, features = ["ring", "std", "tls12", "logging"] }
1111
# v2.2.0 deprecates `bdk_wallet::wallet::signer` without making it clear what alternative to use & how:
1212
bdk_wallet = { version = "~2.1.0", features = ["rusqlite", "keys-bip39"] }
13+
bdk_kyoto = "0.15.3"
1314
const_format = "0.2.35"
1415
rusqlite = { version = "0.31.0", features = ["bundled-sqlcipher"] }
1516

@@ -23,6 +24,8 @@ base64 = "0.22.1"
2324
hex = "0.4"
2425
zeroize = "1.8.1"
2526
argon2 = { version = "0.5.3", default-features = false }
27+
tracing = "0.1"
28+
tracing-subscriber = "0.3"
2629

2730
[workspace.lints.rust]
2831
rust-2024-compatibility = "warn"

testenv/src/lib.rs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
1+
use std::net::SocketAddrV4;
2+
use std::sync::Arc;
3+
use std::time::Duration;
4+
15
/// Bitcoin regtest environment using electrsd with automatic executable downloads
26
use anyhow::{Context, Result};
37
use bdk_electrum::bdk_core::bitcoin::{KnownHrp, XOnlyPublicKey};
48
use bdk_electrum::BdkElectrumClient;
5-
6-
9+
use bdk_wallet::bitcoin::address::NetworkChecked;
710
use bdk_wallet::bitcoin::key::Secp256k1;
811
use bdk_wallet::bitcoin::secp256k1::All;
9-
use bdk_wallet::bitcoin::{address::NetworkChecked, Address, Amount, BlockHash, Network, Transaction, Txid};
12+
use bdk_wallet::bitcoin::{Address, Amount, BlockHash, Network, Transaction, Txid};
1013
use corepc_node::get_available_port;
11-
use electrsd::corepc_node;
12-
use electrsd::electrum_client::Client;
13-
use electrsd::{corepc_node::Node, electrum_client::ElectrumApi, ElectrsD};
14+
use electrsd::corepc_node::Node;
15+
use electrsd::electrum_client::{Client, ElectrumApi};
16+
use electrsd::{corepc_node, ElectrsD};
1417
use hmac::{Hmac, Mac};
1518
use rand::{Rng, RngCore};
1619
use secp::Scalar;
1720
use sha2::Sha256;
1821
use simple_semaphore::{Permit, Semaphore};
19-
use std::sync::Arc;
20-
use std::time::Duration;
2122
use tempfile::{tempdir, TempDir};
2223

2324

@@ -54,6 +55,7 @@ impl Default for Config<'_> {
5455
let mut conf = corepc_node::Conf::default();
5556
// Listen on all interfaces (0.0.0.0) instead of just localhost
5657
conf.args.push("-rpcbind=0.0.0.0");
58+
conf.args.push("-listen=1");
5759

5860
// Allow connections from any IP (use 0.0.0.0/0 for "everywhere")
5961
conf.args.push("-rpcallowip=0.0.0.0/0");
@@ -173,6 +175,7 @@ impl TestEnv {
173175

174176
let auth_config = format!("-{}", rpc_auth);
175177
let mut bitcoin_config = config.bitcoind.clone();
178+
bitcoin_config.p2p = corepc_node::P2P::Yes;
176179
bitcoin_config.args.push(&*auth_config);
177180

178181
let bitcoind = match std::env::var("BITCOIND_EXEC") {
@@ -243,7 +246,7 @@ impl TestEnv {
243246
let bitcoind_rpc_port = self.bitcoind.params.rpc_socket.port();
244247
let browserport = get_available_port()?;
245248

246-
let electrum_port = self.electrsd.electrum_url.split(':').last()
249+
let electrum_port = self.electrsd.electrum_url.split(':').next_back()
247250
.context("Failed to parse electrum port")?;
248251

249252
let container_name = format!("btc-explorer-{}", browserport);
@@ -439,6 +442,11 @@ impl TestEnv {
439442
pub fn workdir(&self) -> std::path::PathBuf {
440443
self.electrsd.workdir()
441444
}
445+
446+
/// Get the running bitcoind socket address
447+
pub fn p2p_socket_addr(&self) -> Option<SocketAddrV4> {
448+
self.bitcoind.params.p2p_socket
449+
}
442450
}
443451

444452
impl Drop for TestEnv {

wallet/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ hex = { workspace = true }
1616
base64 = { workspace = true }
1717
zeroize = { workspace = true }
1818
rustls = { workspace = true }
19-
19+
bdk_kyoto = { workspace = true }
20+
tracing = { workspace = true }
21+
tracing-subscriber = { workspace = true }
2022
[dev-dependencies]
2123
tempfile = "3.23.0"
2224
bdk_wallet = { workspace = true , features = ["test-utils"]}

wallet/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ It currently provides the following features:
66

77
- Importing of secrets
88
- Syncing with BDK Electrum
9+
- Syncing using Compact Block Filters (CBF)
910
- Uses Sqlite to store additional information outside of the BDK structure
1011

1112
# Running tests

0 commit comments

Comments
 (0)