From 1ee4d3d66ee45e440a622d58519e1db648e336ab Mon Sep 17 00:00:00 2001 From: jeffro256 Date: Thu, 24 Apr 2025 13:28:49 -0500 Subject: [PATCH] carrot_impl: propogate error::password_needed instead of generic exception when applicable --- src/wallet/wallet2.cpp | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 0107bfa04..a876d9ff6 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -3211,7 +3211,8 @@ void wallet2::process_parsed_blocks(const uint64_t start_height, const std::vect // define view-incoming scan and key image derivation job std::vector> enote_scan_infos(num_tx_outputs); std::vector> output_key_images(num_tx_outputs); - auto tx_scan_job = [this, &enote_scan_infos, &output_key_images] + std::atomic password_is_needed = false; + auto tx_scan_job = [this, &enote_scan_infos, &output_key_images, &password_is_needed] (const cryptonote::transaction &tx, size_t tx_output_idx) { const size_t output_span_end = tx_output_idx + tx.vout.size(); @@ -3227,8 +3228,20 @@ void wallet2::process_parsed_blocks(const uint64_t start_height, const std::vect // if view-incoming scan was successful, try deriving the key image for (size_t i = tx_output_idx; i < output_span_end; ++i) + { if (enote_scan_infos.at(i)) - scan_key_image(*enote_scan_infos.at(i), /*pool=*/false, output_key_images[i]); + { + try + { + scan_key_image(*enote_scan_infos.at(i), /*pool=*/false, output_key_images[i]); + } + catch (const error::password_needed &e) + { + password_is_needed.store(true); + throw e; + } + } + } }; //tx_scan_job // create tx scanning jobs for all relevant tx outputs in all blocks @@ -3249,9 +3262,11 @@ void wallet2::process_parsed_blocks(const uint64_t start_height, const std::vect tx_output_idx += tx.vout.size(); } } - THROW_WALLET_EXCEPTION_IF(!scan_blocks_waiter.wait(), - error::wallet_internal_error, - "Exception in enote / key image scanning threadpool"); + if (!scan_blocks_waiter.wait()) + { + THROW_WALLET_EXCEPTION_IF(password_is_needed.load(), error::password_needed); + THROW_WALLET_EXCEPTION(error::wallet_internal_error, "Unrecognized exception in enote scanning threadpool"); + } size_t current_index = start_height; tx_output_idx = 0;