feat(wallet)!: use miniscript plan in place of old policy mod#1786
Closed
ValuedMammal wants to merge 4 commits intobitcoindevkit:masterfrom
Closed
feat(wallet)!: use miniscript plan in place of old policy mod#1786ValuedMammal wants to merge 4 commits intobitcoindevkit:masterfrom
plan in place of old policy mod#1786ValuedMammal wants to merge 4 commits intobitcoindevkit:masterfrom
Conversation
6 tasks
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.
d97de6a to
6628f4b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR integrates features of the miniscript
planmodule 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 currentpolicycode.fixes bitcoindevkit/bdk_wallet#4
Notes to the reviewers
Changelog notice
Checklists
All Submissions:
cargo fmtandcargo clippybefore committingNew Features:
Bugfixes: