deriveWalletKeys
Derives the root-level wallet keys from an HD root node. Returns the salt, root extended private key, and configuration private key.
Usage
import { deriveWalletKeys } from '@stacks/wallet-sdk';
import { HDKey } from '@scure/bip32';
import { mnemonicToSeed } from '@scure/bip39';
const seed = await mnemonicToSeed('your 24-word seed phrase ...');
const rootNode = HDKey.fromMasterSeed(seed);
const walletKeys = await deriveWalletKeys(rootNode);
console.log(walletKeys.salt); // hex string
console.log(walletKeys.rootKey); // xprv... extended private key
console.log(walletKeys.configPrivateKey); // hex stringNotes
This is called internally by
generateWallet. You typically don't need to call it directly unless building custom wallet flows.The
saltis derived from the identity keychain's public key and used for generating app-specific private keys.The
configPrivateKeyis derived from pathm/5757'/0'/1and is used to encrypt wallet configuration data.
Signature
Returns
Promise<WalletKeys>
Parameters
rootNode (required)
Type:
HDKey(from@scure/bip32)
The root HD key derived from the wallet's seed phrase.
Last updated
Was this helpful?