HDWallet: rename local priv to isPrivate

This commit is contained in:
Daniel Cousens 2014-06-03 15:58:42 +10:00
parent 938c43649d
commit 91b8833e52
2 changed files with 17 additions and 17 deletions

View file

@ -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([

View file

@ -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,