]> Untitled Git - bdk/commitdiff
Merge bitcoindevkit/bdk#2135: docs: Document TxUpdate temporal context requirements... master github/master
authormerge-script <hello@evanlinjin.me>
Thu, 12 Mar 2026 14:45:19 +0000 (14:45 +0000)
committermerge-script <hello@evanlinjin.me>
Thu, 12 Mar 2026 14:45:19 +0000 (14:45 +0000)
b69d7bfce32d20a5849052a2e61bf8d8bff813a6 docs: document TxUpdate temporal context requirements (Rafael Turon)

Pull request description:

  Closes #2133

  This introduces clear temporal context **documentation** to the `TxUpdate` struct, explicitly stating that entries must have either `anchors` or `seen_ats` to be considered canonical and contribute to wallet balances.

  It also explicitly documents the `seen_ats` HashSet signature to prevent usage errors when writing custom chain sources.

  This fulfills the recommendation outlined in the Wizardsardine BDK Audit Report (Q4 2024).

  ### Description
  This primarily affects developers building **custom chain sources** — anyone constructing `Update` structs outside of `bdk_electrum`/`bdk_esplora`/`bdk_bitcoind_rpc`.
  As the ecosystem grows (streaming Electrum, Nostr relay sync, compact block filters, custom backends), more developers will encounter this undocumented contract.

  ### What I Changed

  *1. Doc comment on `TxUpdate` struct*
  * **`anchors` or `seen_ats`** are stored in the graph but do not affect the balance.
  * **`seen_ats` collection type**: `TxUpdate::seen_ats` is a `BTreeSet<(Txid, u64)>`, requiring `.insert((txid, timestamp))`.

  *2. Doc comment on `Wallet::apply_update()`*
  * **TxGraph `apply_update`**: transactions without temporal context note.
  * **IndexedTxGraph `apply_update`**: transactions without temporal context note.

  ### Impact
  This is just a documentation fix - no code changes, no breaking changes.

  ### Checklists

  #### All Submissions:

  * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)

ACKs for top commit:
  evanlinjin:
    ACK b69d7bfce32d20a5849052a2e61bf8d8bff813a6

Tree-SHA512: 669fbd2c23f7615c697d550ab448b3fd72955223cef4146d6719e2d0c26b959253ce987eebf737366968cb88e5477a897289274ddf78c1ffd338be4e5d795f4b

1  2 
crates/chain/src/tx_graph.rs

Simple merge