Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@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)
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
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
def get_seed(seed_words):
return mnemonic.mn_decode(seed_words.split(' '))
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