Fix bug on HD*Keys

This commit is contained in:
Esteban Ordano 2014-12-17 12:31:04 -03:00
parent afb5b6971f
commit c793559fa9
2 changed files with 3 additions and 3 deletions

View File

@ -221,7 +221,7 @@ HDPrivateKey.prototype._buildFromObject = function(arg) {
// TODO: Type validation
var buffers = {
version: arg.network ? BufferUtil.integerAsBuffer(Network.get(arg.network).xprivkey) : arg.version,
depth: BufferUtil.integerAsSingleByteBuffer(arg.depth),
depth: _.isNumber(arg.depth) ? BufferUtil.integerAsSingleByteBuffer(arg.depth) : arg.depth,
parentFingerPrint: _.isNumber(arg.parentFingerPrint) ? BufferUtil.integerAsBuffer(arg.parentFingerPrint) : arg.parentFingerPrint,
childIndex: _.isNumber(arg.childIndex) ? BufferUtil.integerAsBuffer(arg.childIndex) : arg.childIndex,
chainCode: _.isString(arg.chainCode) ? BufferUtil.hexToBuffer(arg.chainCode) : arg.chainCode,

View File

@ -231,9 +231,9 @@ HDPublicKey.prototype._buildFromObject = function (arg) {
// TODO: Type validation
var buffers = {
version: arg.network ? BufferUtil.integerAsBuffer(Network.get(arg.network).xpubkey) : arg.version,
depth: BufferUtil.integerAsSingleByteBuffer(arg.depth),
depth: _.isNumber(arg.depth) ? BufferUtil.integerAsSingleByteBuffer(arg.depth) : arg.depth,
parentFingerPrint: _.isNumber(arg.parentFingerPrint) ? BufferUtil.integerAsBuffer(arg.parentFingerPrint) : arg.parentFingerPrint,
childIndex: BufferUtil.integerAsBuffer(arg.childIndex),
childIndex: _.isNumber(arg.childIndex) ? BufferUtil.integerAsBuffer(arg.childIndex) : arg.childIndex,
chainCode: _.isString(arg.chainCode) ? BufferUtil.hexToBuffer(arg.chainCode) : arg.chainCode,
publicKey: _.isString(arg.publicKey) ? BufferUtil.hexToBuffer(arg.publicKey) :
BufferUtil.isBuffer(arg.publicKey) ? arg.publicKey : arg.publicKey.toBuffer(),