]> Untitled Git - bdk/commit
Merge bitcoindevkit/bdk#2027: feat(chain): add new `list_ordered_canonical_txs` method
authormerge-script <valuedmammal@protonmail.com>
Mon, 24 Nov 2025 14:02:19 +0000 (09:02 -0500)
committermerge-script <valuedmammal@protonmail.com>
Mon, 24 Nov 2025 14:02:19 +0000 (09:02 -0500)
commit1a77475f087ae311672ff91da5206c49bed6adec
tree7faaddf00c3ec5eb2b8cfa8f50f76af3264d2744
parent822ce5ea785fa0f013a7b102b89ecd1668a96895
parent12c107637eb46cf9674d09067f65d07d1701f60d
Merge bitcoindevkit/bdk#2027: feat(chain): add new `list_ordered_canonical_txs` method

12c107637eb46cf9674d09067f65d07d1701f60d feat(chain): introduce new `list_ordered_canonical_txs` (Leonardo Lima)
f34117b7843f1d85a041d58601fbc7bed7695a86 test(chain): add `test_list_ordered_canonical_txs` (Leonardo Lima)
a201be0b9fdb1811f83f95b305cffb9cd4d584d7 chore(test): rename `txid_to_name` to proper `tx_name_to_txid` (Leonardo Lima)
6cf720e48fe7ac58d9c161387710862a1d64909a chore(docs): fix typo in docs (Leonardo Lima)

Pull request description:

  ### Description

  It introduces a new method for topological ordering canonical transactions, `list_ordered_canonical_txs`. It now ensures the dependency-based transaction processing, guaranteeing that parent transactions always appears before their children transaction.

  The existing `list_canonical_txs` and `try_list_canonical_txs` methods have been deprecated in favor of the new ordered version.

  ### Notes to the reviewers

  "[...] For those reviewing, and wondering why we don't have a fallible try version of this method, it's because we don't have a fallible ChainOracle implementation - we will get rid of ChainOracle trait soon anyway."

  This PR is intended for a point release so that bdk_wallet 2.x users can get a topologically sorted list of transactions (we need a point release on bdk_wallet 2.x as well).

  It might be useful to take a look at the new test scenarios that I've added, it shows some specific scenarios where the current implementation and output of `canonical_txs` didn't output the transactions in topological order.

  Let me know if you think the TopologicalIter algorithm and/or API could be improved.

  ### Changelog notice
  ```
  #### Added
  - New `list_ordered_canonical_txs` method to `TxGraph` that returns canonical transactions in topological order, ensuring parent transactions always appear before their children

  #### Deprecated
  - `list_canonical_txs` method - use `list_ordered_canonical_txs` instead for guaranteed topological ordering
  - `try_list_canonical_txs` method - use `list_ordered_canonical_txs` instead for guaranteed topological ordering
  ```

  ### Checklists

  #### All Submissions:

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

  #### New Features:

  * [x] I've added tests for the new feature
  * [x] I've added docs for the new feature

ACKs for top commit:
  ValuedMammal:
    ACK 12c107637eb46cf9674d09067f65d07d1701f60d

Tree-SHA512: 73c8cc40e6b77844af52ddc1a788cf1190357e08f487f443ab492881e50ed4343598e2607f542e7d9b69615cd102f29ec3bda5942753186860d919433b1d62dd