You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the enhancement
TxGraph::walk_ancestors skips the root transaction, it starts directly from the parents of the tx passed in. There is currently no public way to traverse ancestors including the root itself.
Use case
In bitcoindevkit/bdk_wallet@15beb0b5, balance() needs to inspect the inputs of every transaction in a chain, including the root, to determine whether they belong to the wallet. By including the root, the same inspection logic would not be duplicated.
I have a few ideas to discuss:
Make TxAncestors::new_include_root public. It already exists as pub(crate), so the change would be minimal. Not sure if there's a reason it was kept internal.
Add a wrapper method on TxGraph (e.g. walk_ancestors_include_root), follows the same pattern as walk_ancestors and keeps TxAncestors as an implementation detail.
Just to show how it could be used I've made a test. I decided to go with the first implementation proposed , though it would be pretty similar with the wrapper approach.
Note: the test uses CanonicalView from a fork of #2038, but the usage of new_include_root itself is independent of that and would work the same in the current API. I built it on top of a follow-up commit from @nymius that removes the min_confirmations parameter from CanonicalView::balance, since we were experimenting with balance changes there.
Activity
Dmenec commentedon Jun 3, 2026
Just to show how it could be used I've made a test. I decided to go with the first implementation proposed , though it would be pretty similar with the wrapper approach.
b0acd3b#diff-d3f18e9a77fd241fa351a0cbcd75e993d90819834ccde09b7f4247c153ff26eeR586-R607
Note: the test uses
CanonicalViewfrom a fork of #2038, but the usage ofnew_include_rootitself is independent of that and would work the same in the current API. I built it on top of a follow-up commit from @nymius that removes themin_confirmationsparameter fromCanonicalView::balance, since we were experimenting with balance changes there.alok844937-design commentedon Jul 6, 2026
Just for future reference — is this still being handled by @Dmenec, or is it open for someone else to pick up? Happy to help if it's still available.
Dmenec commentedon Jul 22, 2026
Closing this in favor of #2235, as another walk will be included in that or a follow-up PR.