|
|
@ -306,7 +306,10 @@ HDPrivateKey.prototype._buildFromBuffers = function(arg) { |
|
|
|
/* jshint maxstatements: 20 */ |
|
|
|
|
|
|
|
HDPrivateKey._validateBufferArguments(arg); |
|
|
|
this._buffers = arg; |
|
|
|
Object.defineProperty(this, '_buffers', { |
|
|
|
configurable: false, |
|
|
|
value: arg |
|
|
|
}); |
|
|
|
|
|
|
|
var sequence = [ |
|
|
|
arg.version, arg.depth, arg.parentFingerPrint, arg.childIndex, arg.chainCode, |
|
|
@ -321,21 +324,35 @@ HDPrivateKey.prototype._buildFromBuffers = function(arg) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
var xprivkey; |
|
|
|
|
|
|
|
if (!arg.xprivkey) { |
|
|
|
this.xprivkey = Base58Check.encode(buffer.Buffer.concat(sequence)); |
|
|
|
xprivkey = Base58Check.encode(buffer.Buffer.concat(sequence)); |
|
|
|
} else { |
|
|
|
this.xprivkey = arg.xprivkey; |
|
|
|
xprivkey = arg.xprivkey; |
|
|
|
} |
|
|
|
this.network = Network.get(bufferUtil.integerFromBuffer(arg.version)); |
|
|
|
this.depth = bufferUtil.integerFromSingleByteBuffer(arg.depth); |
|
|
|
this.privateKey = new PrivateKey(BN().fromBuffer(arg.privateKey)); |
|
|
|
this.publicKey = this.privateKey.toPublicKey(); |
|
|
|
|
|
|
|
this.fingerPrint = Hash.sha256ripemd160(this.publicKey.toBuffer()).slice(0, HDPrivateKey.ParentFingerPrintSize); |
|
|
|
var privateKey = new PrivateKey(BN().fromBuffer(arg.privateKey)); |
|
|
|
var publicKey = privateKey.toPublicKey(); |
|
|
|
var size = HDPrivateKey.ParentFingerPrintSize; |
|
|
|
var fingerPrint = Hash.sha256ripemd160(publicKey.toBuffer()).slice(0, size); |
|
|
|
|
|
|
|
jsUtil.defineImmutable(this, { |
|
|
|
xprivkey: xprivkey, |
|
|
|
network: Network.get(bufferUtil.integerFromBuffer(arg.version)), |
|
|
|
depth: bufferUtil.integerFromSingleByteBuffer(arg.depth), |
|
|
|
privateKey: privateKey, |
|
|
|
publicKey: publicKey, |
|
|
|
fingerPrint: fingerPrint |
|
|
|
}); |
|
|
|
|
|
|
|
var HDPublicKey = require('./hdpublickey'); |
|
|
|
this.hdPublicKey = new HDPublicKey(this); |
|
|
|
this.xpubkey = this.hdPublicKey.xpubkey; |
|
|
|
var hdPublicKey = new HDPublicKey(this); |
|
|
|
|
|
|
|
jsUtil.defineImmutable(this, { |
|
|
|
hdPublicKey: hdPublicKey, |
|
|
|
xpubkey: hdPublicKey.xpubkey |
|
|
|
}); |
|
|
|
|
|
|
|
return this; |
|
|
|
}; |
|
|
|