network -> networkstr

This commit is contained in:
Ryan X. Charles 2014-08-28 17:55:33 -07:00
parent 280578d641
commit 2ef5e2f003
2 changed files with 10 additions and 10 deletions

View File

@ -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();

View File

@ -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() {