WIP for automatic network join

This commit is contained in:
Manuel Araoz 2014-04-18 14:40:16 -03:00
commit d62dbeffca
12 changed files with 73 additions and 76 deletions

View file

@ -16,13 +16,17 @@ function PrivateKey(opts) {
var init = opts.extendedPrivateKeyString || this.network.name;
this.bip = opts.BIP32 || new BIP32(init);
this.privateKeyCache = opts.privateKeyCache || {};
this._calcId();
};
PrivateKey.prototype._calcId = function() {
this.id = util.ripe160(this.bip.extendedPublicKey).toString('hex');
PrivateKey.prototype.getId = function(prefix) {
var buf = this.bip.extendedPublicKey;
if (prefix) {
buf = Buffer.concat([prefix, this.bip.extendedPublicKey]);
}
return util.ripe160(buf).toString('hex');
};
PrivateKey.fromObj = function(obj) {
return new PrivateKey(obj);
};