Skip to content

Spending Policy Required: External error on tx builder finish #605

@BitcoinZavior

Description

@BitcoinZavior

Describe the bug

Encountering a Spending policy required: External error when attempting to build a transaction using a multi-sig descriptor. Currently, bdk-ffi does not provide a policy_path() in txBuilder, which is necessary for specifying the correct policy path during transaction creation.

Proposed Solution:

  • Expose policies() from the wallet to retrieve available spending policies.
  • Add support for policy_path() in txBuilder to allow specifying the correct policy path when building the transaction.

These changes will ensure that the correct branch of a script is selected when creating transactions, preventing ambiguity issues.

Use Case:
An example where the policy_path is needed is with the following descriptor:

wsh(thresh(2,pk(A),sj:and_v(v:pk(B),n:older(6)),snj:and_v(v:pk(C),after(630000)))),
which is derived from the miniscript policy:

thresh(2,pk(A),and(pk(B),older(6)),and(pk(C),after(630000))).
In this case, the script can be satisfied in multiple ways. Without specifying the policy_path, it becomes ambiguous which spending path should be used for the transaction, leading to the error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions