blockchain: return false from get_tx_outputs_gindexs on TX_DNE
What changed, and why it matters
This commit hardens a Monero blockchain lookup function so it returns a clean failure instead of letting an internal 'transaction does not exist' exception bubble up. The change makes the node more robust when asked about outputs for a transaction that is missing from the database, which could previously crash or abort the calling code path.
Apply the patch. Review all callers of get_tx_outputs_gindexs to ensure they handle a false return safely, and audit other database-access functions for similar unhandled TX_DNE exceptions.
Security signals we found
Unhandled exception path removed from database lookup
Function now returns false on missing-transaction error
Potential denial-of-service vector (crash via unhandled exception) mitigated
Evidence from the diff
Blockchain::get_tx_outputs_gindexs() now wraps m_db->get_tx_amount_output_indices() in a try/catch for TX_DNE (transaction does not exist). If the exception is thrown, the function logs an error and returns false rather than propagating the exception. This prevents unhandled-exception termination or unexpected control flow in callers that expect a boolean success/failure result.
Changed components
src/cryptonote_core/blockchain.cppBlockchain::get_tx_outputs_gindexsInspect captured patch +9 / −1
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp
index 1b8fca3..a6d153c 100644
--- a/src/cryptonote_core/blockchain.cpp
+++ b/src/cryptonote_core/blockchain.cpp
@@ -2967,7 +2967,15 @@ bool Blockchain::get_tx_outputs_gindexs(const crypto::hash& tx_id, size_t n_txes
MERROR_VER("get_tx_outputs_gindexs failed to find transaction with id = " << tx_id);
return false;
}
- indexs = m_db->get_tx_amount_output_indices(tx_index, n_txes);
+ try
+ {
+ indexs = m_db->get_tx_amount_output_indices(tx_index, n_txes);
+ }
+ catch (const TX_DNE& e)
+ {
+ MERROR_VER("get_tx_outputs_gindexs: " << e.what());
+ return false;
+ }
CHECK_AND_ASSERT_MES(n_txes == indexs.size(), false, "Wrong indexs size");
return true;
Why this scored 41/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.