Skip to content
This repository has been archived by the owner on Mar 7, 2023. It is now read-only.

Commit

Permalink
feat(Metadata): handle metadata hd node on payload
Browse files Browse the repository at this point in the history
  • Loading branch information
Thore3 committed Apr 13, 2017
1 parent ebd7534 commit e2f4e5b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/blockchain-wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ var External = require('./external');
var AccountInfo = require('./account-info');
var Metadata = require('./metadata');
var constants = require('./constants');
var Bitcoin = require('bitcoinjs-lib');

// Wallet

Expand Down Expand Up @@ -58,6 +59,17 @@ function Wallet (object) {
}, {})
: {};

this._metadataHDNode = null;

if (obj.metadataHDNode) {
this._metadataHDNode = Bitcoin.HDNode.fromBase58(obj.metadataHDNode, constants.getNetwork());
} else if (!this.isUpgradedToHD) {
} else if (!this.isDoubleEncrypted) {
this._metadataHDNode = Metadata.deriveMetadataNode(this.hdwallet.getMasterHDNode());
} else {
console.warn('Second password required to prepare KV Store');
}

// tx_notes dictionary
this._tx_notes = obj.tx_notes || {};

Expand Down Expand Up @@ -408,6 +420,7 @@ Wallet.prototype.toJSON = function () {
sharedKey: this.sharedKey,
double_encryption: this.isDoubleEncrypted,
dpasswordhash: this.dpasswordhash,
metadataHDNode: this._metadataHDNode && this._metadataHDNode.toBase58(),
options: {
pbkdf2_iterations: this.pbkdf2_iterations,
fee_per_kb: this.fee_per_kb,
Expand Down

0 comments on commit e2f4e5b

Please sign in to comment.