What changed, and why it matters
This commit is a routine cleanup that removes unused variables and adds one safety check. It fixes compiler warnings about variables being assigned but never read. The only functional change is a new error throw if a reserve proof signature fails to parse, which makes the wallet fail more cleanly instead of continuing with bad data. There is no indication this fixes an active security vulnerability.
Treat as a normal maintenance patch. Review and merge after standard CI passes. No urgent security response required.
Security signals we found
New validation guard added in reserve proof parsing path
Removal of dead code/unused variables only
No changes to consensus rules, cryptography, or network protocol handling
Evidence from the diff
The diff removes unused local variables (block_index, change, i, inner) in blockchain.cpp, simplewallet.cpp, wallet2.cpp, and a unit test. These were triggering compiler warnings. In wallet2::check_reserve_proof, a THROW_WALLET_EXCEPTION_IF(!loaded, ...) guard is added after a try/catch that parses reserve proof signature data, preventing continued execution when parsing failed. No cryptographic, consensus, or network behavior changes are evident.
Changed components
src/cryptonote_core/blockchain.cppsrc/simplewallet/simplewallet.cppsrc/wallet/wallet2.cpptests/unit_tests/epee_levin_protocol_handler_async.cppInspect captured patch +4 / −11
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp
index 387bae9..45f9b0a 100644
--- a/src/cryptonote_core/blockchain.cpp
+++ b/src/cryptonote_core/blockchain.cpp
@@ -5055,7 +5055,7 @@ bool Blockchain::prepare_handle_incoming_blocks(const std::vector<block_complete
} while(0); \
// generate sorted tables for all amounts and absolute offsets
- size_t tx_index = 0, block_index = 0;
+ size_t tx_index = 0;
for (const auto &entry : blocks_entry)
{
if (m_cancel)
@@ -5120,7 +5120,6 @@ bool Blockchain::prepare_handle_incoming_blocks(const std::vector<block_complete
}
}
- ++block_index;
}
// sort and remove duplicate absolute_offsets in offset_map
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index 4904059..0ea5ff8 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -6689,14 +6689,12 @@ bool simple_wallet::transfer_main(const std::vector<std::string> &args_, bool ca
uint64_t total_fee = 0;
uint64_t dust_not_in_fee = 0;
uint64_t dust_in_fee = 0;
- uint64_t change = 0;
for (size_t n = 0; n < ptx_vector.size(); ++n)
{
total_fee += ptx_vector[n].fee;
for (auto i: ptx_vector[n].selected_transfers)
total_sent += m_wallet->get_transfer_details(i).amount();
total_sent -= ptx_vector[n].change_dts.amount + ptx_vector[n].fee;
- change += ptx_vector[n].change_dts.amount;
if (ptx_vector[n].dust_added_to_fee)
dust_in_fee += ptx_vector[n].dust;
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index b073357..e1dd0a3 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -9730,7 +9730,7 @@ void wallet2::transfer_selected(const std::vector<cryptonote::tx_destination_ent
//prepare inputs
LOG_PRINT_L2("preparing outputs");
typedef cryptonote::tx_source_entry::output_entry tx_output_entry;
- size_t i = 0, out_index = 0;
+ size_t out_index = 0;
std::vector<cryptonote::tx_source_entry> sources;
for(size_t idx: selected_transfers)
{
@@ -9749,7 +9749,6 @@ void wallet2::transfer_selected(const std::vector<cryptonote::tx_destination_ent
oe.second.mask = std::get<2>(outs[out_index][n]);
src.outputs.push_back(oe);
- ++i;
}
//paste real transaction to the random index
@@ -9950,7 +9949,7 @@ void wallet2::transfer_selected_rct(std::vector<cryptonote::tx_destination_entry
//prepare inputs
LOG_PRINT_L2("preparing outputs");
- size_t i = 0, out_index = 0;
+ size_t out_index = 0;
std::vector<cryptonote::tx_source_entry> sources;
for(size_t idx: selected_transfers)
{
@@ -9973,7 +9972,6 @@ void wallet2::transfer_selected_rct(std::vector<cryptonote::tx_destination_entry
oe.second.mask = std::get<2>(outs[out_index][n]);
src.outputs.push_back(oe);
}
- ++i;
//paste real transaction to the random index
auto it_to_replace = std::find_if(src.outputs.begin(), src.outputs.end(), [&](const tx_output_entry& a)
@@ -12661,6 +12659,7 @@ bool wallet2::check_reserve_proof(const cryptonote::account_public_address &addr
}
catch(...) {}
+ THROW_WALLET_EXCEPTION_IF(!loaded, error::wallet_internal_error, "Failed to parse reserve proof signature data");
THROW_WALLET_EXCEPTION_IF(subaddr_spendkeys.count(address.m_spend_public_key) == 0, error::wallet_internal_error,
"The given address isn't found in the proof");
diff --git a/tests/unit_tests/epee_levin_protocol_handler_async.cpp b/tests/unit_tests/epee_levin_protocol_handler_async.cpp
index 65afc83..5a39851 100644
--- a/tests/unit_tests/epee_levin_protocol_handler_async.cpp
+++ b/tests/unit_tests/epee_levin_protocol_handler_async.cpp
@@ -657,9 +657,6 @@ TEST_F(test_levin_protocol_handler__hanle_recv_with_invalid_data, handles_bad_cb
m_req_head.m_cb = sizeof(epee::levin::bucket_head2);
m_req_head.m_flags = LEVIN_PACKET_BEGIN;
m_req_head.m_command = 0;
-
- epee::levin::bucket_head2 inner{};
- inner.m_cb = 2;
m_in_data.resize(sizeof(epee::levin::bucket_head2));
prepare_buf();
Why this scored 18/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.