Skip to content

Make TxAncestors::new_include_root public #2216

@Dmenec

Description

@Dmenec

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:

  1. 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.

  2. 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.

Impact

  • Developer experience / maintainability

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions