Browse Source

refactor code

patch-2
Manuel Araoz 10 years ago
parent
commit
21266570d4
  1. 20
      lib/hdprivatekey.js

20
lib/hdprivatekey.js

@ -365,6 +365,15 @@ HDPrivateKey.fromSeed = function(hexa, network) {
});
};
HDPrivateKey.prototype._calcHDPublicKey = function() {
if (!this._hdPublicKey) {
var HDPublicKey = require('./hdpublickey');
this._hdPublicKey = new HDPublicKey(this);
}
};
/**
* Receives a object with buffers in all the properties and populates the
* internal structure
@ -424,14 +433,12 @@ HDPrivateKey.prototype._buildFromBuffers = function(arg) {
});
this._hdPublicKey = null;
Object.defineProperty(this, 'hdPublicKey', {
configurable: false,
enumerable: true,
get: function() {
if (!this._hdPublicKey) {
var HDPublicKey = require('./hdpublickey');
this._hdPublicKey = new HDPublicKey(this);
}
this._calcHDPublicKey();
return this._hdPublicKey;
}
});
@ -439,10 +446,7 @@ HDPrivateKey.prototype._buildFromBuffers = function(arg) {
configurable: false,
enumerable: true,
get: function() {
if (!this._hdPublicKey) {
var HDPublicKey = require('./hdpublickey');
this._hdPublicKey = new HDPublicKey(this);
}
this._calcHDPublicKey();
return this._hdPublicKey.xpubkey;
}
});

Loading…
Cancel
Save