create-xpub
Create a BIP32 extended public key
Creates a Base58 encoded extended public key (xpub) for use in a BIP32 hierarchical deterministic wallet.
Install
npm install create-xpub
Usage
You should familiarise yourself with BIP32 to understand what these arguments represent.
const createXpub = ; const xpub = ;// => 'xpub6CgMcBZk66ayM9ESh7QtBmRKJbsa6rBeBH2k4aQZQJGossryP5r2N2nQS4hBMG1wb8igPoH53bxtzTBaeMqJkbu8bxsih1gGkoAn23Nr8VP'
Pass in version bytes for a different network:
const createXpub = ; const tpub = ;// => 'tpubDD3z8RPRoNYRcwRJ9JPyPgkgdiyE6Eghiud3R8ThkD2hdAXgTJh7WUTEg6mxskyBP3Fb1NnwahnwgdgC3DgYe3MRfZd2NYLWLkmBn7UWZXk'
Tip
If you're working with ledgerjs you can pass the output of getWalletPublicKey()
almost directly in.
API
createXpub(options)
Returns a Base58 encoded extended public key.
options
Type: Object
An object containing the following properties of the derivation path.
Consult BIP32 for an in-depth explanation on these properties.
networkVersion
Type: number
Default: 0x0488B21E
(mainnet)
Network version bytes.
depth
Type: number
Default: undefined
The depth of the derived key.
childNumber
Type: number
Default: undefined
The child number.
chainCode
Type: string
Default: undefined
The chain code.
publicKey
Type: string
Default: undefined
The public key in compressed or uncompressed form.
createXpub.mainnet
Mainnet (xpub) version bytes: 0x0488B21E
createXpub.testnet
Testnet (tpub) version bytes: 0x043587CF
License
MIT © Luke Childs