PRCYCoin  2.0.0.7rc1
P2P Digital Currency
transactiontablemodel.cpp
Go to the documentation of this file.
1 // Copyright (c) 2011-2014 The Bitcoin developers
2 // Distributed under the MIT/X11 software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
6 
7 #include "addresstablemodel.h"
8 #include "guiconstants.h"
9 #include "guiutil.h"
10 #include "optionsmodel.h"
11 #include "transactiondesc.h"
12 #include "transactionrecord.h"
13 #include "walletmodel.h"
14 
15 #include "main.h"
16 #include "sync.h"
17 #include "uint256.h"
18 #include "util.h"
19 #include "wallet/wallet.h"
20 
21 #include <algorithm>
22 
23 #include <QColor>
24 #include <QDateTime>
25 #include <QDebug>
26 #include <QIcon>
27 #include <QList>
28 #include <QtConcurrent/QtConcurrent>
29 #include <QFuture>
30 
31 #define SINGLE_THREAD_MAX_TXES_SIZE 4000
32 
33 // Maximum amount of loaded records in ram in the first load.
34 // If the user has more and want to load them:
35 // TODO, add load on demand in pages (not every tx loaded all the time into the records list).
36 #define MAX_AMOUNT_LOADED_RECORDS 20000
37 
38 // Amount column is right-aligned it contains numbers
39 static int column_alignments[] = {
40  Qt::AlignLeft | Qt::AlignVCenter, /* status */
41  Qt::AlignLeft | Qt::AlignVCenter, /* watchonly */
42  Qt::AlignLeft | Qt::AlignVCenter, /* date */
43  Qt::AlignLeft | Qt::AlignVCenter, /* type */
44  Qt::AlignLeft | Qt::AlignVCenter, /* address */
45  Qt::AlignRight | Qt::AlignVCenter /* amount */
46 };
47 
48 // Comparison operator for sort/binary search of model tx list
49 struct TxLessThan {
50  bool operator()(const TransactionRecord& a, const TransactionRecord& b) const
51  {
52  return a.hash < b.hash;
53  }
54  bool operator()(const TransactionRecord& a, const uint256& b) const
55  {
56  return a.hash < b;
57  }
58  bool operator()(const uint256& a, const TransactionRecord& b) const
59  {
60  return a < b.hash;
61  }
62 };
63 
64 // Private implementation
66 {
67 public:
69  parent(parent)
70  {
71  }
72 
75 
76  /* Local cache of wallet.
77  * As it is in the same order as the CWallet, by definition
78  * this is sorted by sha256.
79  */
80  QList<TransactionRecord> cachedWallet;
81 
82  /* Query entire wallet anew from core.
83  */
85  {
86  if (wallet->IsLocked()) return;
87  cachedWallet.clear();
88  //Use defined values
89  int customThreadLimit = SINGLE_THREAD_MAX_TXES_SIZE;
90  int maxTXUIlLimit = MAX_AMOUNT_LOADED_RECORDS;
91  //Change to user values if set
92  customThreadLimit = GetArg("-txthreadinglimit", 4000);
93  maxTXUIlLimit = GetArg("-maxtxuilimit", 20000);
94 
95  std::vector<CWalletTx> walletTxes = wallet->getWalletTxs();
96 
97  // Divide the work between multiple threads to speedup the process if the vector is larger than 4k txes
98  std::size_t txesSize = walletTxes.size();
99  if (txesSize > customThreadLimit && GetBoolArg("-txthreading", true)) {
100  // First check if the amount of txs exceeds the UI limit
101  if (txesSize > maxTXUIlLimit) {
102  // Sort the txs by date just to be really really sure that them are ordered.
103  // (this extra calculation should be removed in the future if can ensure that
104  // txs are stored in order in the db, which is what should be happening)
105  sort(walletTxes.begin(), walletTxes.end(),
106  [](const CWalletTx & a, const CWalletTx & b) -> bool {
107  return a.GetComputedTxTime() > b.GetComputedTxTime();
108  });
109 
110  // Only latest ones.
111  walletTxes = std::vector<CWalletTx>(walletTxes.begin(), walletTxes.begin() + MAX_AMOUNT_LOADED_RECORDS);
112  txesSize = walletTxes.size();
113  };
114 
115  // Simple way to get the processors count
116  std::size_t threadsCount = (QThreadPool::globalInstance()->maxThreadCount() / 2 ) + 1;
117 
118  // Size of the tx subsets
119  std::size_t const subsetSize = txesSize / (threadsCount + 1);
120  std::size_t totalSumSize = 0;
121  QList<QFuture<QList<TransactionRecord>>> tasks;
122 
123  // Subsets + run task
124  for (std::size_t i = 0; i < threadsCount; ++i) {
125  tasks.append(
126  QtConcurrent::run(
128  this,
129  wallet,
130  std::vector<CWalletTx>(walletTxes.begin() + totalSumSize, walletTxes.begin() + totalSumSize + subsetSize)
131  )
132  );
133  totalSumSize += subsetSize;
134  }
135 
136  // Now take the remaining ones and do the work here
137  std::size_t const remainingSize = txesSize - totalSumSize;
139  std::vector<CWalletTx>(walletTxes.end() - remainingSize, walletTxes.end())
140  ));
141 
142  for (QFuture<QList<TransactionRecord>> &future : tasks) {
143  future.waitForFinished();
144  cachedWallet.append(future.result());
145  }
146  } else {
147  // Single thread flow
148  cachedWallet.append(convertTxToRecords(this, wallet, walletTxes));
149  }
150  }
151 
152  static QList<TransactionRecord> convertTxToRecords(TransactionTablePriv* tablePriv, const CWallet* wallet, const std::vector<CWalletTx>& walletTxes) {
153  QList<TransactionRecord> cachedWallet;
154  for (const auto &tx : walletTxes) {
155  QList<TransactionRecord> records = TransactionRecord::decomposeTransaction(wallet, tx);
156  cachedWallet.append(records);
157  }
158 
159  return cachedWallet;
160  }
161 
162  /* Update our model of the wallet incrementally, to synchronize our model of the wallet
163  with that of the core.
164 
165  Call with transaction that was added, removed or changed.
166  */
167  void updateWallet(const uint256& hash, int status, bool showTransaction)
168  {
169  qDebug() << "TransactionTablePriv::updateWallet : " + QString::fromStdString(hash.ToString()) + " " + QString::number(status);
170 
171  // Find bounds of this transaction in model
172  QList<TransactionRecord>::iterator lower = std::lower_bound(
173  cachedWallet.begin(), cachedWallet.end(), hash, TxLessThan());
174  QList<TransactionRecord>::iterator upper = std::upper_bound(
175  cachedWallet.begin(), cachedWallet.end(), hash, TxLessThan());
176  int lowerIndex = (lower - cachedWallet.begin());
177  int upperIndex = (upper - cachedWallet.begin());
178  bool inModel = (lower != upper);
179 
180  if (status == CT_UPDATED) {
181  if (showTransaction && !inModel)
182  status = CT_NEW; /* Not in model, but want to show, treat as new */
183  if (!showTransaction && inModel)
184  status = CT_DELETED; /* In model, but want to hide, treat as deleted */
185  }
186 
187  qDebug() << " inModel=" + QString::number(inModel) +
188  " Index=" + QString::number(lowerIndex) + "-" + QString::number(upperIndex) +
189  " showTransaction=" + QString::number(showTransaction) + " derivedStatus=" + QString::number(status);
190 
191  switch (status) {
192  case CT_NEW:
193  if (inModel) {
194  qWarning() << "TransactionTablePriv::updateWallet : Warning: Got CT_NEW, but transaction is already in model";
195  break;
196  }
197  if (showTransaction) {
199  // Find transaction in wallet
200  std::map<uint256, CWalletTx>::iterator mi = wallet->mapWallet.find(hash);
201  if (mi == wallet->mapWallet.end()) {
202  qWarning() << "TransactionTablePriv::updateWallet : Warning: Got CT_NEW, but transaction is not in wallet";
203  break;
204  }
205 
206  // Added -- insert at the right position
207  QList<TransactionRecord> toInsert =
209  if (!toInsert.isEmpty()) /* only if something to insert */
210  {
211  parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex + toInsert.size() - 1);
212  int insert_idx = lowerIndex;
213  Q_FOREACH (const TransactionRecord& rec, toInsert) {
214  cachedWallet.insert(insert_idx, rec);
215  insert_idx += 1;
216  }
217  parent->endInsertRows();
218  }
219  }
220  break;
221  case CT_DELETED:
222  if (!inModel) {
223  qWarning() << "TransactionTablePriv::updateWallet : Warning: Got CT_DELETED, but transaction is not in model";
224  break;
225  }
226  // Removed -- remove entire transaction from table
227  parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex - 1);
228  cachedWallet.erase(lower, upper);
229  parent->endRemoveRows();
230  break;
231  case CT_UPDATED:
232  // Miscellaneous updates -- nothing to do, status update will take care of this, and is only computed for
233  // visible transactions.
234  break;
235  }
236  }
237 
238  int size()
239  {
240  return cachedWallet.size();
241  }
242 
244  {
245  if (idx >= 0 && idx < cachedWallet.size()) {
246  TransactionRecord* rec = &cachedWallet[idx];
247 
248  // Get required locks upfront. This avoids the GUI from getting
249  // stuck if the core is holding the locks for a longer time - for
250  // example, during a wallet rescan.
251  //
252  // If a status update is needed (blocks came in since last check),
253  // update the status of this transaction from the wallet. Otherwise,
254  // simply re-use the cached status.
255  TRY_LOCK(cs_main, lockMain);
256  if (lockMain) {
257  TRY_LOCK(wallet->cs_wallet, lockWallet);
258  if (lockWallet && rec->statusUpdateNeeded()) {
259  std::map<uint256, CWalletTx>::iterator mi = wallet->mapWallet.find(rec->hash);
260 
261  if (mi != wallet->mapWallet.end()) {
262  rec->updateStatus(mi->second);
263  }
264  }
265  }
266  return rec;
267  }
268  return 0;
269  }
270 
271  QString describe(TransactionRecord* rec, int unit)
272  {
273  {
275  std::map<uint256, CWalletTx>::iterator mi = wallet->mapWallet.find(rec->hash);
276  if (mi != wallet->mapWallet.end()) {
277  return TransactionDesc::toHTML(wallet, mi->second, rec, unit);
278  }
279  }
280  return QString();
281  }
282 };
283 
284 TransactionTableModel::TransactionTableModel(CWallet* wallet, WalletModel* parent) : QAbstractTableModel(parent),
285  wallet(wallet),
286  walletModel(parent),
287  priv(new TransactionTablePriv(wallet, this)),
288  fProcessingQueuedTransactions(false)
289 {
290  columns << QString() << QString() << tr("Date") << tr("Type") << tr("Address") << BitcoinUnits::getAmountColumnTitle(walletModel->getOptionsModel()->getDisplayUnit()) << tr("Confirmations");
291  priv->refreshWallet();
292 
293  connect(walletModel->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
294 
296 }
297 
299 {
301  delete priv;
302 }
303 
306 {
308  Q_EMIT headerDataChanged(Qt::Horizontal, Amount, Amount);
309 }
310 
311 void TransactionTableModel::updateTransaction(const QString& hash, int status, bool showTransaction)
312 {
313  uint256 updated;
314  updated.SetHex(hash.toStdString());
315 
316  priv->updateWallet(updated, status, showTransaction);
317  Q_EMIT walletModel->RefreshRecent();
318 }
319 
321 {
322  // Blocks came in since last poll.
323  // Invalidate status (number of confirmations) and (possibly) description
324  // for all rows. Qt is smart enough to only actually request the data for the
325  // visible rows.
326  Q_EMIT dataChanged(index(0, Status), index(priv->size() - 1, Status));
327  Q_EMIT dataChanged(index(0, ToAddress), index(priv->size() - 1, ToAddress));
328 }
329 
330 int TransactionTableModel::rowCount(const QModelIndex& parent) const
331 {
332  Q_UNUSED(parent);
333  return priv->size();
334 }
335 
336 int TransactionTableModel::columnCount(const QModelIndex& parent) const
337 {
338  Q_UNUSED(parent);
339  return columns.length();
340 }
341 
343 {
344  QString status;
345 
346  switch (wtx->status.status) {
348  status = tr("Open for %n more block(s)", "", wtx->status.open_for);
349  break;
351  status = tr("Open until %1").arg(GUIUtil::dateTimeStr(wtx->status.open_for));
352  break;
354  status = tr("Offline");
355  break;
357  status = tr("Unconfirmed");
358  break;
360  status = tr("Confirming (%1 of %2 recommended confirmations)").arg(wtx->status.depth).arg(TransactionRecord::RecommendedNumConfirmations);
361  break;
363  status = tr("Confirmed (%1 confirmations)").arg(wtx->status.depth);
364  break;
366  status = tr("Conflicted");
367  break;
369  status = tr("Immature (%1 confirmations, will be available after %2)").arg(wtx->status.depth).arg(wtx->status.depth + wtx->status.matures_in);
370  break;
372  status = tr("This block was not received by any other nodes and will probably not be accepted!");
373  break;
375  status = tr("Orphan Block - Generated but not accepted. This does not impact your holdings.");
376  break;
377  }
378 
379  return status;
380 }
381 
383 {
384  if (wtx->time) {
385  return GUIUtil::dateTimeStr(wtx->time);
386  }
387  return QString();
388 }
389 
390 /* Look up address in address book, if found return label (address)
391  otherwise just return (address)
392  */
393 QString TransactionTableModel::lookupAddress(const std::string& address, bool tooltip) const
394 {
395  QString label = walletModel->getAddressTableModel()->labelForAddress(QString::fromStdString(address));
396  QString description;
397  if (!label.isEmpty()) {
398  description += label;
399  }
400  if (label.isEmpty() || tooltip) {
401  description += QString(" (") + QString::fromStdString(address) + QString(")");
402  }
403  return description;
404 }
405 
407 {
408  switch (wtx->type) {
410  return tr("Received with");
412  return tr("Masternode Reward");
414  return tr("Received from");
417  return tr("Sent to");
419  return tr("Payment to yourself");
421  return tr("Minted");
423  return tr("Mined");
424  default:
425  return QString();
426  }
427 }
428 
430 {
431  return QString::number(wtx->status.depth);
432 }
433 
435 {
436  switch (wtx->type) {
440  return QIcon(":/icons/tx_mined");
443  return QIcon(":/icons/tx_input");
446  return QIcon(":/icons/tx_output");
447  default:
448  return QIcon(":/icons/tx_inout");
449  }
450 }
451 
452 QString TransactionTableModel::formatTxToAddress(const TransactionRecord* wtx, bool tooltip) const
453 {
454  QString watchAddress;
455  if (tooltip) {
456  // Mark transactions involving watch-only addresses by adding " (watch-only)"
457  watchAddress = wtx->involvesWatchAddress ? QString(" (") + tr("watch-only") + QString(")") : "";
458  }
459 
460  switch (wtx->type) {
462  return QString::fromStdString(wtx->address) + watchAddress;
468  return lookupAddress(wtx->address, tooltip);
470  return QString::fromStdString(wtx->address) + watchAddress;
472  return QString::fromStdString(wtx->address) + watchAddress;
473  default:
474  return tr("(n/a)") + watchAddress;
475  }
476 }
477 
479 {
480  switch (wtx->type) {
481  // Show addresses without label in a less visible color
486  QString label = walletModel->getAddressTableModel()->labelForAddress(QString::fromStdString(wtx->address));
487  if (label.isEmpty())
488  return COLOR_BAREADDRESS;
489  }
491  default:
492  // To avoid overriding above conditional formats a default text color for this QTableView is not defined in stylesheet,
493  // so we must always return a color here
494  return COLOR_BLACK;
495  }
496 }
497 
498 QString TransactionTableModel::formatTxAmount(const TransactionRecord* wtx, bool showUnconfirmed, BitcoinUnits::SeparatorStyle separators) const
499 {
500  QString str = BitcoinUnits::format(walletModel->getOptionsModel()->getDisplayUnit(), wtx->credit + wtx->debit, false, separators);
501  if (showUnconfirmed) {
502  if (!wtx->status.countsForBalance) {
503  str = QString("[") + str + QString("]");
504  }
505  }
506  return QString(str);
507 }
508 
510 {
511  switch (wtx->status.status) {
518  return QIcon(":/icons/transaction_0");
520  switch (wtx->status.depth) {
521  case 1:
522  return QIcon(":/icons/transaction_1");
523  case 2:
524  return QIcon(":/icons/transaction_2");
525  case 3:
526  return QIcon(":/icons/transaction_3");
527  case 4:
528  return QIcon(":/icons/transaction_4");
529  default:
530  return QIcon(":/icons/transaction_5");
531  };
533  return QIcon(":/icons/transaction_confirmed");
535  return QIcon(":/icons/transaction_conflicted");
537  int total = wtx->status.depth + wtx->status.matures_in;
538  int part = (wtx->status.depth * 5 / total) + 1;
539  return QIcon(QString(":/icons/transaction_%1").arg(part));
540  }
543  return QIcon(":/icons/transaction_0");
544  default:
545  return COLOR_BLACK;
546  }
547 }
548 
550 {
551  if (wtx->involvesWatchAddress)
552  return QIcon(":/icons/eye");
553  else
554  return QVariant();
555 }
556 
558 {
559  QString tooltip = formatTxStatus(rec) + QString("\n") + formatTxType(rec);
562  tooltip += QString(" ") + formatTxToAddress(rec, true);
563  }
564  return tooltip;
565 }
566 
567 QVariant TransactionTableModel::data(const QModelIndex& index, int role) const
568 {
569  if (!index.isValid())
570  return QVariant();
571  TransactionRecord* rec = static_cast<TransactionRecord*>(index.internalPointer());
572 
573  switch (role) {
574  case Qt::DecorationRole:
575  switch (index.column()) {
576  case Status:
577  return txStatusDecoration(rec);
578  case Watchonly:
579  return txWatchonlyDecoration(rec);
580  case ToAddress:
581  return txAddressDecoration(rec);
582  }
583  break;
584  case Qt::DisplayRole:
585  switch (index.column()) {
586  case Date:
587  return formatTxDate(rec);
588  case Type:
589  return formatTxType(rec);
590  case ToAddress:
591  return formatTxToAddress(rec, false);
592  case Amount:
594  case Confirmations:
595  return formatTxConfirmations(rec);
596  }
597  break;
598  case Qt::EditRole:
599  // Edit role is used for sorting, so return the unformatted values
600  switch (index.column()) {
601  case Status:
602  return QString::fromStdString(rec->status.sortKey);
603  case Date:
604  return rec->time;
605  case Type:
606  return formatTxType(rec);
607  case Watchonly:
608  return (rec->involvesWatchAddress ? 1 : 0);
609  case ToAddress:
610  return formatTxToAddress(rec, true);
611  case Amount:
612  return qint64(rec->credit + rec->debit);
613  case Confirmations:
614  return formatTxConfirmations(rec);
615  }
616  break;
617  case Qt::ToolTipRole:
618  return formatTooltip(rec);
619  case Qt::TextAlignmentRole:
620  return column_alignments[index.column()];
621  case Qt::ForegroundRole:
622  // Minted
625  return COLOR_ORPHAN;
626  else
627  return COLOR_STAKE;
628  }
629  // Conflicted tx
631  return COLOR_CONFLICTED;
632  }
633  // Unconfimed or immature
635  return COLOR_UNCONFIRMED;
636  }
637  if (index.column() == Amount && (rec->credit + rec->debit) < 0) {
638  return COLOR_NEGATIVE;
639  }
640  if (index.column() == ToAddress) {
641  return addressColor(rec);
642  }
643 
644  // To avoid overriding above conditional formats a default text color for this QTableView is not defined in stylesheet,
645  // so we must always return a color here
646  return COLOR_BLACK;
647  case TypeRole:
648  return rec->type;
649  case DateRole:
650  return QDateTime::fromTime_t(static_cast<uint>(rec->time));
651  case WatchonlyRole:
652  return rec->involvesWatchAddress;
654  return txWatchonlyDecoration(rec);
655  case LongDescriptionRole:
657  case AddressRole:
658  return QString::fromStdString(rec->address);
659  case LabelRole:
660  return walletModel->getAddressTableModel()->labelForAddress(QString::fromStdString(rec->address));
661  case AmountRole:
662  return qint64(rec->credit + rec->debit);
663  case TxIDRole:
664  return rec->getTxID();
665  case TxHashRole:
666  return QString::fromStdString(rec->hash.ToString());
667  case ConfirmedRole:
668  return rec->status.countsForBalance;
669  case FormattedAmountRole:
670  // Used for copy/export, so don't include separators
671  return formatTxAmount(rec, false, BitcoinUnits::separatorNever);
672  case StatusRole:
673  return rec->status.status;
674  }
675  return QVariant();
676 }
677 
678 QVariant TransactionTableModel::headerData(int section, Qt::Orientation orientation, int role) const
679 {
680  if (orientation == Qt::Horizontal) {
681  if (role == Qt::DisplayRole) {
682  return columns[section];
683  } else if (role == Qt::TextAlignmentRole) {
684  return column_alignments[section];
685  } else if (role == Qt::ToolTipRole) {
686  switch (section) {
687  case Status:
688  return tr("Transaction status. Hover over this field to show number of confirmations.");
689  case Date:
690  return tr("Date and time that the transaction was received.");
691  case Type:
692  return tr("Type of transaction.");
693  case Watchonly:
694  return tr("Whether or not a watch-only address is involved in this transaction.");
695  case ToAddress:
696  return tr("Destination address of transaction.");
697  case Amount:
698  return tr("Amount removed from or added to balance.");
699  case Confirmations:
700  return tr("Confirmed Count.");
701  }
702  }
703  }
704  return QVariant();
705 }
706 
707 QModelIndex TransactionTableModel::index(int row, int column, const QModelIndex& parent) const
708 {
709  Q_UNUSED(parent);
710  TransactionRecord* data = priv->index(row);
711  if (data) {
712  return createIndex(row, column, data);
713  }
714  return QModelIndex();
715 }
716 
718 {
719  // Q_EMIT dataChanged to update Amount column with the current unit
721  Q_EMIT dataChanged(index(0, Amount), index(priv->size() - 1, Amount));
722 }
723 
724 // queue notifications to show a non freezing progress dialog e.g. for rescan
726 public:
729 
730  void invoke(QObject* ttm)
731  {
732  QString strHash = QString::fromStdString(hash.GetHex());
733  qDebug() << "NotifyTransactionChanged : " + strHash + " status= " + QString::number(status);
734  QMetaObject::invokeMethod(ttm, "updateTransaction", Qt::QueuedConnection,
735  Q_ARG(QString, strHash),
736  Q_ARG(int, status),
737  Q_ARG(bool, true));
738  }
739 
740 private:
743 };
744 
745 static bool fQueueNotifications = false;
746 static std::vector<TransactionNotification> vQueueNotifications;
747 
748 static void NotifyTransactionChanged(TransactionTableModel* ttm, CWallet* wallet, const uint256& hash, ChangeType status)
749 {
750 
751  TransactionNotification notification(hash, status);
752 
753  if (fQueueNotifications)
754  {
755  vQueueNotifications.push_back(notification);
756  return;
757  }
758  notification.invoke(ttm);
759 }
760 
761 static void ShowProgress(TransactionTableModel* ttm, const std::string& title, int nProgress)
762 {
763  if (nProgress == 0)
764  fQueueNotifications = true;
765 
766  if (nProgress == 100) {
767  fQueueNotifications = false;
768  if (vQueueNotifications.size() > 10) // prevent balloon spam, show maximum 10 balloons
769  QMetaObject::invokeMethod(ttm, "setProcessingQueuedTransactions", Qt::QueuedConnection, Q_ARG(bool, true));
770  for (unsigned int i = 0; i < vQueueNotifications.size(); ++i) {
771  if (vQueueNotifications.size() - i <= 10)
772  QMetaObject::invokeMethod(ttm, "setProcessingQueuedTransactions", Qt::QueuedConnection, Q_ARG(bool, false));
773 
774  vQueueNotifications[i].invoke(ttm);
775  }
776  std::vector<TransactionNotification>().swap(vQueueNotifications); // clear
777  }
778 }
779 
781 {
782  // Connect signals to wallet
783  wallet->NotifyTransactionChanged.connect(boost::bind(NotifyTransactionChanged, this, _1, _2, _3));
784  wallet->ShowProgress.connect(boost::bind(ShowProgress, this, _1, _2));
785 }
786 
788 {
789  // Disconnect signals from wallet
790  wallet->NotifyTransactionChanged.disconnect(boost::bind(NotifyTransactionChanged, this, _1, _2, _3));
791  wallet->ShowProgress.disconnect(boost::bind(ShowProgress, this, _1, _2));
792 }
COLOR_CONFLICTED
#define COLOR_CONFLICTED
Definition: guiconstants.h:38
LOCK2
#define LOCK2(cs1, cs2)
Definition: sync.h:183
WalletModel::getOptionsModel
OptionsModel * getOptionsModel()
Definition: walletmodel.cpp:358
TransactionRecord::StakeMint
@ StakeMint
Definition: transactionrecord.h:78
TransactionTableModel::txAddressDecoration
QVariant txAddressDecoration(const TransactionRecord *wtx) const
Definition: transactiontablemodel.cpp:434
transactiontablemodel.h
TransactionTableModel::formatTxStatus
QString formatTxStatus(const TransactionRecord *wtx) const
Definition: transactiontablemodel.cpp:342
TransactionRecord::statusUpdateNeeded
bool statusUpdateNeeded()
Return whether a status update is needed.
Definition: transactionrecord.cpp:251
TransactionTableModel::wallet
CWallet * wallet
Definition: transactiontablemodel.h:79
TransactionTableModel::updateConfirmations
void updateConfirmations()
Definition: transactiontablemodel.cpp:320
TransactionTableModel::txStatusDecoration
QVariant txStatusDecoration(const TransactionRecord *wtx) const
Definition: transactiontablemodel.cpp:509
TransactionStatus::sortKey
std::string sortKey
Sorting key based on status.
Definition: transactionrecord.h:46
TransactionStatus::OpenUntilDate
@ OpenUntilDate
Normal (sent/received) transactions.
Definition: transactionrecord.h:31
CT_DELETED
@ CT_DELETED
Definition: guiinterface.h:24
CWallet::mapWallet
std::map< uint256, CWalletTx > mapWallet
Definition: wallet.h:344
TransactionTablePriv::describe
QString describe(TransactionRecord *rec, int unit)
Definition: transactiontablemodel.cpp:271
TransactionTablePriv::size
int size()
Definition: transactiontablemodel.cpp:238
TransactionTableModel::Date
@ Date
Definition: transactiontablemodel.h:32
WalletModel
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:102
TxLessThan
Definition: transactiontablemodel.cpp:49
COLOR_ORPHAN
#define COLOR_ORPHAN
Definition: guiconstants.h:40
TransactionTableModel::AddressRole
@ AddressRole
Address of transaction.
Definition: transactiontablemodel.h:54
TransactionNotification::invoke
void invoke(QObject *ttm)
Definition: transactiontablemodel.cpp:730
b
void const uint64_t * b
Definition: field_5x52_asm_impl.h:10
base_uint::GetHex
std::string GetHex() const
Definition: arith_uint256.cpp:155
TransactionRecord::status
TransactionStatus status
Status: can change with block chain update.
Definition: transactionrecord.h:122
TransactionRecord::hash
uint256 hash
Definition: transactionrecord.h:110
transactiondesc.h
sync.h
TransactionTableModel::formatTxDate
QString formatTxDate(const TransactionRecord *wtx) const
Definition: transactiontablemodel.cpp:382
TransactionRecord::RecvWithAddress
@ RecvWithAddress
Definition: transactionrecord.h:81
walletmodel.h
uint256.h
WalletModel::getAddressTableModel
AddressTableModel * getAddressTableModel()
Definition: walletmodel.cpp:363
TransactionTableModel::WatchonlyRole
@ WatchonlyRole
Watch-only boolean.
Definition: transactiontablemodel.h:48
AddressTableModel::labelForAddress
QString labelForAddress(const QString &address) const
Definition: addresstablemodel.cpp:400
TransactionStatus::Conflicted
@ Conflicted
Conflicts with other transaction or mempool.
Definition: transactionrecord.h:36
wallet.h
TransactionRecord::credit
CAmount credit
Definition: transactionrecord.h:115
COLOR_BLACK
#define COLOR_BLACK
Definition: guiconstants.h:36
TransactionTableModel::index
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
Definition: transactiontablemodel.cpp:707
TransactionTableModel::Confirmations
@ Confirmations
Definition: transactiontablemodel.h:36
CWallet::getWalletTxs
std::vector< CWalletTx > getWalletTxs()
Definition: wallet.cpp:176
TransactionTablePriv::parent
TransactionTableModel * parent
Definition: transactiontablemodel.cpp:74
TRY_LOCK
#define TRY_LOCK(cs, name)
Definition: sync.h:186
TransactionTablePriv::index
TransactionRecord * index(int idx)
Definition: transactiontablemodel.cpp:243
TransactionRecord::MNReward
@ MNReward
Definition: transactionrecord.h:82
TransactionRecord::updateStatus
void updateStatus(const CWalletTx &wtx)
Update status from core wallet tx.
Definition: transactionrecord.cpp:188
TransactionTableModel::txWatchonlyDecoration
QVariant txWatchonlyDecoration(const TransactionRecord *wtx) const
Definition: transactiontablemodel.cpp:549
COLOR_BAREADDRESS
#define COLOR_BAREADDRESS
Definition: guiconstants.h:30
TransactionNotification::hash
uint256 hash
Definition: transactiontablemodel.cpp:741
TransactionRecord::RecommendedNumConfirmations
static const int RecommendedNumConfirmations
Number of confirmation recommended for accepting a transaction.
Definition: transactionrecord.h:88
TransactionNotification::TransactionNotification
TransactionNotification(uint256 hash, ChangeType status)
Definition: transactiontablemodel.cpp:728
COLOR_NEGATIVE
#define COLOR_NEGATIVE
Definition: guiconstants.h:28
TransactionTablePriv::wallet
CWallet * wallet
Definition: transactiontablemodel.cpp:73
TransactionRecord::RecvFromOther
@ RecvFromOther
Definition: transactionrecord.h:83
TransactionRecord
UI model for a transaction.
Definition: transactionrecord.h:72
TransactionRecord::time
qint64 time
Definition: transactionrecord.h:111
TransactionStatus::MaturesWarning
@ MaturesWarning
Transaction will likely not mature because no nodes have confirmed.
Definition: transactionrecord.h:39
TransactionTableModel::TxIDRole
@ TxIDRole
Unique identifier.
Definition: transactiontablemodel.h:60
OptionsModel::getDisplayUnit
int getDisplayUnit()
Definition: optionsmodel.h:60
TransactionTableModel::updateDisplayUnit
void updateDisplayUnit()
Definition: transactiontablemodel.cpp:717
TransactionTableModel::formatTxAmount
QString formatTxAmount(const TransactionRecord *wtx, bool showUnconfirmed=true, BitcoinUnits::SeparatorStyle separators=BitcoinUnits::separatorStandard) const
Definition: transactiontablemodel.cpp:498
TransactionTableModel::updateTransaction
void updateTransaction(const QString &hash, int status, bool showTransaction)
Definition: transactiontablemodel.cpp:311
TransactionTableModel::formatTxConfirmations
QString formatTxConfirmations(const TransactionRecord *wtx) const
Definition: transactiontablemodel.cpp:429
CT_NEW
@ CT_NEW
Definition: guiinterface.h:22
cs_main
RecursiveMutex cs_main
Global state.
Definition: main.cpp:65
TransactionTablePriv::updateWallet
void updateWallet(const uint256 &hash, int status, bool showTransaction)
Definition: transactiontablemodel.cpp:167
TransactionTableModel::AmountRole
@ AmountRole
Net amount of transaction.
Definition: transactiontablemodel.h:58
TransactionTableModel::subscribeToCoreSignals
void subscribeToCoreSignals()
Definition: transactiontablemodel.cpp:780
TransactionNotification::status
ChangeType status
Definition: transactiontablemodel.cpp:742
TransactionStatus::open_for
qint64 open_for
Timestamp if status==OpenUntilDate, otherwise number of additional blocks that need to be mined befor...
Definition: transactionrecord.h:57
TransactionTablePriv::refreshWallet
void refreshWallet()
Definition: transactiontablemodel.cpp:84
TransactionTableModel::unsubscribeFromCoreSignals
void unsubscribeFromCoreSignals()
Definition: transactiontablemodel.cpp:787
TransactionTablePriv::cachedWallet
QList< TransactionRecord > cachedWallet
Definition: transactiontablemodel.cpp:80
SINGLE_THREAD_MAX_TXES_SIZE
#define SINGLE_THREAD_MAX_TXES_SIZE
Definition: transactiontablemodel.cpp:31
TransactionRecord::SendToOther
@ SendToOther
Definition: transactionrecord.h:80
TransactionTableModel::ToAddress
@ ToAddress
Definition: transactiontablemodel.h:34
TransactionTableModel::formatTxToAddress
QString formatTxToAddress(const TransactionRecord *wtx, bool tooltip) const
Definition: transactiontablemodel.cpp:452
TransactionRecord::involvesWatchAddress
bool involvesWatchAddress
Whether the transaction was sent/received with a watch-only address.
Definition: transactionrecord.h:125
MAX_AMOUNT_LOADED_RECORDS
#define MAX_AMOUNT_LOADED_RECORDS
Definition: transactiontablemodel.cpp:36
GetBoolArg
bool GetBoolArg(const std::string &strArg, bool fDefault)
Return boolean argument or default value.
Definition: util.cpp:255
TransactionTableModel::priv
TransactionTablePriv * priv
Definition: transactiontablemodel.h:82
CWallet::ShowProgress
boost::signals2::signal< void(const std::string &title, int nProgress)> ShowProgress
Show progress e.g.
Definition: wallet.h:610
TransactionTableModel::rowCount
int rowCount(const QModelIndex &parent) const
Definition: transactiontablemodel.cpp:330
BitcoinUnits::SeparatorStyle
SeparatorStyle
Definition: bitcoinunits.h:66
TransactionTableModel::StatusRole
@ StatusRole
Transaction status (TransactionRecord::Status)
Definition: transactiontablemodel.h:68
guiutil.h
COLOR_TX_STATUS_OFFLINE
#define COLOR_TX_STATUS_OFFLINE
Definition: guiconstants.h:34
TransactionRecord::Generated
@ Generated
Definition: transactionrecord.h:77
TransactionTableModel::Amount
@ Amount
Definition: transactiontablemodel.h:35
TransactionTableModel::columnCount
int columnCount(const QModelIndex &parent) const
Definition: transactiontablemodel.cpp:336
TransactionTableModel::columns
QStringList columns
Definition: transactiontablemodel.h:81
uint256
256-bit unsigned big integer.
Definition: uint256.h:38
base_uint::SetHex
void SetHex(const char *psz)
Definition: arith_uint256.cpp:164
TransactionTableModel::headerData
QVariant headerData(int section, Qt::Orientation orientation, int role) const
Definition: transactiontablemodel.cpp:678
COLOR_STAKE
#define COLOR_STAKE
Definition: guiconstants.h:42
TransactionRecord::debit
CAmount debit
Definition: transactionrecord.h:114
TransactionTableModel::data
QVariant data(const QModelIndex &index, int role) const
Definition: transactiontablemodel.cpp:567
TransactionRecord::SendToSelf
@ SendToSelf
Definition: transactionrecord.h:84
TransactionStatus::Immature
@ Immature
Generated (mined) transactions.
Definition: transactionrecord.h:38
TxLessThan::operator()
bool operator()(const TransactionRecord &a, const TransactionRecord &b) const
Definition: transactiontablemodel.cpp:50
COLOR_TX_STATUS_OPENUNTILDATE
#define COLOR_TX_STATUS_OPENUNTILDATE
Definition: guiconstants.h:32
TransactionTablePriv::convertTxToRecords
static QList< TransactionRecord > convertTxToRecords(TransactionTablePriv *tablePriv, const CWallet *wallet, const std::vector< CWalletTx > &walletTxes)
Definition: transactiontablemodel.cpp:152
TransactionStatus::OpenUntilBlock
@ OpenUntilBlock
Transaction not yet final, waiting for block.
Definition: transactionrecord.h:32
TransactionRecord::type
Type type
Definition: transactionrecord.h:112
TransactionTableModel::FormattedAmountRole
@ FormattedAmountRole
Formatted amount, without brackets when unconfirmed.
Definition: transactiontablemodel.h:66
BitcoinUnits::format
static QString format(int unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=separatorStandard)
Format as string.
Definition: bitcoinunits.cpp:140
CT_UPDATED
@ CT_UPDATED
Definition: guiinterface.h:23
TransactionStatus::Confirmed
@ Confirmed
Have 6 or more confirmations (normal tx) or fully mature (mined tx)
Definition: transactionrecord.h:29
TransactionTableModel::LongDescriptionRole
@ LongDescriptionRole
Long description (HTML format)
Definition: transactiontablemodel.h:52
ChangeType
ChangeType
General change type (added, updated, removed).
Definition: guiinterface.h:21
TransactionTableModel::addressColor
QVariant addressColor(const TransactionRecord *wtx) const
Definition: transactiontablemodel.cpp:478
transactionrecord.h
TransactionRecord::address
std::string address
Definition: transactionrecord.h:113
TransactionTableModel
UI model for the transaction table of a wallet.
Definition: transactiontablemodel.h:21
guiconstants.h
TransactionStatus::Confirming
@ Confirming
Confirmed, but waiting for the recommended number of confirmations.
Definition: transactionrecord.h:35
TransactionTableModel::formatTxType
QString formatTxType(const TransactionRecord *wtx) const
Definition: transactiontablemodel.cpp:406
TransactionNotification
Definition: transactiontablemodel.cpp:725
TransactionRecord::decomposeTransaction
static QList< TransactionRecord > decomposeTransaction(const CWallet *wallet, const CWalletTx &wtx)
Decompose CWallet transaction to model transaction records.
Definition: transactionrecord.cpp:20
TransactionStatus::status
Status status
Definition: transactionrecord.h:55
TransactionTablePriv
Definition: transactiontablemodel.cpp:65
BitcoinUnits::separatorAlways
@ separatorAlways
Definition: bitcoinunits.h:69
main.h
TransactionStatus::matures_in
int matures_in
Definition: transactionrecord.h:50
TransactionTableModel::~TransactionTableModel
~TransactionTableModel()
Definition: transactiontablemodel.cpp:298
TransactionTableModel::WatchonlyDecorationRole
@ WatchonlyDecorationRole
Watch-only icon.
Definition: transactiontablemodel.h:50
CWallet
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances,...
Definition: wallet.h:243
BitcoinUnits::getAmountColumnTitle
static QString getAmountColumnTitle(int unit)
Gets title for amount column including current display unit if optionsModel reference available *‍/.
Definition: bitcoinunits.cpp:254
TransactionTableModel::Type
@ Type
Definition: transactiontablemodel.h:33
CWalletTx
A transaction with a bunch of additional info that only the owner cares about.
Definition: wallet.h:792
CWallet::NotifyTransactionChanged
boost::signals2::signal< void(CWallet *wallet, const uint256 &hashTx, ChangeType status)> NotifyTransactionChanged
Wallet transaction added, removed or updated.
Definition: wallet.h:607
TxLessThan::operator()
bool operator()(const uint256 &a, const TransactionRecord &b) const
Definition: transactiontablemodel.cpp:58
TransactionStatus::Offline
@ Offline
Not sent to any other nodes.
Definition: transactionrecord.h:33
TransactionTableModel::lookupAddress
QString lookupAddress(const std::string &address, bool tooltip) const
Definition: transactiontablemodel.cpp:393
TxLessThan::operator()
bool operator()(const TransactionRecord &a, const uint256 &b) const
Definition: transactiontablemodel.cpp:54
TransactionTablePriv::TransactionTablePriv
TransactionTablePriv(CWallet *wallet, TransactionTableModel *parent)
Definition: transactiontablemodel.cpp:68
TransactionNotification::TransactionNotification
TransactionNotification()
Definition: transactiontablemodel.cpp:727
TransactionRecord::SendToAddress
@ SendToAddress
Definition: transactionrecord.h:79
TransactionTableModel::TxHashRole
@ TxHashRole
Transaction hash.
Definition: transactiontablemodel.h:62
CWallet::cs_wallet
RecursiveMutex cs_wallet
Definition: wallet.h:301
TransactionTableModel::Status
@ Status
Definition: transactiontablemodel.h:30
GUIUtil::dateTimeStr
QString dateTimeStr(const QDateTime &date)
Definition: guiutil.cpp:70
TransactionTableModel::DateRole
@ DateRole
Date and time this transaction was created.
Definition: transactiontablemodel.h:46
TransactionStatus::depth
qint64 depth
Definition: transactionrecord.h:56
WalletModel::RefreshRecent
void RefreshRecent()
TransactionStatus::NotAccepted
@ NotAccepted
Mined but not accepted.
Definition: transactionrecord.h:40
TransactionDesc::toHTML
static QString toHTML(CWallet *wallet, CWalletTx &wtx, TransactionRecord *rec, int unit)
Definition: transactiondesc.cpp:87
optionsmodel.h
TransactionStatus::countsForBalance
bool countsForBalance
Transaction counts towards available balance.
Definition: transactionrecord.h:44
TransactionStatus::Unconfirmed
@ Unconfirmed
Not yet mined into a block.
Definition: transactionrecord.h:34
TransactionTableModel::TransactionTableModel
TransactionTableModel(CWallet *wallet, WalletModel *parent=0)
Definition: transactiontablemodel.cpp:284
TransactionTableModel::TypeRole
@ TypeRole
Type of transaction.
Definition: transactiontablemodel.h:44
TransactionRecord::getTxID
QString getTxID() const
Return the unique identifier for this transaction (part)
Definition: transactionrecord.cpp:257
GetArg
std::string GetArg(const std::string &strArg, const std::string &strDefault)
Return string argument or default value.
Definition: util.cpp:241
TransactionTableModel::updateAmountColumnTitle
void updateAmountColumnTitle()
Updates the column title to "Amount (DisplayUnit)" and emits headerDataChanged() signal for table hea...
Definition: transactiontablemodel.cpp:305
TransactionTableModel::LabelRole
@ LabelRole
Label of address related to transaction.
Definition: transactiontablemodel.h:56
addresstablemodel.h
TransactionTableModel::Watchonly
@ Watchonly
Definition: transactiontablemodel.h:31
TransactionTableModel::formatTooltip
QString formatTooltip(const TransactionRecord *rec) const
Definition: transactiontablemodel.cpp:557
TransactionTableModel::walletModel
WalletModel * walletModel
Definition: transactiontablemodel.h:80
COLOR_UNCONFIRMED
#define COLOR_UNCONFIRMED
Definition: guiconstants.h:26
CCryptoKeyStore::IsLocked
bool IsLocked() const
Definition: crypter.h:159
BitcoinUnits::separatorNever
@ separatorNever
Definition: bitcoinunits.h:67
TransactionTableModel::ConfirmedRole
@ ConfirmedRole
Is transaction confirmed?
Definition: transactiontablemodel.h:64
base_uint::ToString
std::string ToString() const
Definition: arith_uint256.cpp:199