|
|
@ -52,6 +52,8 @@ function HDPrivateKey(arg) { |
|
|
|
this._buildFromSerialized(arg); |
|
|
|
} else if (JSUtil.isValidJSON(arg)) { |
|
|
|
this._buildFromJSON(arg); |
|
|
|
} else if (BufferUtil.isBuffer(arg) && HDPrivateKey.isValidSerialized(arg.toString())) { |
|
|
|
this._buildFromSerialized(arg.toString()); |
|
|
|
} else { |
|
|
|
throw HDPrivateKey.getSerializedError(arg); |
|
|
|
} |
|
|
@ -377,12 +379,8 @@ HDPrivateKey.prototype._buildFromBuffers = function(arg) { |
|
|
|
} |
|
|
|
|
|
|
|
var xprivkey; |
|
|
|
|
|
|
|
if (!arg.xprivkey) { |
|
|
|
xprivkey = Base58Check.encode(buffer.Buffer.concat(sequence)); |
|
|
|
} else { |
|
|
|
xprivkey = arg.xprivkey; |
|
|
|
} |
|
|
|
xprivkey = Base58Check.encode(buffer.Buffer.concat(sequence)); |
|
|
|
arg.xprivkey = new Buffer(xprivkey); |
|
|
|
|
|
|
|
var privateKey = new PrivateKey(BN.fromBuffer(arg.privateKey)); |
|
|
|
var publicKey = privateKey.toPublicKey(); |
|
|
@ -496,7 +494,7 @@ HDPrivateKey.prototype.toJSON = function toJSON() { |
|
|
|
* @return {HDPrivateKey} |
|
|
|
*/ |
|
|
|
HDPrivateKey.fromBuffer = function(arg) { |
|
|
|
return new HDPrivateKey(arg); |
|
|
|
return new HDPrivateKey(arg.toString()); |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
@ -505,7 +503,7 @@ HDPrivateKey.fromBuffer = function(arg) { |
|
|
|
* @return {string} |
|
|
|
*/ |
|
|
|
HDPrivateKey.prototype.toBuffer = function() { |
|
|
|
return this._buffers.xprivkey; |
|
|
|
return BufferUtil.copy(this._buffers.xprivkey); |
|
|
|
}; |
|
|
|
|
|
|
|
HDPrivateKey.DefaultDepth = 0; |
|
|
|