Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions src/hdnode.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,15 @@ HDNode.fromSeedHex = function(hex, network) {
}

HDNode.fromBase58 = function(string) {
return HDNode.fromBuffer(base58check.decode(string))
return HDNode.fromBuffer(base58check.decode(string), true)
}

HDNode.fromBuffer = function(buffer) {
// FIXME: remove in 2.x.y
HDNode.fromBuffer = function(buffer, __ignoreDeprecation) {
if (!__ignoreDeprecation) {
console.warn('HDNode.fromBuffer() is deprecated for removal in 2.x.y, use fromBase58 instead')
}

assert.strictEqual(buffer.length, HDNode.LENGTH, 'Invalid buffer length')

// 4 byte: version bytes
Expand Down Expand Up @@ -127,6 +132,7 @@ HDNode.fromBuffer = function(buffer) {
return hd
}

// FIXME: remove in 2.x.y
HDNode.fromHex = function(hex) {
return HDNode.fromBuffer(new Buffer(hex, 'hex'))
}
Expand All @@ -153,10 +159,11 @@ HDNode.prototype.neutered = function() {
}

HDNode.prototype.toBase58 = function(isPrivate) {
return base58check.encode(this.toBuffer(isPrivate))
return base58check.encode(this.toBuffer(isPrivate, true))
}

HDNode.prototype.toBuffer = function(isPrivate) {
// FIXME: remove in 2.x.y
HDNode.prototype.toBuffer = function(isPrivate, __ignoreDeprecation) {
if (isPrivate == undefined) {
isPrivate = !!this.privKey

Expand All @@ -165,6 +172,10 @@ HDNode.prototype.toBuffer = function(isPrivate) {
console.warn('isPrivate flag is deprecated, please use the .neutered() method instead')
}

if (!__ignoreDeprecation) {
console.warn('HDNode.toBuffer() is deprecated for removal in 2.x.y, use toBase58 instead')
}

// Version
var version = isPrivate ? this.network.bip32.private : this.network.bip32.public
var buffer = new Buffer(HDNode.LENGTH)
Expand Down Expand Up @@ -204,6 +215,7 @@ HDNode.prototype.toBuffer = function(isPrivate) {
return buffer
}

// FIXME: remove in 2.x.y
HDNode.prototype.toHex = function(isPrivate) {
return this.toBuffer(isPrivate).toString('hex')
}
Expand Down