ilap / slip39-js

The javascript implementation of the SLIP39 for Shamir's Secret-Sharing for Mnemonic Codes.
MIT License
69 stars 27 forks source link

Throw exception on invalid words #7

Closed Auronmatrix closed 5 years ago

Auronmatrix commented 5 years ago

The current mnemonicToIndices method doesn't throw an exception when a word can't be mapped to an index. Instead it returns 'undefined' as the index. In the end the checksum at the end fails. This error is slightly misleading.

In order to debug what was wrong I needed to log the output of the mapping to notice the 'undefined' value.

Proposed explicitly throwing an exception when a word can't be mapped, clearly indicating which word is problematic.