Esempio n. 1
0
 def retrieve_seed_from_mnemonic(self):
     if os.path.isfile(self.mnemonic_filename):
         with open(self.mnemonic_filename, 'r') as f:
             seed_mnemonic = f.read()
             seed = mnemonic_to_seed(seed_mnemonic.strip())
         return seed
     return None
Esempio n. 2
0
    def recover_wallet(self):
        try:
            with open(self.wallet_info_filename, 'r') as myfile:
                data = pickle.load(myfile)

            if data and len(data[0]) != 5:
                logger.info('wallet.info is also corrupted, cannot recover')
                return False
        except Exception as e:
            logger.error('Wallet.info is corrupted')
            logger.exception(e)
            return False

        with open(self.wallet_dat_filename, "w+") as myfile:
            # FIXME: What is this? obsolete code?
            pass

        self.chain.my = []
        for wallets in data:
            words = wallets[0]
            addr = self.getnewaddress(addrtype='XMSS',
                                      SEED=mnemonic_to_seed(words))
            self.f_append_wallet(addr, True)
        return True
Esempio n. 3
0
 def test_mnemonic_to_seed_invalid_len_long(self):
     long_word_list = S1_Mne + ' circus'
     with self.assertRaises(ValueError):
         mnemonic_to_seed(long_word_list)
Esempio n. 4
0
 def test_mnemonic_to_seed_invalid_len_short(self):
     short_word_list = 'circus'
     with self.assertRaises(ValueError):
         mnemonic_to_seed(short_word_list)
Esempio n. 5
0
 def test_mnemonic_to_seed_invalid_word(self):
     bad_word_list = S1_Mne.replace('dragon', 'covfefe')
     with self.assertRaises(ValueError):
         mnemonic_to_seed(bad_word_list)
Esempio n. 6
0
 def test_mnemonic_to_seed(self):
     seed = mnemonic_to_seed(S1_Mne)
     self.assertEqual(seed, S1)