Skip to content

Conversation

@ValuedMammal
Copy link
Collaborator

This PR integrates features of the miniscript plan module into the wallet internals, in particular when it comes to coin selection and tx building. If accepted, the result is that the new interface may eventually replace bdk's current policy code.

fixes bitcoindevkit/bdk_wallet#4

Notes to the reviewers

Changelog notice

Checklists

All Submissions:

  • I've signed all my commits
  • I followed the contribution guidelines
  • I ran cargo fmt and cargo clippy before committing

New Features:

  • I've added tests for the new feature
  • I've added docs for the new feature

Bugfixes:

  • This pull request breaks the existing API
  • I've added tests to reproduce the issue which are now passing
  • I'm linking the issue being fixed by this PR

@ValuedMammal ValuedMammal self-assigned this Dec 20, 2024
@ValuedMammal ValuedMammal added this to the 2.0.0 milestone Dec 20, 2024
We can't easily plan the utxos before all of the assets are known,
so having `TxBuilder` try to create `WeightedUtxo`s creates a
chicken and egg problem that we fix by moving some logic to
`Wallet::create_tx`.

`TxParams::utxos` field is thus split into two: `utxos` is a list
of outpoints strictly to be used for getting locally owned outputs,
and `foreign_utxos` handles adding `WeightedUtxos` coming from
`add_foreign_utxo`. These are later combined with the manually
selected coins to form the list of utxos that must be spent.
The internal behavior is preserved insofar as the policy
path can influence the outcome of tx building. The difference
is instead of encode the path as nodes in a policy tree, the
plan is determined by the `Assets` available.

Note that creating a `Plan` is a pre-requisite to coin selection,
so if a UTXO in the wallet can't be planned, it won't be selected.
The wallet attempts to create a plan for each UTXO based on the
available information. The user may provide additional assets or
specify a particular set of assets in order to complete a plan.

New APIs include `TxBuilder::add_assets` and `Wallet::try_plan`
and `Wallet::planned_utxos`.

To prevent confusion due to overlapping functionality, the
`TxBuilder` methods `policy_path` and `current_height` are
removed.
@ValuedMammal ValuedMammal deleted the feat/plan branch April 7, 2025 21:16
@github-project-automation github-project-automation bot moved this from In Progress to Done in BDK Wallet Apr 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Can we remove policy module and use rust-miniscript ?

1 participant