@@ -72,10 +72,15 @@ HDNode.fromSeedHex = function(hex, network) {
72
72
}
73
73
74
74
HDNode . fromBase58 = function ( string ) {
75
- return HDNode . fromBuffer ( base58check . decode ( string ) )
75
+ return HDNode . fromBuffer ( base58check . decode ( string ) , true )
76
76
}
77
77
78
- HDNode . fromBuffer = function ( buffer ) {
78
+ // FIXME: remove in 2.x.y
79
+ HDNode . fromBuffer = function ( buffer , __ignoreDeprecation ) {
80
+ if ( ! __ignoreDeprecation ) {
81
+ console . warn ( 'HDNode.fromBuffer() is deprecated for removal in 2.x.y, use fromBase58 instead' )
82
+ }
83
+
79
84
assert . strictEqual ( buffer . length , HDNode . LENGTH , 'Invalid buffer length' )
80
85
81
86
// 4 byte: version bytes
@@ -127,6 +132,7 @@ HDNode.fromBuffer = function(buffer) {
127
132
return hd
128
133
}
129
134
135
+ // FIXME: remove in 2.x.y
130
136
HDNode . fromHex = function ( hex ) {
131
137
return HDNode . fromBuffer ( new Buffer ( hex , 'hex' ) )
132
138
}
@@ -153,10 +159,11 @@ HDNode.prototype.neutered = function() {
153
159
}
154
160
155
161
HDNode . prototype . toBase58 = function ( isPrivate ) {
156
- return base58check . encode ( this . toBuffer ( isPrivate ) )
162
+ return base58check . encode ( this . toBuffer ( isPrivate , true ) )
157
163
}
158
164
159
- HDNode . prototype . toBuffer = function ( isPrivate ) {
165
+ // FIXME: remove in 2.x.y
166
+ HDNode . prototype . toBuffer = function ( isPrivate , __ignoreDeprecation ) {
160
167
if ( isPrivate == undefined ) {
161
168
isPrivate = ! ! this . privKey
162
169
@@ -165,6 +172,10 @@ HDNode.prototype.toBuffer = function(isPrivate) {
165
172
console . warn ( 'isPrivate flag is deprecated, please use the .neutered() method instead' )
166
173
}
167
174
175
+ if ( ! __ignoreDeprecation ) {
176
+ console . warn ( 'HDNode.toBuffer() is deprecated for removal in 2.x.y, use toBase58 instead' )
177
+ }
178
+
168
179
// Version
169
180
var version = isPrivate ? this . network . bip32 . private : this . network . bip32 . public
170
181
var buffer = new Buffer ( HDNode . LENGTH )
@@ -204,6 +215,7 @@ HDNode.prototype.toBuffer = function(isPrivate) {
204
215
return buffer
205
216
}
206
217
218
+ // FIXME: remove in 2.x.y
207
219
HDNode . prototype . toHex = function ( isPrivate ) {
208
220
return this . toBuffer ( isPrivate ) . toString ( 'hex' )
209
221
}
0 commit comments