|
|
@ -245,7 +245,7 @@ class HDAccountsHelper { |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Checks if a hd account is a valid hdnode |
|
|
|
* Checks if a hd account is a valid bip32 |
|
|
|
* @param {string} xpub - hd account |
|
|
|
* @returns {boolean} returns true if hd account is valid, false otherwise |
|
|
|
*/ |
|
|
@ -258,7 +258,7 @@ class HDAccountsHelper { |
|
|
|
const xlatedXpub = this.xlatXPUB(xpub) |
|
|
|
|
|
|
|
// Parse input as an HD Node. Throws if invalid
|
|
|
|
const node = bitcoin.HDNode.fromBase58(xlatedXpub, activeNet) |
|
|
|
const node = bitcoin.bip32.fromBase58(xlatedXpub, activeNet) |
|
|
|
|
|
|
|
// Check and see if this is a private key
|
|
|
|
if (!node.isNeutered()) |
|
|
@ -278,7 +278,7 @@ class HDAccountsHelper { |
|
|
|
/** |
|
|
|
* Get the hd node associated to an hd account |
|
|
|
* @param {string} xpub - hd account |
|
|
|
* @returns {HDNode} |
|
|
|
* @returns {bip32} |
|
|
|
*/ |
|
|
|
getNode(xpub) { |
|
|
|
if (this.isValid(xpub)) |
|
|
@ -291,7 +291,7 @@ class HDAccountsHelper { |
|
|
|
* Derives an address for an hd account |
|
|
|
* @param {int} chain - chain to be derived |
|
|
|
* must have a value on [0,1] for BIP44/BIP49/BIP84 derivation |
|
|
|
* @param {HDNode} chainNode - Parent HDNode used for derivation |
|
|
|
* @param {bip32} chainNode - Parent bip32 used for derivation |
|
|
|
* @param {int} index - index to be derived |
|
|
|
* @param {int} type - type of derivation |
|
|
|
* @returns {Promise - object} returns an object {address: '...', chain: <int>, index: <int>} |
|
|
@ -307,13 +307,13 @@ class HDAccountsHelper { |
|
|
|
|
|
|
|
switch (type) { |
|
|
|
case this.BIP44: |
|
|
|
addr.address = indexNode.getAddress() |
|
|
|
addr.address = bitcoin.payments.p2pkh({ pubkey: indexNode.publicKey, network: activeNet }).address |
|
|
|
break |
|
|
|
case this.BIP49: |
|
|
|
addr.address = addrHelper.p2wpkhP2shAddress(indexNode.getPublicKeyBuffer()) |
|
|
|
addr.address = addrHelper.p2wpkhP2shAddress(indexNode.publicKey) |
|
|
|
break |
|
|
|
case this.BIP84: |
|
|
|
addr.address = addrHelper.p2wpkhAddress(indexNode.getPublicKeyBuffer()) |
|
|
|
addr.address = addrHelper.p2wpkhAddress(indexNode.publicKey) |
|
|
|
break |
|
|
|
} |
|
|
|
|
|
|
|