more lazy loading.

This commit is contained in:
Christopher Jeffrey 2016-02-23 20:06:07 -08:00
parent b6e32ecaf8
commit 72a877cc49

View File

@ -674,22 +674,30 @@ HDPrivateKey.prototype._build = function _build(data) {
this.fingerPrint = null;
this.hdPrivateKey = this;
this.hdPublicKey = new HDPublicKey({
network: this.network,
data: {
version: network[this.network].prefixes.xpubkey,
depth: this.depth,
parentFingerPrint: this.parentFingerPrint,
childIndex: this.childIndex,
chainCode: this.chainCode,
checksum: this.checksum,
publicKey: this.publicKey
}
});
this.xpubkey = this.hdPublicKey.xpubkey;
};
HDPrivateKey.prototype.__defineGetter__('hdPublicKey', function() {
if (!this._hdPublicKey) {
this._hdPublicKey = new HDPublicKey({
network: this.network,
data: {
version: network[this.network].prefixes.xpubkey,
depth: this.depth,
parentFingerPrint: this.parentFingerPrint,
childIndex: this.childIndex,
chainCode: this.chainCode,
checksum: this.checksum,
publicKey: this.publicKey
}
});
}
return this._hdPublicKey;
});
HDPrivateKey.prototype.__defineGetter__('xpubkey', function() {
return this.hdPublicKey.xpubkey;
});
HDPrivateKey.prototype.derive = function derive(index, hardened) {
var cached, data, hash, leftPart, chainCode, privateKey, child;
var off = 0;