mnemonic: better parsing.
This commit is contained in:
parent
bff9e25796
commit
50b8dd2b2c
@ -475,17 +475,21 @@ Mnemonic.prototype.toRaw = function toRaw(writer) {
|
||||
*/
|
||||
|
||||
Mnemonic.prototype.fromReader = function fromReader(br) {
|
||||
this.bits = br.readU16();
|
||||
this.language = Mnemonic.languages[br.readU8()];
|
||||
this.entropy = br.readBytes(this.bits / 8);
|
||||
const bits = br.readU16();
|
||||
|
||||
assert(bits >= common.MIN_ENTROPY);
|
||||
assert(bits <= common.MAX_ENTROPY);
|
||||
assert(bits % 32 === 0);
|
||||
|
||||
const language = Mnemonic.languages[br.readU8()];
|
||||
assert(language);
|
||||
|
||||
this.bits = bits;
|
||||
this.language = language;
|
||||
this.entropy = br.readBytes(bits / 8);
|
||||
this.phrase = br.readVarString('utf8');
|
||||
this.passphrase = br.readVarString('utf8');
|
||||
|
||||
assert(this.language);
|
||||
assert(this.bits >= common.MIN_ENTROPY);
|
||||
assert(this.bits <= common.MAX_ENTROPY);
|
||||
assert(this.bits % 32 === 0);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user