diff --git a/src/cpp/wallet/py_monero_wallet_rpc.cpp b/src/cpp/wallet/py_monero_wallet_rpc.cpp index 37e4702..74e5515 100644 --- a/src/cpp/wallet/py_monero_wallet_rpc.cpp +++ b/src/cpp/wallet/py_monero_wallet_rpc.cpp @@ -1264,14 +1264,15 @@ std::string PyMoneroWalletRpc::get_tx_key(const std::string& tx_hash) const { std::shared_ptr PyMoneroWalletRpc::check_tx_key(const std::string& tx_hash, const std::string& tx_key, const std::string& address) const { try { - auto params = std::make_shared(tx_hash, tx_key, address); - PyMoneroJsonRequest request("check_tx_key", params); - auto response = m_rpc->send_json_request(request); - if (response->m_result == boost::none) throw std::runtime_error("Invalid Monero JSONRPC response"); - auto node = response->m_result.get(); - auto check = std::make_shared(); - PyMoneroCheckTxProof::from_property_tree(node, check); - return check; + auto params = std::make_shared(tx_hash, tx_key, address); + PyMoneroJsonRequest request("check_tx_key", params); + auto response = m_rpc->send_json_request(request); + if (response->m_result == boost::none) throw std::runtime_error("Invalid Monero JSONRPC response"); + auto node = response->m_result.get(); + auto check = std::make_shared(); + check->m_is_good = true; + PyMoneroCheckTxProof::from_property_tree(node, check); + return check; } catch (const PyMoneroRpcError& ex) { if (ex.code == -8 && ex.what() == std::string("TX ID has invalid format")) { // normalize error message diff --git a/tests/test_monero_wallet_common.py b/tests/test_monero_wallet_common.py index f6889c5..b184132 100644 --- a/tests/test_monero_wallet_common.py +++ b/tests/test_monero_wallet_common.py @@ -16,7 +16,7 @@ MoneroOutputQuery, MoneroTransfer, MoneroIncomingTransfer, MoneroOutgoingTransfer, MoneroTxWallet, MoneroOutputWallet, MoneroTx, MoneroAccount, MoneroSubaddress, MoneroMessageSignatureType, MoneroTxPriority, MoneroFeeEstimate, - MoneroIntegratedAddress, MoneroCheckTx, MoneroCheckReserve + MoneroIntegratedAddress, MoneroCheckTx, MoneroCheckReserve, MoneroSubmitTxResult ) from utils import ( TestUtils, WalletEqualityUtils, @@ -3318,6 +3318,57 @@ def test_input_key_images(self, wallet: MoneroWallet) -> None: assert max_skipped_output.amount is not None assert max_skipped_output.amount < TxUtils.MAX_FEE + # Can prove unrelayed txs + @pytest.mark.skipif(TestUtils.TEST_NON_RELAYS is False, reason="TEST_NON_RELAYS disabled") + def test_prove_unrelayed_txs(self, daemon: MoneroDaemonRpc, wallet: MoneroWallet) -> None: + # create unrelayed tx to verify + address1: str = WalletUtils.get_external_wallet_address() + address2: str = wallet.get_address(0, 0) + address3: str = wallet.get_address(1, 0) + tx_config: MoneroTxConfig = MoneroTxConfig() + tx_config.account_index = 0 + tx_config.destinations.append(MoneroDestination(address1, TxUtils.MAX_FEE)) + tx_config.destinations.append(MoneroDestination(address2, TxUtils.MAX_FEE * 2)) + tx_config.destinations.append(MoneroDestination(address3, TxUtils.MAX_FEE * 3)) + tx: MoneroTxWallet = wallet.create_tx(tx_config) + assert tx.full_hex is not None + assert tx.hash is not None + assert tx.key is not None + + # submit tx to daemon but do not relay + result: MoneroSubmitTxResult = daemon.submit_tx_hex(tx.full_hex, True) + assert result.is_good + + # create random wallet to verify transfers + verifying_wallet: MoneroWallet = self._create_wallet(MoneroWalletConfig()) + + # verify transfer 1 + check: MoneroCheckTx = verifying_wallet.check_tx_key(tx.hash, tx.key, address1) + assert check.is_good + assert check.in_tx_pool is True + assert check.num_confirmations == 0 + assert check.received_amount == TxUtils.MAX_FEE + + # verify transfer 2 + check = verifying_wallet.check_tx_key(tx.hash, tx.key, address2) + assert check.is_good + assert check.in_tx_pool is True + assert check.num_confirmations == 0 + # + change amount + assert check.received_amount is not None + assert check.received_amount >= TxUtils.MAX_FEE * 2 + + # verify transfer 3 + check = verifying_wallet.check_tx_key(tx.hash, tx.key, address3) + assert check.is_good + assert check.in_tx_pool is True + assert check.num_confirmations == 0 + assert TxUtils.MAX_FEE * 3 == check.received_amount + + # cleanup + daemon.flush_tx_pool(tx.hash) + self._close_wallet(verifying_wallet) + # Can get the default fee priority @pytest.mark.skipif(TestUtils.TEST_NON_RELAYS is False, reason="TEST_NON_RELAYS disabled") def test_get_default_fee_priority(self, wallet: MoneroWallet) -> None: diff --git a/tests/test_monero_wallet_keys.py b/tests/test_monero_wallet_keys.py index ee4a1b6..8e325d8 100644 --- a/tests/test_monero_wallet_keys.py +++ b/tests/test_monero_wallet_keys.py @@ -497,6 +497,11 @@ def test_sweep_wallet_by_accounts(self, wallet: MoneroWallet) -> None: def test_sweep_wallet_by_subaddresses(self, wallet: MoneroWallet) -> None: return super().test_sweep_wallet_by_subaddresses(wallet) + @pytest.mark.not_supported + @override + def test_prove_unrelayed_txs(self, daemon: MoneroDaemonRpc, wallet: MoneroWallet) -> None: + return super().test_prove_unrelayed_txs(daemon, wallet) + #endregion #region Tests diff --git a/tests/utils/wallet_utils.py b/tests/utils/wallet_utils.py index 6209252..0973407 100644 --- a/tests/utils/wallet_utils.py +++ b/tests/utils/wallet_utils.py @@ -219,7 +219,7 @@ def get_external_wallet_address(cls) -> str: :returns str: external wallet address """ - network_type: MoneroNetworkType | None = TestUtils.get_daemon_rpc().get_info().network_type + network_type: MoneroNetworkType | None = TestUtils.NETWORK_TYPE if network_type == MoneroNetworkType.STAGENET: # subaddress