コード例 #1
0
 def test_create_write(self):
     wm = WalletManager()
     wm.create_wallet_file(self.path)
     try:
         wm.open_wallet(self.path)
         random_password = utils.get_random_hex_str(10)
         label = 'label'
         wm.create_account(random_password, label)
         default_account = wm.get_default_account_data()
         self.assertEqual(label, default_account.label)
         wm.create_identity(random_password, label)
         default_identity = wm.get_default_identity()
         self.assertEqual(default_identity.label, label)
         wm.write_wallet()
     finally:
         wm.del_wallet_file()
コード例 #2
0
 def test_add_control_by_private_key(self):
     wm = WalletManager()
     wm.create_wallet_file(self.path)
     try:
         wm.open_wallet(self.path)
         private_key = utils.get_random_bytes(32)
         hex_private_key = private_key.hex()
         public_key = Signature.ec_get_public_key_by_private_key(
             private_key, Curve.P256)
         hex_public_key = public_key.hex()
         identity = wm.create_identity('label', password)
         wm.write_wallet()
         wm.add_control_by_hex_private_key(identity.ont_id, password,
                                           hex_private_key)
         ctrl_acct = wm.get_control_account_by_index(
             identity.ont_id, 1, password)
         acct_private_key = ctrl_acct.get_private_key_hex()
         acct_public_key = ctrl_acct.get_public_key_hex()
         self.assertEqual(hex_public_key, acct_public_key)
         self.assertEqual(hex_private_key, acct_private_key)
         ctrl_len_1 = len(wm.wallet_in_mem.identities[0].controls)
         ctrl_len_2 = len(wm.wallet_file.identities[0].controls)
         self.assertEqual(ctrl_len_1, ctrl_len_2 + 1)
     finally:
         wm.del_wallet_file()