junderw
6 years ago
No known key found for this signature in database
GPG Key ID: B256185D3A971908
3 changed files with
7 additions and
5 deletions
-
lib/bitcoin/addresses-helper.js
-
lib/bitcoin/hd-accounts-helper.js
-
lib/bitcoin/parallel-address-derivation.js
|
|
@ -7,7 +7,7 @@ |
|
|
|
const bitcoin = require('bitcoinjs-lib') |
|
|
|
const btcMessage = require('bitcoinjs-message') |
|
|
|
const activeNet = require('./network').network |
|
|
|
const { p2sh, p2wpkh } = bitcoin.payments |
|
|
|
const { p2pkh, p2sh, p2wpkh } = bitcoin.payments |
|
|
|
|
|
|
|
/** |
|
|
|
* A singleton providing Addresses helper functions |
|
|
@ -20,8 +20,10 @@ class AddressesHelper { |
|
|
|
* @returns {string} return the derived address |
|
|
|
*/ |
|
|
|
p2pkhAddress(pubKeyBuffer) { |
|
|
|
const pubKeyHash = bitcoin.crypto.hash160(pubKeyBuffer) |
|
|
|
return bitcoin.address.toBase58Check(pubKeyHash, activeNet.pubKeyHash) |
|
|
|
return p2pkh({ |
|
|
|
pubkey: pubKeyBuffer, |
|
|
|
network: activeNet, |
|
|
|
}).address |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
@ -307,7 +307,7 @@ class HDAccountsHelper { |
|
|
|
|
|
|
|
switch (type) { |
|
|
|
case this.BIP44: |
|
|
|
addr.address = bitcoin.payments.p2pkh({ pubkey: indexNode.publicKey, network: activeNet }).address |
|
|
|
addr.address = addrHelper.p2pkhAddress(indexNode.publicKey) |
|
|
|
break |
|
|
|
case this.BIP49: |
|
|
|
addr.address = addrHelper.p2wpkhP2shAddress(indexNode.publicKey) |
|
|
|
|
|
@ -37,7 +37,7 @@ const deriveAddress = async function(chain, chainNode, index, type) { |
|
|
|
|
|
|
|
switch (type) { |
|
|
|
case BIP44: |
|
|
|
addr.address = bitcoin.payments.p2pkh({ pubkey: indexNode.publicKey, network: activeNet }).address |
|
|
|
addr.address = addrHelper.p2pkhAddress(indexNode.publicKey) |
|
|
|
break |
|
|
|
case BIP49: |
|
|
|
addr.address = addrHelper.p2wpkhP2shAddress(indexNode.publicKey) |
|
|
|