HDWallet: rename local priv to isPrivate
This commit is contained in:
parent
938c43649d
commit
91b8833e52
2 changed files with 17 additions and 17 deletions
|
@ -19,7 +19,7 @@ function findBIP32ParamsByVersion(version) {
|
||||||
if (version != network.bip32[type]) continue
|
if (version != network.bip32[type]) continue
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isPrivate: (type === 'priv'),
|
isPrivate: (type === 'private'),
|
||||||
network: network
|
network: network
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ HDWallet.fromBuffer = function(buffer) {
|
||||||
return hd
|
return hd
|
||||||
}
|
}
|
||||||
|
|
||||||
HDWallet.fromHex = function(hex, priv) {
|
HDWallet.fromHex = function(hex, isPrivate) {
|
||||||
return HDWallet.fromBuffer(new Buffer(hex, 'hex'))
|
return HDWallet.fromBuffer(new Buffer(hex, 'hex'))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,9 +148,9 @@ HDWallet.prototype.getAddress = function() {
|
||||||
return this.pub.getAddress(this.network.pubKeyHash)
|
return this.pub.getAddress(this.network.pubKeyHash)
|
||||||
}
|
}
|
||||||
|
|
||||||
HDWallet.prototype.toBuffer = function(priv) {
|
HDWallet.prototype.toBuffer = function(isPrivate) {
|
||||||
// Version
|
// 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)
|
var buffer = new Buffer(HDWallet.LENGTH)
|
||||||
|
|
||||||
// 4 bytes: version bytes
|
// 4 bytes: version bytes
|
||||||
|
@ -172,7 +172,7 @@ HDWallet.prototype.toBuffer = function(priv) {
|
||||||
this.chainCode.copy(buffer, 13)
|
this.chainCode.copy(buffer, 13)
|
||||||
|
|
||||||
// 33 bytes: the public key or private key data
|
// 33 bytes: the public key or private key data
|
||||||
if (priv) {
|
if (isPrivate) {
|
||||||
assert(this.priv, 'Missing private key')
|
assert(this.priv, 'Missing private key')
|
||||||
|
|
||||||
// 0x00 + k for private keys
|
// 0x00 + k for private keys
|
||||||
|
@ -187,12 +187,12 @@ HDWallet.prototype.toBuffer = function(priv) {
|
||||||
return buffer
|
return buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
HDWallet.prototype.toHex = function(priv) {
|
HDWallet.prototype.toHex = function(isPrivate) {
|
||||||
return this.toBuffer(priv).toString('hex')
|
return this.toBuffer(isPrivate).toString('hex')
|
||||||
}
|
}
|
||||||
|
|
||||||
HDWallet.prototype.toBase58 = function(priv) {
|
HDWallet.prototype.toBase58 = function(isPrivate) {
|
||||||
var buffer = this.toBuffer(priv)
|
var buffer = this.toBuffer(isPrivate)
|
||||||
var checksum = crypto.hash256(buffer).slice(0, 4)
|
var checksum = crypto.hash256(buffer).slice(0, 4)
|
||||||
|
|
||||||
return base58.encode(Buffer.concat([
|
return base58.encode(Buffer.concat([
|
||||||
|
|
|
@ -4,8 +4,8 @@ module.exports = {
|
||||||
bitcoin: {
|
bitcoin: {
|
||||||
magicPrefix: '\x18Bitcoin Signed Message:\n',
|
magicPrefix: '\x18Bitcoin Signed Message:\n',
|
||||||
bip32: {
|
bip32: {
|
||||||
pub: 0x0488b21e,
|
public: 0x0488b21e,
|
||||||
priv: 0x0488ade4
|
private: 0x0488ade4
|
||||||
},
|
},
|
||||||
pubKeyHash: 0x00,
|
pubKeyHash: 0x00,
|
||||||
scriptHash: 0x05,
|
scriptHash: 0x05,
|
||||||
|
@ -14,8 +14,8 @@ module.exports = {
|
||||||
dogecoin: {
|
dogecoin: {
|
||||||
magicPrefix: '\x19Dogecoin Signed Message:\n',
|
magicPrefix: '\x19Dogecoin Signed Message:\n',
|
||||||
bip32: {
|
bip32: {
|
||||||
pub: 0x02facafd,
|
public: 0x02facafd,
|
||||||
priv: 0x02fac398
|
private: 0x02fac398
|
||||||
},
|
},
|
||||||
pubKeyHash: 0x1e,
|
pubKeyHash: 0x1e,
|
||||||
scriptHash: 0x16,
|
scriptHash: 0x16,
|
||||||
|
@ -24,8 +24,8 @@ module.exports = {
|
||||||
litecoin: {
|
litecoin: {
|
||||||
magicPrefix: '\x19Litecoin Signed Message:\n',
|
magicPrefix: '\x19Litecoin Signed Message:\n',
|
||||||
bip32: {
|
bip32: {
|
||||||
pub: 0x019da462,
|
public: 0x019da462,
|
||||||
priv: 0x019d9cfe
|
private: 0x019d9cfe
|
||||||
},
|
},
|
||||||
pubKeyHash: 0x30,
|
pubKeyHash: 0x30,
|
||||||
scriptHash: 0x05,
|
scriptHash: 0x05,
|
||||||
|
@ -34,8 +34,8 @@ module.exports = {
|
||||||
testnet: {
|
testnet: {
|
||||||
magicPrefix: '\x18Bitcoin Signed Message:\n',
|
magicPrefix: '\x18Bitcoin Signed Message:\n',
|
||||||
bip32: {
|
bip32: {
|
||||||
pub: 0x043587cf,
|
public: 0x043587cf,
|
||||||
priv: 0x04358394
|
private: 0x04358394
|
||||||
},
|
},
|
||||||
pubKeyHash: 0x6f,
|
pubKeyHash: 0x6f,
|
||||||
scriptHash: 0xc4,
|
scriptHash: 0xc4,
|
||||||
|
|
Loading…
Reference in a new issue