def test_wallet_addr(self): addr = monero.encode_addr( monero.net_version(), binascii.unhexlify( b"3bec484c5d7f0246af520aab550452b5b6013733feabebd681c4a60d457b7fc1" ), binascii.unhexlify( b"2d5918e31d3c003da3c778592c07b398ad6f961a67082a75fd49394d51e69bbe" ), ) self.assertEqual( addr, b"43tpGG9PKbwCpjRvNLn1jwXPpnacw2uVUcszAtgmDiVcZK4VgHwjJT9BJz1WGF9eMxSYASp8yNMkuLjeQfWqJn3CNWdWfzV", ) w = monero.AccountCreds.new_wallet( crypto.b16_to_scalar( b"4ce88c168e0f5f8d6524f712d5f8d7d83233b1e7a2a60b5aba5206cc0ea2bc08" ), crypto.b16_to_scalar( b"f2644a3dd97d43e87887e74d1691d52baa0614206ad1b0c239ff4aa3b501750a" ), network_type=monero.NetworkTypes.TESTNET, ) self.assertEqual( w.address, b"9vacMKaj8JJV6MnwDzh2oNVdwTLJfTDyNRiB6NzV9TT7fqvzLivH2dB8Tv7VYR3ncn8vCb3KdNMJzQWrPAF1otYJ9cPKpkr", )
async def check_existing_wallet_file(self, key_file): """ Checks existing wallet file correctness :param key_file: :return: """ wl = await wallet.load_keys_file(key_file, self.wallet_password) addr = wl["key_data"]["m_keys"]["m_account_address"] spend_pub = addr["m_spend_public_key"] view_pub = addr["m_view_public_key"] match = spend_pub == crypto.encodepoint( self.pub_spend) and view_pub == crypto.encodepoint(self.pub_view) net_ver = monero.net_version(self.network_type, False) addr = monero.encode_addr(net_ver, spend_pub, view_pub) return addr, match
async def key_image_sync(self, line): """ Key image sync with Trezor :param line: :return: """ res = self.wallet_proxy.export_outputs() outputs_data_hex = res["result"]["outputs_data_hex"] outs_data = binascii.unhexlify(outputs_data_hex) exps = await wallet.load_exported_outputs(self.priv_view, outs_data) # Check if for this address match = exps.m_spend_public_key == crypto.encodepoint( self.pub_spend) and exps.m_view_public_key == crypto.encodepoint( self.pub_view) net_ver = monero.net_version(self.network_type, False) addr = monero.encode_addr(net_ver, exps.m_spend_public_key, exps.m_view_public_key) if not match: logger.error("Exported outputs from different wallet: %s" % addr.decode("ascii")) return self.poutput("Exported outputs loaded.") self.poutput("Please confirm the key image sync on the Trezor ") res = await self.agent.import_outputs(exps.tds) # Generate import key image requests key_images = [] for kie in res: key_images.append({ "key_image": binascii.hexlify(kie[0]).decode("ascii"), "signature": binascii.hexlify(kie[1][0] + kie[1][1]).decode("ascii"), }) import_req = {"signed_key_images": key_images} res = self.wallet_proxy.import_key_images(import_req) print("Height: %s" % res["result"]["height"]) print("Spent: %.5f" % wallet.conv_disp_amount(res["result"]["spent"])) print("Unspent: %.5f" % wallet.conv_disp_amount(res["result"]["unspent"]))