HDKeys: Added toObject method and changed toJSON to return a string
This commit is contained in:
parent
19a17017a9
commit
1c0caac8c3
@ -406,7 +406,7 @@ HDPrivateKey.prototype.toString = function() {
|
|||||||
*
|
*
|
||||||
* @return {Object}
|
* @return {Object}
|
||||||
*/
|
*/
|
||||||
HDPrivateKey.prototype.toJSON = function() {
|
HDPrivateKey.prototype.toObject = function toObject() {
|
||||||
return {
|
return {
|
||||||
network: Network.get(BufferUtil.integerFromBuffer(this._buffers.version)).name,
|
network: Network.get(BufferUtil.integerFromBuffer(this._buffers.version)).name,
|
||||||
depth: BufferUtil.integerFromSingleByteBuffer(this._buffers.depth),
|
depth: BufferUtil.integerFromSingleByteBuffer(this._buffers.depth),
|
||||||
@ -420,6 +420,10 @@ HDPrivateKey.prototype.toJSON = function() {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
HDPrivateKey.prototype.toJSON = function toJSON() {
|
||||||
|
return JSON.stringify(this.toObject());
|
||||||
|
};
|
||||||
|
|
||||||
HDPrivateKey.DefaultDepth = 0;
|
HDPrivateKey.DefaultDepth = 0;
|
||||||
HDPrivateKey.DefaultFingerprint = 0;
|
HDPrivateKey.DefaultFingerprint = 0;
|
||||||
HDPrivateKey.DefaultChildIndex = 0;
|
HDPrivateKey.DefaultChildIndex = 0;
|
||||||
|
|||||||
@ -366,7 +366,7 @@ HDPublicKey.prototype.toString = function () {
|
|||||||
* * xpubkey: the string with the base58 representation of this extended key
|
* * xpubkey: the string with the base58 representation of this extended key
|
||||||
* * checksum: the base58 checksum of xpubkey
|
* * checksum: the base58 checksum of xpubkey
|
||||||
*/
|
*/
|
||||||
HDPublicKey.prototype.toJSON = function () {
|
HDPublicKey.prototype.toObject = function toObject() {
|
||||||
return {
|
return {
|
||||||
network: Network.get(BufferUtil.integerFromBuffer(this._buffers.version)).name,
|
network: Network.get(BufferUtil.integerFromBuffer(this._buffers.version)).name,
|
||||||
depth: BufferUtil.integerFromSingleByteBuffer(this._buffers.depth),
|
depth: BufferUtil.integerFromSingleByteBuffer(this._buffers.depth),
|
||||||
@ -380,6 +380,10 @@ HDPublicKey.prototype.toJSON = function () {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
HDPublicKey.prototype.toJSON = function toJSON() {
|
||||||
|
return JSON.stringify(this.toObject());
|
||||||
|
};
|
||||||
|
|
||||||
HDPublicKey.Hardened = 0x80000000;
|
HDPublicKey.Hardened = 0x80000000;
|
||||||
HDPublicKey.RootElementAlias = ['m', 'M'];
|
HDPublicKey.RootElementAlias = ['m', 'M'];
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user