@@ -181,12 +181,12 @@ void TXHistoryDialog::setWalletModel(WalletModel *model)
181181
182182int TXHistoryDialog::PopulateHistoryMap ()
183183{
184- CWallet * wallet = pwalletMain;
185- if (NULL == wallet ) return 0 ;
184+ // TODO: locks may not be needed here -- looks like wallet lock can be removed
185+ if (NULL == pwalletMain ) return 0 ;
186186 // try and fix intermittent freeze on startup and while running by only updating if we can get required locks
187187 TRY_LOCK (cs_main,lckMain);
188188 if (!lckMain) return 0 ;
189- TRY_LOCK (wallet ->cs_wallet , lckWallet);
189+ TRY_LOCK (pwalletMain ->cs_wallet , lckWallet);
190190 if (!lckWallet) return 0 ;
191191
192192 int64_t nProcessed = 0 ; // counter for how many transactions we've added to history this time
@@ -195,7 +195,6 @@ int TXHistoryDialog::PopulateHistoryMap()
195195 std::map<std::string,uint256> walletTransactions = FetchWalletOmniTransactions (GetArg (" -omniuiwalletscope" , 1000 ));
196196
197197 // reverse iterate over (now ordered) transactions and populate history map for each one
198- Array response;
199198 for (std::map<std::string,uint256>::reverse_iterator it = walletTransactions.rbegin (); it != walletTransactions.rend (); it++) {
200199 uint256 txHash = it->second ;
201200
@@ -227,7 +226,6 @@ int TXHistoryDialog::PopulateHistoryMap()
227226 uint256 blockHash = 0 ;
228227 if (!GetTransaction (txHash, wtx, blockHash, true )) continue ;
229228 if ((0 == blockHash) || (NULL == GetBlockIndex (blockHash))) {
230-
231229 // this transaction is unconfirmed, should be one of our pending transactions
232230 LOCK (cs_pending);
233231 PendingMap::iterator pending_it = my_pending.find (txHash);
@@ -269,12 +267,15 @@ int TXHistoryDialog::PopulateHistoryMap()
269267 uint64_t tmpPropertyId = 0 ;
270268 bool bIsBuy = false ;
271269 int numberOfPurchases = 0 ;
272- LOCK (cs_tally);
273- p_txlistdb->getPurchaseDetails (txHash, 1 , &tmpBuyer, &tmpSeller, &tmpVout, &tmpPropertyId, &tmpNValue);
270+ {
271+ LOCK (cs_tally);
272+ p_txlistdb->getPurchaseDetails (txHash, 1 , &tmpBuyer, &tmpSeller, &tmpVout, &tmpPropertyId, &tmpNValue);
273+ }
274274 bIsBuy = IsMyAddress (tmpBuyer);
275275 numberOfPurchases = p_txlistdb->getNumberOfPurchases (txHash);
276276 if (0 >= numberOfPurchases) continue ;
277277 for (int purchaseNumber = 1 ; purchaseNumber <= numberOfPurchases; purchaseNumber++) {
278+ LOCK (cs_tally);
278279 p_txlistdb->getPurchaseDetails (txHash, purchaseNumber, &tmpBuyer, &tmpSeller, &tmpVout, &tmpPropertyId, &tmpNValue);
279280 total += tmpNValue;
280281 }
@@ -340,7 +341,7 @@ int TXHistoryDialog::PopulateHistoryMap()
340341
341342void TXHistoryDialog::UpdateConfirmations ()
342343{
343- int chainHeight = chainActive. Height (); // get the chain height
344+ int chainHeight = GetHeight (); // get the chain height
344345 int rowCount = ui->txHistoryTable ->rowCount ();
345346 for (int row = 0 ; row < rowCount; row++) {
346347 int confirmations = 0 ;
@@ -400,6 +401,7 @@ void TXHistoryDialog::UpdateHistory()
400401 QDateTime txTime;
401402 QTableWidgetItem *dateCell = new QTableWidgetItem;
402403 if (htxo.blockHeight >0 ) {
404+ LOCK (cs_main);
403405 CBlockIndex* pBlkIdx = chainActive[htxo.blockHeight ];
404406 if (NULL != pBlkIdx) txTime.setTime_t (pBlkIdx->GetBlockTime ());
405407 dateCell->setData (Qt::DisplayRole, txTime);
0 commit comments