# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
-bdk_chain = { path = "../chain", version = "0.17.0", default-features = false }
+bdk_core = { path = "../core", version = "0.1", default-features = false }
esplora-client = { version = "0.9.0", default-features = false }
async-trait = { version = "0.1.66", optional = true }
futures = { version = "0.3.26", optional = true }
miniscript = { version = "12.0.0", optional = true, default-features = false }
[dev-dependencies]
+bdk_chain = { path = "../chain", version = "0.17.0" }
bdk_testenv = { path = "../testenv", default-features = false }
tokio = { version = "1", features = ["rt", "rt-multi-thread", "macros"] }
[`bdk_chain`]: https://docs.rs/bdk-chain/
[`EsploraExt`]: crate::EsploraExt
[`EsploraAsyncExt`]: crate::EsploraAsyncExt
-[`SyncRequest`]: bdk_chain::spk_client::SyncRequest
-[`FullScanRequest`]: bdk_chain::spk_client::FullScanRequest
+[`SyncRequest`]: bdk_core::spk_client::SyncRequest
+[`FullScanRequest`]: bdk_core::spk_client::FullScanRequest
[`sync`]: crate::EsploraExt::sync
[`full_scan`]: crate::EsploraExt::full_scan
-use std::collections::{BTreeSet, HashSet};
-
use async_trait::async_trait;
-use bdk_chain::spk_client::{FullScanRequest, FullScanResult, SyncRequest, SyncResult};
-use bdk_chain::{
+use bdk_core::collections::{BTreeMap, BTreeSet, HashSet};
+use bdk_core::spk_client::{FullScanRequest, FullScanResult, SyncRequest, SyncResult};
+use bdk_core::{
bitcoin::{BlockHash, OutPoint, ScriptBuf, Txid},
- collections::BTreeMap,
- local_chain::CheckPoint,
- BlockId, ConfirmationBlockTime,
+ tx_graph, BlockId, CheckPoint, ConfirmationBlockTime, Indexed,
};
-use bdk_chain::{tx_graph, Anchor, Indexed};
use futures::{stream::FuturesOrdered, TryStreamExt};
use crate::{insert_anchor_from_status, insert_prevouts};
///
/// We want to have a corresponding checkpoint per anchor height. However, checkpoints fetched
/// should not surpass `latest_blocks`.
-async fn chain_update<A: Anchor>(
+async fn chain_update(
client: &esplora_client::AsyncClient,
latest_blocks: &BTreeMap<u32, BlockHash>,
local_tip: &CheckPoint,
- anchors: &BTreeSet<(A, Txid)>,
+ anchors: &BTreeSet<(ConfirmationBlockTime, Txid)>,
) -> Result<CheckPoint, Error> {
let mut point_of_agreement = None;
let mut conflicts = vec![];
.extend(conflicts.into_iter().rev())
.expect("evicted are in order");
- for anchor in anchors {
- let height = anchor.0.anchor_block().height;
+ for (anchor, _txid) in anchors {
+ let height = anchor.block_id.height;
if tip.get(height).is_none() {
let hash = match fetch_block(client, latest_blocks, height).await? {
Some(hash) => hash,
local_chain::LocalChain,
BlockId,
};
+ use bdk_core::ConfirmationBlockTime;
use bdk_testenv::{anyhow, bitcoincore_rpc::RpcApi, TestEnv};
use esplora_client::Builder;
.iter()
.map(|&height| -> anyhow::Result<_> {
Ok((
- BlockId {
- height,
- hash: env.bitcoind.client.get_block_hash(height as _)?,
+ ConfirmationBlockTime {
+ block_id: BlockId {
+ height,
+ hash: env.bitcoind.client.get_block_hash(height as _)?,
+ },
+ confirmation_time: height as _,
},
Txid::all_zeros(),
))
.iter()
.map(|&(height, txid)| -> anyhow::Result<_> {
Ok((
- BlockId {
- height,
- hash: env.bitcoind.client.get_block_hash(height as _)?,
+ ConfirmationBlockTime {
+ block_id: BlockId {
+ height,
+ hash: env.bitcoind.client.get_block_hash(height as _)?,
+ },
+ confirmation_time: height as _,
},
txid,
))
-use std::collections::{BTreeSet, HashSet};
-use std::thread::JoinHandle;
-
-use bdk_chain::collections::BTreeMap;
-use bdk_chain::spk_client::{FullScanRequest, FullScanResult, SyncRequest, SyncResult};
-use bdk_chain::{
+use bdk_core::collections::{BTreeMap, BTreeSet, HashSet};
+use bdk_core::spk_client::{FullScanRequest, FullScanResult, SyncRequest, SyncResult};
+use bdk_core::{
bitcoin::{BlockHash, OutPoint, ScriptBuf, Txid},
- local_chain::CheckPoint,
- BlockId, ConfirmationBlockTime,
+ tx_graph, BlockId, CheckPoint, ConfirmationBlockTime, Indexed,
};
-use bdk_chain::{tx_graph, Anchor, Indexed};
use esplora_client::{OutputStatus, Tx};
+use std::thread::JoinHandle;
use crate::{insert_anchor_from_status, insert_prevouts};
///
/// We want to have a corresponding checkpoint per anchor height. However, checkpoints fetched
/// should not surpass `latest_blocks`.
-fn chain_update<A: Anchor>(
+fn chain_update(
client: &esplora_client::BlockingClient,
latest_blocks: &BTreeMap<u32, BlockHash>,
local_tip: &CheckPoint,
- anchors: &BTreeSet<(A, Txid)>,
+ anchors: &BTreeSet<(ConfirmationBlockTime, Txid)>,
) -> Result<CheckPoint, Error> {
let mut point_of_agreement = None;
let mut conflicts = vec![];
.extend(conflicts.into_iter().rev())
.expect("evicted are in order");
- for anchor in anchors {
- let height = anchor.0.anchor_block().height;
+ for (anchor, _) in anchors {
+ let height = anchor.block_id.height;
if tip.get(height).is_none() {
let hash = match fetch_block(client, latest_blocks, height)? {
Some(hash) => hash,
use bdk_chain::bitcoin::Txid;
use bdk_chain::local_chain::LocalChain;
use bdk_chain::BlockId;
+ use bdk_core::ConfirmationBlockTime;
use bdk_testenv::{anyhow, bitcoincore_rpc::RpcApi, TestEnv};
use esplora_client::{BlockHash, Builder};
use std::collections::{BTreeMap, BTreeSet};
.iter()
.map(|&height| -> anyhow::Result<_> {
Ok((
- BlockId {
- height,
- hash: env.bitcoind.client.get_block_hash(height as _)?,
+ ConfirmationBlockTime {
+ block_id: BlockId {
+ height,
+ hash: env.bitcoind.client.get_block_hash(height as _)?,
+ },
+ confirmation_time: height as _,
},
Txid::all_zeros(),
))
.iter()
.map(|&(height, txid)| -> anyhow::Result<_> {
Ok((
- BlockId {
- height,
- hash: env.bitcoind.client.get_block_hash(height as _)?,
+ ConfirmationBlockTime {
+ block_id: BlockId {
+ height,
+ hash: env.bitcoind.client.get_block_hash(height as _)?,
+ },
+ confirmation_time: height as _,
},
txid,
))
let txid: Txid = bdk_chain::bitcoin::hashes::Hash::hash(
&format!("txid_at_height_{}", h).into_bytes(),
);
- let anchor = BlockId {
- height: h,
- hash: anchor_blockhash,
+ let anchor = ConfirmationBlockTime {
+ block_id: BlockId {
+ height: h,
+ hash: anchor_blockhash,
+ },
+ confirmation_time: h as _,
};
(anchor, txid)
})
//! Just like how [`EsploraExt`] extends the functionality of an
//! [`esplora_client::BlockingClient`], [`EsploraAsyncExt`] is the async version which extends
//! [`esplora_client::AsyncClient`].
-//!
-//! [`TxGraph`]: bdk_chain::tx_graph::TxGraph
-//! [`LocalChain`]: bdk_chain::local_chain::LocalChain
-//! [`ChainOracle`]: bdk_chain::ChainOracle
-//! [`example_esplora`]: https://github.com/bitcoindevkit/bdk/tree/master/example-crates/example_esplora
-use bdk_chain::bitcoin::{Amount, OutPoint, TxOut, Txid};
-use bdk_chain::{tx_graph, BlockId, ConfirmationBlockTime};
+use bdk_core::bitcoin::{Amount, OutPoint, TxOut, Txid};
+use bdk_core::{tx_graph, BlockId, ConfirmationBlockTime};
use esplora_client::TxStatus;
pub use esplora_client;