What changed, and why it matters
This change refactors how Monero's wallet fetches transaction data when creating or verifying 'spend proofs'—cryptographic receipts that prove you spent funds. Previously, spend-proof code fetched transactions directly from the network daemon in two separate places. Now it uses a single helper function, and importantly, that helper now passes through a configurable network timeout and reports daemon errors more precisely. The commit title says the goal is to bind v1 spend proofs to the requested transaction, suggesting the previous code may have used the wrong transaction under some edge cases. However, the diff itself does not show a clear bug being fixed; it mostly consolidates duplicated code and tightens error handling.
Treat as a routine correctness/hardening fix. Review the full PR #11696 discussion and any release notes to confirm whether this addressed an exploitable proof-forgery or wrong-transaction issue. If running a wallet that creates or verifies spend proofs, update to the patched version once it is included in a release. No immediate emergency action is warranted based solely on this diff.
Security signals we found
Refactoring of spend-proof transaction lookup to a single helper
Addition of explicit RPC timeout parameter to transaction fetch helper
Improved daemon RPC error/status reporting in get_tx_for_proof
Commit title implies binding of v1 spend proofs to requested transaction
No explicit vulnerability description or CVE in commit message
Evidence from the diff
The patch removes inline RPC calls to /gettransactions from get_spend_proof() and check_spend_proof(), replacing them with a call to the existing helper get_tx_for_proof(). It also updates get_tx_for_proof() to accept an optional timeout parameter and to use THROW_ON_RPC_RESPONSE_ERROR for status checking. The header signature changes from no timeout to a default 15-second timeout. The stated intent (per PR title) is to ensure v1 spend proofs are bound to the transaction the caller actually requested, but the diff does not visibly alter hash comparison logic beyond moving it into the helper. The previous helper already compared tx_hash to txid; that comparison remains. The main observable security-relevant change is improved error propagation and timeout handling when talking to a possibly untrusted daemon.
Changed components
src/wallet/wallet2.cppsrc/wallet/wallet2.hwallet2::get_spend_proofwallet2::check_spend_proofwallet2::get_tx_for_proofInspect captured patch +9 / −42
### src/wallet/wallet2.cpp
@@ -12489,26 +12489,8 @@ std::string wallet2::get_spend_proof(const crypto::hash &txid, const std::string
THROW_WALLET_EXCEPTION_IF(m_watch_only, error::wallet_internal_error,
"get_spend_proof requires spend secret key and is not available for a watch-only wallet");
- // fetch tx from daemon
- COMMAND_RPC_GET_TRANSACTIONS::request req = AUTO_VAL_INIT(req);
- req.txs_hashes.push_back(epee::string_tools::pod_to_hex(txid));
- req.decode_as_json = false;
- req.prune = true;
- COMMAND_RPC_GET_TRANSACTIONS::response res = AUTO_VAL_INIT(res);
- bool r;
- {
- const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
- r = epee::net_utils::invoke_http_json("/gettransactions", req, res, *m_http_client, rpc_timeout);
- THROW_ON_RPC_RESPONSE_ERROR(r, {}, res, "gettransactions", error::wallet_generic_rpc_error, "gettransactions", get_rpc_status(m_trusted_daemon, res.status));
- THROW_WALLET_EXCEPTION_IF(res.txs.size() != 1, error::wallet_internal_error,
- "daemon returned wrong response for gettransactions, wrong txs count = " +
- std::to_string(res.txs.size()) + ", expected 1");
- }
-
cryptonote::transaction tx;
- crypto::hash tx_hash;
- THROW_WALLET_EXCEPTION_IF(!get_pruned_tx(res.txs[0], tx, tx_hash), error::wallet_internal_error, "Failed to get tx from daemon");
- THROW_WALLET_EXCEPTION_IF(tx_hash != txid, error::wallet_internal_error, "Failed to get the right transaction from daemon");
+ get_tx_for_proof(txid, tx, rpc_timeout);
THROW_WALLET_EXCEPTION_IF(tx.is_coinbase(), error::wallet_internal_error, "Cannot generate spend proof for a coinbase transaction");
std::vector<std::vector<crypto::signature>> signatures;
@@ -12607,26 +12589,8 @@ bool wallet2::check_spend_proof(const crypto::hash &txid, const std::string &mes
THROW_WALLET_EXCEPTION_IF(sig_str.size() < header_len || sig_str.substr(0, header_len) != header, error::wallet_internal_error,
"Signature header check error");
- // fetch tx from daemon
- COMMAND_RPC_GET_TRANSACTIONS::request req = AUTO_VAL_INIT(req);
- req.txs_hashes.push_back(epee::string_tools::pod_to_hex(txid));
- req.decode_as_json = false;
- req.prune = true;
- COMMAND_RPC_GET_TRANSACTIONS::response res = AUTO_VAL_INIT(res);
- bool r;
- {
- const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
- r = epee::net_utils::invoke_http_json("/gettransactions", req, res, *m_http_client, rpc_timeout);
- THROW_ON_RPC_RESPONSE_ERROR(r, {}, res, "gettransactions", error::wallet_generic_rpc_error, "gettransactions", get_rpc_status(m_trusted_daemon, res.status));
- THROW_WALLET_EXCEPTION_IF(res.txs.size() != 1, error::wallet_internal_error,
- "daemon returned wrong response for gettransactions, wrong txs count = " +
- std::to_string(res.txs.size()) + ", expected 1");
- }
-
cryptonote::transaction tx;
- crypto::hash tx_hash;
- THROW_WALLET_EXCEPTION_IF(!get_pruned_tx(res.txs[0], tx, tx_hash), error::wallet_internal_error, "failed to get tx from daemon");
- THROW_WALLET_EXCEPTION_IF(tx_hash != txid, error::wallet_internal_error, "Failed to get the right transaction from daemon");
+ get_tx_for_proof(txid, tx, rpc_timeout);
// check signature size
size_t num_sigs = 0;
@@ -12827,7 +12791,7 @@ bool wallet2::is_out_to_acc(const cryptonote::account_public_address &address, c
return found;
}
-COMMAND_RPC_GET_TRANSACTIONS::entry wallet2::get_tx_for_proof(const crypto::hash &txid, cryptonote::transaction &tx)
+COMMAND_RPC_GET_TRANSACTIONS::entry wallet2::get_tx_for_proof(const crypto::hash &txid, cryptonote::transaction &tx, std::chrono::milliseconds timeout)
{
COMMAND_RPC_GET_TRANSACTIONS::request req;
req.txs_hashes.push_back(epee::string_tools::pod_to_hex(txid));
@@ -12840,8 +12804,10 @@ COMMAND_RPC_GET_TRANSACTIONS::entry wallet2::get_tx_for_proof(const crypto::hash
bool ok;
{
const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
- ok = net_utils::invoke_http_json("/gettransactions", req, res, *m_http_client);
- THROW_WALLET_EXCEPTION_IF(!ok || res.txs.size() != 1,
+ ok = net_utils::invoke_http_json("/gettransactions", req, res, *m_http_client, timeout);
+ THROW_ON_RPC_RESPONSE_ERROR(ok, {}, res, "gettransactions", error::wallet_generic_rpc_error,
+ "gettransactions", get_rpc_status(m_trusted_daemon, res.status));
+ THROW_WALLET_EXCEPTION_IF(res.txs.size() != 1,
error::wallet_internal_error, "Failed to get transaction from daemon");
}
### src/wallet/wallet2.h
@@ -1591,7 +1591,8 @@ namespace tools
void handle_reorg(uint64_t height, std::map<std::pair<uint64_t, uint64_t>, size_t> *output_tracker_cache = NULL);
void get_short_chain_history(std::list<crypto::hash>& ids, uint64_t granularity = 1) const;
bool clear();
- cryptonote::COMMAND_RPC_GET_TRANSACTIONS::entry get_tx_for_proof(const crypto::hash &txid, cryptonote::transaction &tx);
+ cryptonote::COMMAND_RPC_GET_TRANSACTIONS::entry get_tx_for_proof(const crypto::hash &txid, cryptonote::transaction &tx,
+ std::chrono::milliseconds timeout = std::chrono::seconds(15));
void clear_soft(bool keep_key_images=false);
/*
* clear_user_data clears data created by the user, which is mostly dataWhy this scored 57/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.