Repository navigation
refactor(utxo-descriptors): make PoX-5 a descriptor extension - #9992
Closed
OttoAllmendinger wants to merge 1 commit into
Closed
OttoAllmendinger wants to merge 1 commit into
OttoAllmendinger wants to merge 1 commit into
Conversation
Add a DescriptorExtension interface to @bitgo/utxo-descriptors for special purpose descriptors that a descriptor wallet holds next to its regular wallet descriptors: an extension says which descriptors are valid for the wallet keys and refuses PSBTs that spend its inputs incorrectly. PoX-5 lockups are one implementation (pox5.descriptorExtension), next to the existing PoX-5 primitives. abstract-utxo no longer knows about PoX-5. The descriptor policy and the offline vault sign step go through the registered extensions (getValidatorWalletWithExtensions, assertExtensionSpendPolicy), and descriptor/extensions.ts is the one place that lists them. getValidatorPox5Lockup, getValidatorPox5Wallet and offlineVault/descriptor/pox5 are replaced by the generic equivalents. No behavior change. Refs: SI-1971
Contributor
Contributor
|
|
Contributor
Author
|
Reverted to the previous structure (PoX-5 stays in abstract-utxo for now); closing. |
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.
Description
The generic descriptor wallet flow in
@bitgo/abstract-utxohad PoX-5 hardcoded into it: the PoX-5 lockup validators indescriptor/validatePolicy.ts,getPolicyForEnv, the offline vault policy and a directassertPox5SpendPolicycall in the offline vault sign step. This makes PoX-5 one implementation of a generic descriptor extension instead. No behavior change.@bitgo/utxo-descriptorsgets aDescriptorExtensioninterface for special-purpose descriptors that a descriptor wallet holds next to its regular wallet descriptors:isWalletDescriptor(descriptor, walletKeys)says which descriptors are valid for the wallet keys, andassertSpendPolicy(psbt, descriptorMap)refuses PSBTs that spend the extension's inputs incorrectly (a no-op when none of the inputs belong to it).pox5.descriptorExtension, next to the existing PoX-5 primitives: the canonical lockup descriptor check (moved fromvalidatePolicy.ts) and the spend policy (moved fromabstract-utxo/src/offlineVault/descriptor/pox5.tstopox5/spendPolicy.ts).@bitgo/abstract-utxono longer mentions PoX-5 outsidedescriptor/extensions.ts, which is the one place that registers extensions. The descriptor policy usesgetValidatorWalletWithExtensions(the regularWsh2Of3descriptors together with any extension's descriptors) and the offline vault sign step usesassertExtensionSpendPolicy.getValidatorPox5LockupandgetValidatorPox5Walletare replaced by these generic functions.Design note: the extension interface uses plain
Descriptorand wallet key types rather than abstract-utxo'sNamedDescriptorNative/DescriptorValidationPolicy, soutxo-descriptorsdoes not need those types moved; abstract-utxo wraps each extension into aDescriptorValidationPolicy(getValidatorExtension).Follow-ups stacked on this: #9987 (PoX-5 early exit in the extension's spend policy) and #9991 (apply extension spend policies when a hot descriptor wallet signs).
Issue Number
Refs: SI-1971
Type of change
How Has This Been Tested?
modules/utxo-descriptors: newtest/unit/pox5/extension.ts(descriptor acceptance and rejection, spend policy delegation); full suite 62 passing at this commit.modules/abstract-utxo:npx mocha --recursive test/unit/transaction test/unit/signTransaction.ts test/unit/offlineVault, 418 passing, including the existing offline vault PoX-5 tests unchanged.