|
|
@ -13,10 +13,10 @@ var BIP32 = function BIP32() { |
|
|
|
return new BIP32(); |
|
|
|
} |
|
|
|
|
|
|
|
BIP32.prototype.fromRandom = function(network) { |
|
|
|
if (!network) |
|
|
|
network = 'mainnet'; |
|
|
|
this.version = constants[network].bip32privkey; |
|
|
|
BIP32.prototype.fromRandom = function(networkstr) { |
|
|
|
if (!networkstr) |
|
|
|
networkstr = 'mainnet'; |
|
|
|
this.version = constants[networkstr].bip32privkey; |
|
|
|
this.depth = 0x00; |
|
|
|
this.parentFingerprint = 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; |
|
|
|
}; |
|
|
|
|
|
|
|
BIP32.prototype.fromSeed = function(bytes, network) { |
|
|
|
if (!network) |
|
|
|
network = 'mainnet'; |
|
|
|
BIP32.prototype.fromSeed = function(bytes, networkstr) { |
|
|
|
if (!networkstr) |
|
|
|
networkstr = 'mainnet'; |
|
|
|
|
|
|
|
if (!Buffer.isBuffer(bytes)) |
|
|
|
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.childIndex = new Buffer([0, 0, 0, 0]); |
|
|
|
this.chainCode = hash.slice(32, 64); |
|
|
|
this.version = constants[network].bip32privkey; |
|
|
|
this.version = constants[networkstr].bip32privkey; |
|
|
|
this.key = new Key(); |
|
|
|
this.key.privkey = new Privkey({bn: bn.fromBuffer(hash.slice(0, 32))}); |
|
|
|
this.key.privkey2pubkey(); |
|
|
|