示例#1
0
 def test_import_account(self):
     wm = WalletManager(wallet_path=self.path)
     self.assertEqual(self.path, wm.wallet_path)
     wm.create_wallet_file()
     try:
         wm.open_wallet()
         label = 'label'
         b64_salt = 'MGEzY2Y0MWYyODhhOTQ3MA=='
         encrypted_pri_key = 'E6Yb/UmgAggwqHrj/OVYjVVacVhXiehRctKrxzVE/bi+tZId0AEN2wLoKsahpNq2'
         b58_address = 'AazEvfQPcQ2GEFFPLF1ZLwQ7K5jDn81hve'
         account = wm.import_account(label, encrypted_pri_key, password,
                                     b58_address, b64_salt)
         acct = wm.get_account_by_b58_address(b58_address, password)
         self.assertTrue(isinstance(account, AccountData))
         self.assertTrue(isinstance(acct, Account))
         wm.save()
     finally:
         wm.del_wallet_file()
示例#2
0
 def test_get_account(self):
     wallet_manager = WalletManager()
     acct0 = wallet_manager.create_account(password)
     self.assertTrue(isinstance(acct0, Account))
     b58_address = wallet_manager.wallet_in_mem.default_account_address
     acct0 = wallet_manager.get_account_by_b58_address(
         b58_address, password)
     self.assertEqual(acct0.get_address_base58(), b58_address)
     self.assertRaises(SDKException,
                       wallet_manager.get_account_by_b58_address,
                       b58_address, 'wrong_password')
     base64_salt = 'S2JpQ1VyNTNDWlVmS0cxTTNHb2pqdz09'
     b58_address = 'AHX1wzvdw9Yipk7E9MuLY4GGX4Ym9tHeDe'
     encrypted_private_key = 'nw7qMrOEDsNurW3dKBruv3iNGeoZppSKe06QoqMZ9S8msoCvtn864rCSvAbgk1oS'
     label = 'label'
     acct1 = wallet_manager.import_account(label, encrypted_private_key,
                                           password, b58_address,
                                           base64_salt)
     self.assertEqual(b58_address, acct1.b58_address)
     import_acct = wallet_manager.get_account_by_b58_address(
         b58_address, password)
     self.assertEqual(b58_address, import_acct.get_address_base58())
     self.assertEqual(base64_salt, acct1.salt)