How to use the mnemonic.mnemonic.ConfigurationError function in mnemonic

To help you get started, we’ve selected a few mnemonic examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github trezor / python-mnemonic / mnemonic / mnemonic.py View on Github external
def detect_language(cls, code):
        code = cls.normalize_string(code)
        first = code.split(" ")[0]
        languages = cls.list_languages()

        for lang in languages:
            mnemo = cls(lang)
            if first in mnemo.wordlist:
                return lang

        raise ConfigurationError("Language not detected")
github trezor / python-mnemonic / mnemonic / mnemonic.py View on Github external
def __init__(self, language):
        self.radix = 2048
        if sys.version < "3":
            with open("%s/%s.txt" % (self._get_directory(), language), "r") as f:
                self.wordlist = [w.strip().decode("utf8") for w in f.readlines()]
        else:
            with open(
                "%s/%s.txt" % (self._get_directory(), language), "r", encoding="utf-8"
            ) as f:
                self.wordlist = [w.strip() for w in f.readlines()]
        if len(self.wordlist) != self.radix:
            raise ConfigurationError(
                "Wordlist should contain %d words, but it contains %d words."
                % (self.radix, len(self.wordlist))
            )
github 21dotco / two1-python / two1 / wallet / cli.py View on Github external
def check_mnemonic(mnemonic):
        try:
            return Mnemonic(language='english').check(mnemonic)
        except ConfigurationError:
            return False
    if not check_mnemonic(mnemonic):