From 08461683d9a01ada5f68ec7692adb6307de25447 Mon Sep 17 00:00:00 2001 From: sowle Date: Mon, 6 May 2019 20:45:27 +0200 Subject: [PATCH] wallet2: fix a minor bug with balance calculation being called from on_transfer callback --- src/wallet/wallet2.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 612c6ffc..156c6f47 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -4082,16 +4082,24 @@ void wallet2::transfer(const std::vector& dsts, return; } - TIME_MEASURE_START(finalize_transaction_time); - crypto::secret_key sk = AUTO_VAL_INIT(sk); - finalize_transaction(ftp, tx, sk, send_to_network); - TIME_MEASURE_FINISH(finalize_transaction_time); - - // unlock transfers at the very end TIME_MEASURE_START(mark_transfers_as_spent_time); mark_transfers_as_spent(ftp.selected_transfers, std::string("money transfer, tx: ") + epee::string_tools::pod_to_hex(get_transaction_hash(tx))); TIME_MEASURE_FINISH(mark_transfers_as_spent_time); + TIME_MEASURE_START(finalize_transaction_time); + try + { + crypto::secret_key sk = AUTO_VAL_INIT(sk); + finalize_transaction(ftp, tx, sk, send_to_network); + } + catch (...) + { + clear_transfers_from_flag(ftp.selected_transfers, WALLET_TRANSFER_DETAIL_FLAG_SPENT, std::string("exception on money transfer, tx: ") + epee::string_tools::pod_to_hex(get_transaction_hash(tx))); + throw; + } + TIME_MEASURE_FINISH(finalize_transaction_time); + + WLT_LOG_GREEN("[wallet::transfer]" << " precalculation_time: " << print_fixed_decimal_point(precalculation_time, 3) << ", prepare_transaction_time: " << print_fixed_decimal_point(prepare_transaction_time, 3)