Skip to content

Commit e9e6902

Browse files
committed
Merge 4946400 into merged_master (Bitcoin PR bitcoin-core/gui#8)
2 parents f735896 + 4946400 commit e9e6902

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

src/qt/transactionrecord.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ void TransactionRecord::updateStatus(const interfaces::WalletTxStatus& wtx, cons
297297

298298
bool TransactionRecord::statusUpdateNeeded(const uint256& block_hash) const
299299
{
300+
assert(!block_hash.IsNull());
300301
return status.m_cur_block_hash != block_hash || status.needsUpdate;
301302
}
302303

src/qt/transactiontablemodel.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ class TransactionTablePriv
195195
interfaces::WalletTxStatus wtx;
196196
int numBlocks;
197197
int64_t block_time;
198-
if (rec->statusUpdateNeeded(cur_block_hash) && wallet.tryGetTxStatus(rec->hash, wtx, numBlocks, block_time)) {
198+
if (!cur_block_hash.IsNull() && rec->statusUpdateNeeded(cur_block_hash) && wallet.tryGetTxStatus(rec->hash, wtx, numBlocks, block_time)) {
199199
rec->updateStatus(wtx, cur_block_hash, numBlocks, block_time);
200200
}
201201
return rec;
@@ -669,7 +669,7 @@ QVariant TransactionTableModel::headerData(int section, Qt::Orientation orientat
669669
QModelIndex TransactionTableModel::index(int row, int column, const QModelIndex &parent) const
670670
{
671671
Q_UNUSED(parent);
672-
TransactionRecord* data = priv->index(walletModel->wallet(), walletModel->clientModel().getBestBlockHash(), row);
672+
TransactionRecord* data = priv->index(walletModel->wallet(), walletModel->getLastBlockProcessed(), row);
673673
if(data)
674674
{
675675
return createIndex(row, column, data);

src/qt/walletmodel.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ void WalletModel::pollBalanceChanged()
106106
{
107107
// Avoid recomputing wallet balances unless a TransactionChanged or
108108
// BlockTip notification was received.
109-
if (!fForceCheckBalanceChanged && m_cached_last_update_tip == m_client_model->getBestBlockHash()) return;
109+
if (!fForceCheckBalanceChanged && m_cached_last_update_tip == getLastBlockProcessed()) return;
110110

111111
// Try to get balances and return early if locks can't be acquired. This
112112
// avoids the GUI from getting stuck on periodical polls if the core is
@@ -623,3 +623,8 @@ void WalletModel::refresh(bool pk_hash_only)
623623
{
624624
addressTableModel = new AddressTableModel(this, pk_hash_only);
625625
}
626+
627+
uint256 WalletModel::getLastBlockProcessed() const
628+
{
629+
return m_client_model ? m_client_model->getBestBlockHash() : uint256{};
630+
}

src/qt/walletmodel.h

+3
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ class WalletModel : public QObject
156156
AddressTableModel* getAddressTableModel() const { return addressTableModel; }
157157

158158
void refresh(bool pk_hash_only = false);
159+
160+
uint256 getLastBlockProcessed() const;
161+
159162
private:
160163
std::unique_ptr<interfaces::Wallet> m_wallet;
161164
std::unique_ptr<interfaces::Handler> m_handler_unload;

0 commit comments

Comments
 (0)