Skip to content
Merged
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
4 changes: 4 additions & 0 deletions crates/chain/src/indexed_tx_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ where
///
/// `update` is a [`tx_graph::TxUpdate<A>`] and the resultant changes is returned as
/// [`ChangeSet`].
///
/// **Note**: Transactions in the `update` without temporal context (anchors or seen_ats)
/// will be stored but will not be considered canonical. See [`tx_graph::TxUpdate`] for
/// more details.
pub fn apply_update(&mut self, update: tx_graph::TxUpdate<A>) -> ChangeSet<A, I::ChangeSet> {
let tx_graph = self.graph.apply_update(update);
let indexer = self.index_tx_graph_changeset(&tx_graph);
Expand Down
3 changes: 3 additions & 0 deletions crates/chain/src/tx_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,9 @@ impl<A: Anchor> TxGraph<A> {
///
/// The returned [`ChangeSet`] is the set difference between `update` and `self` (transactions
/// that exist in `update` but not in `self`).
///
/// **Note**: Transactions in the `update` without temporal context (anchors or seen_ats)
/// will be stored but will not be considered canonical. See [`TxUpdate`] for more details.
pub fn apply_update(&mut self, update: TxUpdate<A>) -> ChangeSet<A> {
let mut changeset = ChangeSet::<A>::default();
for tx in update.txs {
Expand Down
7 changes: 7 additions & 0 deletions crates/core/src/tx_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ use bitcoin::{OutPoint, Transaction, TxOut, Txid};
/// tx_update.txs.push(tx);
/// tx_update.anchors.insert((anchor, txid));
/// ```
/// ## Temporal context
/// To contribute to a wallet's balance, transactions must have an entry in either:
/// - [`Self::anchors`]: for confirmed transactions.
/// - [`Self::seen_ats`]: for unconfirmed transactions.
///
/// The built-in chain-source crates (`bdk_electrum`, `bdk_esplora`, `bdk_bitcoind_rpc`) handle this
/// automatically. Transactions lacking temporal context are stored but ignored by canonicalization.
#[derive(Debug, Clone)]
#[non_exhaustive]
pub struct TxUpdate<A = ()> {
Expand Down
Loading