minor refactor

This commit is contained in:
Christopher Jeffrey 2016-04-29 23:24:25 -07:00
parent 57ceeabd95
commit 65f99b736b
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
2 changed files with 8 additions and 12 deletions

View File

@ -114,18 +114,12 @@ function Mnemonic(options) {
if (!options)
options = {};
if (Buffer.isBuffer(options)) {
this.seed = options;
options = {};
} else {
this.seed = null;
}
this.bits = options.bits || 128;
this.entropy = options.entropy;
this.phrase = options.phrase;
this.passphrase = options.passphrase || '';
this.lang = options.lang || 'english';
this.seed = null;
assert(this.bits >= 128);
assert(this.bits % 32 === 0);

View File

@ -73,13 +73,15 @@ utils.slice = function slice(buf, start, end) {
* Base58
*/
var base58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZ'
var base58 = ''
+ '123456789'
+ 'ABCDEFGHJKLMNPQRSTUVWXYZ'
+ 'abcdefghijkmnopqrstuvwxyz';
var unbase58 = base58.split('').reduce(function(out, ch, i) {
out[ch] = i;
return out;
}, {});
var unbase58 = {};
for (var i = 0; i < base58.length; i++)
unbase58[base58[i]] = i;
/**
* Encode a base58 string.