HD Private Keys (Bip32)

Hierarchical Deterministic Keys(HD Keys) form a key component of how one manages Private keys within a Bitcoin Wallet. If you are not familiar with HD Keys, be sure to read more about them in the Developer Guide Appendix

Initialise a new HD Private key from a master “seed”

//masterSeed is BIP39 mnemonic seed value
var masterSeed = '000102030405060708090a0b0c0d0e0f';
var seededKey = HDPrivateKey.fromSeed(masterSeed, NetworkType.TEST);

Derive a child key at a specific path

var derivedKey = seededKey.deriveChildKey("m/0'/1");

Serialise a HD Private Key (xpriv)

//use property getter to get the Extended Private Key as a string
var xprivString = derivedKey.xprivkey