diff --git a/src/hdwallet.js b/src/hdwallet.js index 014d0a0..a09eb9e 100644 --- a/src/hdwallet.js +++ b/src/hdwallet.js @@ -19,7 +19,7 @@ function findBIP32ParamsByVersion(version) { if (version != network.bip32[type]) continue return { - isPrivate: (type === 'priv'), + isPrivate: (type === 'private'), network: network } } @@ -132,7 +132,7 @@ HDWallet.fromBuffer = function(buffer) { return hd } -HDWallet.fromHex = function(hex, priv) { +HDWallet.fromHex = function(hex, isPrivate) { return HDWallet.fromBuffer(new Buffer(hex, 'hex')) } @@ -148,9 +148,9 @@ HDWallet.prototype.getAddress = function() { return this.pub.getAddress(this.network.pubKeyHash) } -HDWallet.prototype.toBuffer = function(priv) { +HDWallet.prototype.toBuffer = function(isPrivate) { // Version - var version = this.network.bip32[priv ? 'priv' : 'pub'] + var version = isPrivate ? this.network.bip32.private : this.network.bip32.public var buffer = new Buffer(HDWallet.LENGTH) // 4 bytes: version bytes @@ -172,7 +172,7 @@ HDWallet.prototype.toBuffer = function(priv) { this.chainCode.copy(buffer, 13) // 33 bytes: the public key or private key data - if (priv) { + if (isPrivate) { assert(this.priv, 'Missing private key') // 0x00 + k for private keys @@ -187,12 +187,12 @@ HDWallet.prototype.toBuffer = function(priv) { return buffer } -HDWallet.prototype.toHex = function(priv) { - return this.toBuffer(priv).toString('hex') +HDWallet.prototype.toHex = function(isPrivate) { + return this.toBuffer(isPrivate).toString('hex') } -HDWallet.prototype.toBase58 = function(priv) { - var buffer = this.toBuffer(priv) +HDWallet.prototype.toBase58 = function(isPrivate) { + var buffer = this.toBuffer(isPrivate) var checksum = crypto.hash256(buffer).slice(0, 4) return base58.encode(Buffer.concat([ diff --git a/src/networks.js b/src/networks.js index 5a9ed3e..da71d23 100644 --- a/src/networks.js +++ b/src/networks.js @@ -4,8 +4,8 @@ module.exports = { bitcoin: { magicPrefix: '\x18Bitcoin Signed Message:\n', bip32: { - pub: 0x0488b21e, - priv: 0x0488ade4 + public: 0x0488b21e, + private: 0x0488ade4 }, pubKeyHash: 0x00, scriptHash: 0x05, @@ -14,8 +14,8 @@ module.exports = { dogecoin: { magicPrefix: '\x19Dogecoin Signed Message:\n', bip32: { - pub: 0x02facafd, - priv: 0x02fac398 + public: 0x02facafd, + private: 0x02fac398 }, pubKeyHash: 0x1e, scriptHash: 0x16, @@ -24,8 +24,8 @@ module.exports = { litecoin: { magicPrefix: '\x19Litecoin Signed Message:\n', bip32: { - pub: 0x019da462, - priv: 0x019d9cfe + public: 0x019da462, + private: 0x019d9cfe }, pubKeyHash: 0x30, scriptHash: 0x05, @@ -34,8 +34,8 @@ module.exports = { testnet: { magicPrefix: '\x18Bitcoin Signed Message:\n', bip32: { - pub: 0x043587cf, - priv: 0x04358394 + public: 0x043587cf, + private: 0x04358394 }, pubKeyHash: 0x6f, scriptHash: 0xc4,