How to use the mnemonic.mn_decode 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 spesmilo / electrum / lib / wallet_factory.py View on Github external
    @classmethod
    def from_seed(self, seed, storage):
        import mnemonic
        if not seed:
            return 

        words = seed.strip().split()
        try:
            mnemonic.mn_decode(words)
            uses_electrum_words = True
        except Exception:
            uses_electrum_words = False

        try:
            seed.decode('hex')
            is_hex = True
        except Exception:
            is_hex = False
         
        if is_hex or (uses_electrum_words and len(words) != 13):
            print "old style wallet", len(words), words
            w = OldWallet(storage)
            w.init_seed(seed) #hex
        else:
            #assert is_seed(seed)
github spesmilo / electrum / lib / gui_qt.py View on Github external
if not d.exec_(): return

        try:
            gap = int(unicode(gap_e.text()))
        except:
            QMessageBox.warning(None, _('Error'), 'error', 'OK')
            sys.exit(0)

        try:
            seed = unicode(seed_e.text())
            seed.decode('hex')
        except:
            print_error("Warning: Not hex, trying decode")
            try:
                seed = mnemonic.mn_decode( seed.split(' ') )
            except:
                QMessageBox.warning(None, _('Error'), _('I cannot decode this'), _('OK'))
                sys.exit(0)
        if not seed:
            QMessageBox.warning(None, _('Error'), _('No seed'), 'OK')
            sys.exit(0)
        
        wallet.seed = str(seed)
        #print repr(wallet.seed)
        wallet.gap_limit = gap
        return True
github monero-project / mininero / mininero.py View on Github external
def recoverSK(seed):
    mn2 = seed.split(" ") #make array
    if len(mn2) > 13:
        mn2 = mn2[:24]
        sk = mnemonic.mn_decode(mn2)
    else:
        mn2 = mn2[:12]
        #mn2 += mn2[:]
        sk = cn_fast_hash(mnemonic.mn_decode(mn2))
        #sk = mnemonic.mn_decode(mn2)

    return sk
github trezor-graveyard / trezor-emu / tools.py View on Github external
def get_seed(seed_words):
    return mnemonic.mn_decode(seed_words.split(' '))
github monero-project / mininero / mininero.py View on Github external
def recoverSK(seed):
    mn2 = seed.split(" ") #make array
    if len(mn2) > 13:
        mn2 = mn2[:24]
        sk = mnemonic.mn_decode(mn2)
    else:
        mn2 = mn2[:12]
        #mn2 += mn2[:]
        sk = cn_fast_hash(mnemonic.mn_decode(mn2))
        #sk = mnemonic.mn_decode(mn2)

    return sk