Browse Source

network -> networkstr

patch-2
Ryan X. Charles 11 years ago
parent
commit
2ef5e2f003
  1. 16
      lib/bip32.js
  2. 4
      lib/key.js

16
lib/bip32.js

@ -13,10 +13,10 @@ var BIP32 = function BIP32() {
return new BIP32(); return new BIP32();
} }
BIP32.prototype.fromRandom = function(network) { BIP32.prototype.fromRandom = function(networkstr) {
if (!network) if (!networkstr)
network = 'mainnet'; networkstr = 'mainnet';
this.version = constants[network].bip32privkey; this.version = constants[networkstr].bip32privkey;
this.depth = 0x00; this.depth = 0x00;
this.parentFingerprint = new Buffer([0, 0, 0, 0]); this.parentFingerprint = new Buffer([0, 0, 0, 0]);
this.childIndex = new Buffer([0, 0, 0, 0]); this.childIndex = new Buffer([0, 0, 0, 0]);
@ -46,9 +46,9 @@ BIP32.prototype.fromString = function(str) {
return this; return this;
}; };
BIP32.prototype.fromSeed = function(bytes, network) { BIP32.prototype.fromSeed = function(bytes, networkstr) {
if (!network) if (!networkstr)
network = 'mainnet'; networkstr = 'mainnet';
if (!Buffer.isBuffer(bytes)) if (!Buffer.isBuffer(bytes))
throw new Error('gcbytes must be a buffer'); throw new Error('gcbytes must be a buffer');
@ -62,7 +62,7 @@ BIP32.prototype.fromSeed = function(bytes, network) {
this.parentFingerprint = new Buffer([0, 0, 0, 0]); this.parentFingerprint = new Buffer([0, 0, 0, 0]);
this.childIndex = new Buffer([0, 0, 0, 0]); this.childIndex = new Buffer([0, 0, 0, 0]);
this.chainCode = hash.slice(32, 64); this.chainCode = hash.slice(32, 64);
this.version = constants[network].bip32privkey; this.version = constants[networkstr].bip32privkey;
this.key = new Key(); this.key = new Key();
this.key.privkey = new Privkey({bn: bn.fromBuffer(hash.slice(0, 32))}); this.key.privkey = new Privkey({bn: bn.fromBuffer(hash.slice(0, 32))});
this.key.privkey2pubkey(); this.key.privkey2pubkey();

4
lib/key.js

@ -40,8 +40,8 @@ Key.prototype.fromString = function(str) {
} }
}; };
Key.prototype.getAddress = function(network) { Key.prototype.getAddress = function(networkstr) {
return Address().fromPubkey(this.pubkey, network); return Address().fromPubkey(this.pubkey, networkstr);
}; };
Key.prototype.privkey2pubkey = function() { Key.prototype.privkey2pubkey = function() {

Loading…
Cancel
Save