Repository navigation
WCN-3934 Path-agnostic wallet PSBT parsing and wallet prefix helpers - #458
Draft
davidkaplanbitgo wants to merge 1 commit into
Draft
davidkaplanbitgo wants to merge 1 commit into
davidkaplanbitgo wants to merge 1 commit into
Conversation
Add deriveWalletAccount and deriveWalletPrefix (44/<coin_type>/<h1>/<h2>) with the shared test vectors. Parse, explain and getWalletKeysFromPsbt now classify inputs and outputs by the full derivation path recorded in the PSBT, matching key origins by fingerprint and deriving a missing key (taproot and MuSig2 inputs) along a present entry's path; the script comparison still binds the result. A non-matching output returns None instead of aborting the parse. Hardened derivation prefixes return a typed error instead of panicking, and add-input accepts an optional expectedScript that fails with WalletInputScriptMismatch. Ticket: WCN-3934
davidkaplanbitgo
force-pushed
the
davidkaplan/wcn-3934-bitgowasm-wasm-utxo-per-wallet-derivation-prefix-path
branch
from
October 31, 2026 12:03
20c789d to
770c516
Compare
Contributor
Author
This branch has not been deployed
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.
Ticket: WCN-3934
Part of the BIP-0044 style wallet derivation project (spike WCN-3907): wallets that share root xpubs get a second, per-wallet derivation scheme
44/<coin_type>/<h1>/<h2>/<chain>/<index>.h1/h2are recomputed from the three wallet root keys, never stored.Changes
fixedScriptWallet.deriveWalletAccount(keys)andderiveWalletPrefix(keys, coinType)(Rustwallet_prefix.rs, wasm exports, TS wrappers) with the shared test vectors as a Rust test.getWalletKeysFromPsbtclassify wallet inputs/outputs by the full derivation path recorded in the PSBT, matching key origins by fingerprint. A key with no origin entry (taproot/MuSig2 inputs only carry signer+cosigner) is derived from its xpub along a present entry's path; script equality is still the binding check. A non-matching output returnsNoneinstead of aborting the whole parse; a non-matching input is an error.ParsedInput/ParsedOutput.derivationPathhold the full recorded path.RootWalletKeys::new_with_derivation_prefixesreturns a typed error on a hardened component instead of panicking.expectedScriptoption on add-wallet-input; mismatch fails with the typedWalletInputScriptMismatchand leaves the PSBT unchanged. Omitting it changes nothing.New public API
Rust:
wallet_prefix::{derive_wallet_account, derive_wallet_prefix, WalletPrefixError},WalletKeysError,AddWalletInputError,WalletInputOptions.expected_script,BitGoPsbt::try_add_wallet_input_at_index.RootWalletKeys::new_with_derivation_prefixesnow returnsResult;OutputScriptType::checktakes the three derived pubkeys. wasm:derive_wallet_account,derive_wallet_prefix, trailingexpected_scriptargument onadd_wallet_input/add_wallet_input_at_index. TS:deriveWalletAccount,deriveWalletPrefix,AddWalletInputOptions.expectedScript.Test
cargo check --all-targetspasses.cargo testand the mocha suite have NOT been run, and no mocha tests were added for the new behaviour yet; existing fixtures should be unaffected by inspection only.RootWalletKeysrelies on per-keys prefixes increate_bip32_derivationand is untested;hydrate_psbtstill takes one key set (no per-unspent prefix).Downstream (IMS, BitGoJS, wallet-platform) need the release of this change.