diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp --- a/src/qt/transactionrecord.cpp +++ b/src/qt/transactionrecord.cpp @@ -214,6 +214,7 @@ } bool TransactionRecord::statusUpdateNeeded(const BlockHash &block_hash) const { + assert(!block_hash.IsNull()); return status.m_cur_block_hash != block_hash; } diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp --- a/src/qt/transactiontablemodel.cpp +++ b/src/qt/transactiontablemodel.cpp @@ -186,7 +186,8 @@ interfaces::WalletTxStatus wtx; int numBlocks; int64_t block_time; - if (rec->statusUpdateNeeded(cur_block_hash) && + if (!cur_block_hash.IsNull() && + rec->statusUpdateNeeded(cur_block_hash) && wallet.tryGetTxStatus(rec->txid, wtx, numBlocks, block_time)) { rec->updateStatus(wtx, cur_block_hash, numBlocks, block_time); } @@ -671,9 +672,8 @@ QModelIndex TransactionTableModel::index(int row, int column, const QModelIndex &parent) const { Q_UNUSED(parent); - TransactionRecord *data = - priv->index(walletModel->wallet(), - walletModel->clientModel().getBestBlockHash(), row); + TransactionRecord *data = priv->index( + walletModel->wallet(), walletModel->getLastBlockProcessed(), row); if (data) { return createIndex(row, column, data); } diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h --- a/src/qt/walletmodel.h +++ b/src/qt/walletmodel.h @@ -162,6 +162,8 @@ return addressTableModel; } + BlockHash getLastBlockProcessed() const; + private: std::unique_ptr m_wallet; std::unique_ptr m_handler_unload; diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -72,7 +72,7 @@ // Avoid recomputing wallet balances unless a TransactionChanged or // BlockTip notification was received. if (!fForceCheckBalanceChanged && - m_cached_last_update_tip == m_client_model->getBestBlockHash()) { + m_cached_last_update_tip == getLastBlockProcessed()) { return; } @@ -531,3 +531,7 @@ const CChainParams &WalletModel::getChainParams() const { return Params(); } + +BlockHash WalletModel::getLastBlockProcessed() const { + return m_client_model ? m_client_model->getBestBlockHash() : BlockHash{}; +}