Bitcoin Core  22.99.0
P2P Digital Currency
transactiontablemodel.cpp
Go to the documentation of this file.
1 // Copyright (c) 2011-2021 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
6 
7 #include <qt/addresstablemodel.h>
8 #include <qt/clientmodel.h>
9 #include <qt/guiconstants.h>
10 #include <qt/guiutil.h>
11 #include <qt/optionsmodel.h>
12 #include <qt/platformstyle.h>
13 #include <qt/transactiondesc.h>
14 #include <qt/transactionrecord.h>
15 #include <qt/walletmodel.h>
16 
17 #include <core_io.h>
18 #include <interfaces/handler.h>
19 #include <uint256.h>
20 
21 #include <algorithm>
22 #include <functional>
23 
24 #include <QColor>
25 #include <QDateTime>
26 #include <QDebug>
27 #include <QIcon>
28 #include <QLatin1Char>
29 #include <QLatin1String>
30 #include <QList>
31 
32 
33 // Amount column is right-aligned it contains numbers
34 static int column_alignments[] = {
35  Qt::AlignLeft|Qt::AlignVCenter, /* status */
36  Qt::AlignLeft|Qt::AlignVCenter, /* watchonly */
37  Qt::AlignLeft|Qt::AlignVCenter, /* date */
38  Qt::AlignLeft|Qt::AlignVCenter, /* type */
39  Qt::AlignLeft|Qt::AlignVCenter, /* address */
40  Qt::AlignRight|Qt::AlignVCenter /* amount */
41  };
42 
43 // Comparison operator for sort/binary search of model tx list
44 struct TxLessThan
45 {
46  bool operator()(const TransactionRecord &a, const TransactionRecord &b) const
47  {
48  return a.hash < b.hash;
49  }
50  bool operator()(const TransactionRecord &a, const uint256 &b) const
51  {
52  return a.hash < b;
53  }
54  bool operator()(const uint256 &a, const TransactionRecord &b) const
55  {
56  return a < b.hash;
57  }
58 };
59 
60 // queue notifications to show a non freezing progress dialog e.g. for rescan
62 {
63 public:
65  TransactionNotification(uint256 _hash, ChangeType _status, bool _showTransaction):
66  hash(_hash), status(_status), showTransaction(_showTransaction) {}
67 
68  void invoke(QObject *ttm)
69  {
70  QString strHash = QString::fromStdString(hash.GetHex());
71  qDebug() << "NotifyTransactionChanged: " + strHash + " status= " + QString::number(status);
72  bool invoked = QMetaObject::invokeMethod(ttm, "updateTransaction", Qt::QueuedConnection,
73  Q_ARG(QString, strHash),
74  Q_ARG(int, status),
75  Q_ARG(bool, showTransaction));
76  assert(invoked);
77  }
78 private:
82 };
83 
84 // Private implementation
86 {
87 public:
89  parent(_parent)
90  {
91  }
92 
94 
95  /* Local cache of wallet.
96  * As it is in the same order as the CWallet, by definition
97  * this is sorted by sha256.
98  */
99  QList<TransactionRecord> cachedWallet;
100 
102  bool m_loaded = false;
104  bool m_loading = false;
105  std::vector< TransactionNotification > vQueueNotifications;
106 
107  void NotifyTransactionChanged(const uint256 &hash, ChangeType status);
108  void DispatchNotifications();
109 
110  /* Query entire wallet anew from core.
111  */
113  {
114  assert(!m_loaded);
115  {
116  for (const auto& wtx : wallet.getWalletTxs()) {
119  }
120  }
121  }
122  m_loaded = true;
124  }
125 
126  /* Update our model of the wallet incrementally, to synchronize our model of the wallet
127  with that of the core.
128 
129  Call with transaction that was added, removed or changed.
130  */
131  void updateWallet(interfaces::Wallet& wallet, const uint256 &hash, int status, bool showTransaction)
132  {
133  qDebug() << "TransactionTablePriv::updateWallet: " + QString::fromStdString(hash.ToString()) + " " + QString::number(status);
134 
135  // Find bounds of this transaction in model
136  QList<TransactionRecord>::iterator lower = std::lower_bound(
137  cachedWallet.begin(), cachedWallet.end(), hash, TxLessThan());
138  QList<TransactionRecord>::iterator upper = std::upper_bound(
139  cachedWallet.begin(), cachedWallet.end(), hash, TxLessThan());
140  int lowerIndex = (lower - cachedWallet.begin());
141  int upperIndex = (upper - cachedWallet.begin());
142  bool inModel = (lower != upper);
143 
144  if(status == CT_UPDATED)
145  {
146  if(showTransaction && !inModel)
147  status = CT_NEW; /* Not in model, but want to show, treat as new */
148  if(!showTransaction && inModel)
149  status = CT_DELETED; /* In model, but want to hide, treat as deleted */
150  }
151 
152  qDebug() << " inModel=" + QString::number(inModel) +
153  " Index=" + QString::number(lowerIndex) + "-" + QString::number(upperIndex) +
154  " showTransaction=" + QString::number(showTransaction) + " derivedStatus=" + QString::number(status);
155 
156  switch(status)
157  {
158  case CT_NEW:
159  if(inModel)
160  {
161  qWarning() << "TransactionTablePriv::updateWallet: Warning: Got CT_NEW, but transaction is already in model";
162  break;
163  }
164  if(showTransaction)
165  {
166  // Find transaction in wallet
167  interfaces::WalletTx wtx = wallet.getWalletTx(hash);
168  if(!wtx.tx)
169  {
170  qWarning() << "TransactionTablePriv::updateWallet: Warning: Got CT_NEW, but transaction is not in wallet";
171  break;
172  }
173  // Added -- insert at the right position
174  QList<TransactionRecord> toInsert =
176  if(!toInsert.isEmpty()) /* only if something to insert */
177  {
178  parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex+toInsert.size()-1);
179  int insert_idx = lowerIndex;
180  for (const TransactionRecord &rec : toInsert)
181  {
182  cachedWallet.insert(insert_idx, rec);
183  insert_idx += 1;
184  }
185  parent->endInsertRows();
186  }
187  }
188  break;
189  case CT_DELETED:
190  if(!inModel)
191  {
192  qWarning() << "TransactionTablePriv::updateWallet: Warning: Got CT_DELETED, but transaction is not in model";
193  break;
194  }
195  // Removed -- remove entire transaction from table
196  parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1);
197  cachedWallet.erase(lower, upper);
198  parent->endRemoveRows();
199  break;
200  case CT_UPDATED:
201  // Miscellaneous updates -- nothing to do, status update will take care of this, and is only computed for
202  // visible transactions.
203  for (int i = lowerIndex; i < upperIndex; i++) {
204  TransactionRecord *rec = &cachedWallet[i];
205  rec->status.needsUpdate = true;
206  }
207  break;
208  }
209  }
210 
211  int size()
212  {
213  return cachedWallet.size();
214  }
215 
216  TransactionRecord* index(interfaces::Wallet& wallet, const uint256& cur_block_hash, const int idx)
217  {
218  if (idx >= 0 && idx < cachedWallet.size()) {
219  TransactionRecord *rec = &cachedWallet[idx];
220 
221  // If a status update is needed (blocks came in since last check),
222  // try to update the status of this transaction from the wallet.
223  // Otherwise, simply re-use the cached status.
225  int numBlocks;
226  int64_t block_time;
227  if (!cur_block_hash.IsNull() && rec->statusUpdateNeeded(cur_block_hash) && wallet.tryGetTxStatus(rec->hash, wtx, numBlocks, block_time)) {
228  rec->updateStatus(wtx, cur_block_hash, numBlocks, block_time);
229  }
230  return rec;
231  }
232  return nullptr;
233  }
234 
236  {
237  return TransactionDesc::toHTML(node, wallet, rec, unit);
238  }
239 
241  {
242  auto tx = wallet.getTx(rec->hash);
243  if (tx) {
244  std::string strHex = EncodeHexTx(*tx);
245  return QString::fromStdString(strHex);
246  }
247  return QString();
248  }
249 };
250 
252  QAbstractTableModel(parent),
253  walletModel(parent),
254  priv(new TransactionTablePriv(this)),
255  fProcessingQueuedTransactions(false),
256  platformStyle(_platformStyle)
257 {
259 
260  columns << QString() << QString() << tr("Date") << tr("Type") << tr("Label") << BitcoinUnits::getAmountColumnTitle(walletModel->getOptionsModel()->getDisplayUnit());
262 
264 }
265 
267 {
269  delete priv;
270 }
271 
274 {
276  Q_EMIT headerDataChanged(Qt::Horizontal,Amount,Amount);
277 }
278 
279 void TransactionTableModel::updateTransaction(const QString &hash, int status, bool showTransaction)
280 {
281  uint256 updated;
282  updated.SetHex(hash.toStdString());
283 
284  priv->updateWallet(walletModel->wallet(), updated, status, showTransaction);
285 }
286 
288 {
289  // Blocks came in since last poll.
290  // Invalidate status (number of confirmations) and (possibly) description
291  // for all rows. Qt is smart enough to only actually request the data for the
292  // visible rows.
293  Q_EMIT dataChanged(index(0, Status), index(priv->size()-1, Status));
294  Q_EMIT dataChanged(index(0, ToAddress), index(priv->size()-1, ToAddress));
295 }
296 
297 int TransactionTableModel::rowCount(const QModelIndex &parent) const
298 {
299  if (parent.isValid()) {
300  return 0;
301  }
302  return priv->size();
303 }
304 
305 int TransactionTableModel::columnCount(const QModelIndex &parent) const
306 {
307  if (parent.isValid()) {
308  return 0;
309  }
310  return columns.length();
311 }
312 
314 {
315  QString status;
316 
317  switch(wtx->status.status)
318  {
320  status = tr("Unconfirmed");
321  break;
323  status = tr("Abandoned");
324  break;
326  status = tr("Confirming (%1 of %2 recommended confirmations)").arg(wtx->status.depth).arg(TransactionRecord::RecommendedNumConfirmations);
327  break;
329  status = tr("Confirmed (%1 confirmations)").arg(wtx->status.depth);
330  break;
332  status = tr("Conflicted");
333  break;
335  status = tr("Immature (%1 confirmations, will be available after %2)").arg(wtx->status.depth).arg(wtx->status.depth + wtx->status.matures_in);
336  break;
338  status = tr("Generated but not accepted");
339  break;
340  }
341 
342  return status;
343 }
344 
346 {
347  if(wtx->time)
348  {
349  return GUIUtil::dateTimeStr(wtx->time);
350  }
351  return QString();
352 }
353 
354 /* Look up address in address book, if found return label (address)
355  otherwise just return (address)
356  */
357 QString TransactionTableModel::lookupAddress(const std::string &address, bool tooltip) const
358 {
359  QString label = walletModel->getAddressTableModel()->labelForAddress(QString::fromStdString(address));
360  QString description;
361  if(!label.isEmpty())
362  {
363  description += label;
364  }
365  if(label.isEmpty() || tooltip)
366  {
367  description += QString(" (") + QString::fromStdString(address) + QString(")");
368  }
369  return description;
370 }
371 
373 {
374  switch(wtx->type)
375  {
377  return tr("Received with");
379  return tr("Received from");
382  return tr("Sent to");
384  return tr("Payment to yourself");
386  return tr("Mined");
387  default:
388  return QString();
389  }
390 }
391 
393 {
394  switch(wtx->type)
395  {
397  return QIcon(":/icons/tx_mined");
400  return QIcon(":/icons/tx_input");
403  return QIcon(":/icons/tx_output");
404  default:
405  return QIcon(":/icons/tx_inout");
406  }
407 }
408 
409 QString TransactionTableModel::formatTxToAddress(const TransactionRecord *wtx, bool tooltip) const
410 {
411  QString watchAddress;
412  if (tooltip && wtx->involvesWatchAddress) {
413  // Mark transactions involving watch-only addresses by adding " (watch-only)"
414  watchAddress = QLatin1String(" (") + tr("watch-only") + QLatin1Char(')');
415  }
416 
417  switch(wtx->type)
418  {
420  return QString::fromStdString(wtx->address) + watchAddress;
424  return lookupAddress(wtx->address, tooltip) + watchAddress;
426  return QString::fromStdString(wtx->address) + watchAddress;
428  return lookupAddress(wtx->address, tooltip) + watchAddress;
429  default:
430  return tr("(n/a)") + watchAddress;
431  }
432 }
433 
435 {
436  // Show addresses without label in a less visible color
437  switch(wtx->type)
438  {
442  {
443  QString label = walletModel->getAddressTableModel()->labelForAddress(QString::fromStdString(wtx->address));
444  if(label.isEmpty())
445  return COLOR_BAREADDRESS;
446  } break;
448  return COLOR_BAREADDRESS;
449  default:
450  break;
451  }
452  return QVariant();
453 }
454 
455 QString TransactionTableModel::formatTxAmount(const TransactionRecord *wtx, bool showUnconfirmed, BitcoinUnits::SeparatorStyle separators) const
456 {
457  QString str = BitcoinUnits::format(walletModel->getOptionsModel()->getDisplayUnit(), wtx->credit + wtx->debit, false, separators);
458  if(showUnconfirmed)
459  {
460  if(!wtx->status.countsForBalance)
461  {
462  str = QString("[") + str + QString("]");
463  }
464  }
465  return QString(str);
466 }
467 
469 {
470  switch(wtx->status.status)
471  {
473  return QIcon(":/icons/transaction_0");
475  return QIcon(":/icons/transaction_abandoned");
477  switch(wtx->status.depth)
478  {
479  case 1: return QIcon(":/icons/transaction_1");
480  case 2: return QIcon(":/icons/transaction_2");
481  case 3: return QIcon(":/icons/transaction_3");
482  case 4: return QIcon(":/icons/transaction_4");
483  default: return QIcon(":/icons/transaction_5");
484  };
486  return QIcon(":/icons/transaction_confirmed");
488  return QIcon(":/icons/transaction_conflicted");
490  int total = wtx->status.depth + wtx->status.matures_in;
491  int part = (wtx->status.depth * 4 / total) + 1;
492  return QIcon(QString(":/icons/transaction_%1").arg(part));
493  }
495  return QIcon(":/icons/transaction_0");
496  default:
497  return COLOR_BLACK;
498  }
499 }
500 
502 {
503  if (wtx->involvesWatchAddress)
504  return QIcon(":/icons/eye");
505  else
506  return QVariant();
507 }
508 
510 {
511  QString tooltip = formatTxStatus(rec) + QString("\n") + formatTxType(rec);
514  {
515  tooltip += QString(" ") + formatTxToAddress(rec, true);
516  }
517  return tooltip;
518 }
519 
520 QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
521 {
522  if(!index.isValid())
523  return QVariant();
524  TransactionRecord *rec = static_cast<TransactionRecord*>(index.internalPointer());
525 
526  const auto column = static_cast<ColumnIndex>(index.column());
527  switch (role) {
528  case RawDecorationRole:
529  switch (column) {
530  case Status:
531  return txStatusDecoration(rec);
532  case Watchonly:
533  return txWatchonlyDecoration(rec);
534  case Date: return {};
535  case Type: return {};
536  case ToAddress:
537  return txAddressDecoration(rec);
538  case Amount: return {};
539  } // no default case, so the compiler can warn about missing cases
540  assert(false);
541  case Qt::DecorationRole:
542  {
543  QIcon icon = qvariant_cast<QIcon>(index.data(RawDecorationRole));
544  return platformStyle->TextColorIcon(icon);
545  }
546  case Qt::DisplayRole:
547  switch (column) {
548  case Status: return {};
549  case Watchonly: return {};
550  case Date:
551  return formatTxDate(rec);
552  case Type:
553  return formatTxType(rec);
554  case ToAddress:
555  return formatTxToAddress(rec, false);
556  case Amount:
558  } // no default case, so the compiler can warn about missing cases
559  assert(false);
560  case Qt::EditRole:
561  // Edit role is used for sorting, so return the unformatted values
562  switch (column) {
563  case Status:
564  return QString::fromStdString(rec->status.sortKey);
565  case Date:
566  return rec->time;
567  case Type:
568  return formatTxType(rec);
569  case Watchonly:
570  return (rec->involvesWatchAddress ? 1 : 0);
571  case ToAddress:
572  return formatTxToAddress(rec, true);
573  case Amount:
574  return qint64(rec->credit + rec->debit);
575  } // no default case, so the compiler can warn about missing cases
576  assert(false);
577  case Qt::ToolTipRole:
578  return formatTooltip(rec);
579  case Qt::TextAlignmentRole:
580  return column_alignments[index.column()];
581  case Qt::ForegroundRole:
582  // Use the "danger" color for abandoned transactions
584  {
585  return COLOR_TX_STATUS_DANGER;
586  }
587  // Non-confirmed (but not immature) as transactions are grey
589  {
590  return COLOR_UNCONFIRMED;
591  }
592  if(index.column() == Amount && (rec->credit+rec->debit) < 0)
593  {
594  return COLOR_NEGATIVE;
595  }
596  if(index.column() == ToAddress)
597  {
598  return addressColor(rec);
599  }
600  break;
601  case TypeRole:
602  return rec->type;
603  case DateRole:
604  return QDateTime::fromSecsSinceEpoch(rec->time);
605  case WatchonlyRole:
606  return rec->involvesWatchAddress;
608  return txWatchonlyDecoration(rec);
609  case LongDescriptionRole:
611  case AddressRole:
612  return QString::fromStdString(rec->address);
613  case LabelRole:
614  return walletModel->getAddressTableModel()->labelForAddress(QString::fromStdString(rec->address));
615  case AmountRole:
616  return qint64(rec->credit + rec->debit);
617  case TxHashRole:
618  return rec->getTxHash();
619  case TxHexRole:
620  return priv->getTxHex(walletModel->wallet(), rec);
621  case TxPlainTextRole:
622  {
623  QString details;
624  QDateTime date = QDateTime::fromSecsSinceEpoch(rec->time);
625  QString txLabel = walletModel->getAddressTableModel()->labelForAddress(QString::fromStdString(rec->address));
626 
627  details.append(date.toString("M/d/yy HH:mm"));
628  details.append(" ");
629  details.append(formatTxStatus(rec));
630  details.append(". ");
631  if(!formatTxType(rec).isEmpty()) {
632  details.append(formatTxType(rec));
633  details.append(" ");
634  }
635  if(!rec->address.empty()) {
636  if(txLabel.isEmpty())
637  details.append(tr("(no label)") + " ");
638  else {
639  details.append("(");
640  details.append(txLabel);
641  details.append(") ");
642  }
643  details.append(QString::fromStdString(rec->address));
644  details.append(" ");
645  }
646  details.append(formatTxAmount(rec, false, BitcoinUnits::SeparatorStyle::NEVER));
647  return details;
648  }
649  case ConfirmedRole:
650  return rec->status.status == TransactionStatus::Status::Confirming || rec->status.status == TransactionStatus::Status::Confirmed;
651  case FormattedAmountRole:
652  // Used for copy/export, so don't include separators
654  case StatusRole:
655  return rec->status.status;
656  }
657  return QVariant();
658 }
659 
660 QVariant TransactionTableModel::headerData(int section, Qt::Orientation orientation, int role) const
661 {
662  if(orientation == Qt::Horizontal)
663  {
664  if(role == Qt::DisplayRole)
665  {
666  return columns[section];
667  }
668  else if (role == Qt::TextAlignmentRole)
669  {
670  return column_alignments[section];
671  } else if (role == Qt::ToolTipRole)
672  {
673  switch(section)
674  {
675  case Status:
676  return tr("Transaction status. Hover over this field to show number of confirmations.");
677  case Date:
678  return tr("Date and time that the transaction was received.");
679  case Type:
680  return tr("Type of transaction.");
681  case Watchonly:
682  return tr("Whether or not a watch-only address is involved in this transaction.");
683  case ToAddress:
684  return tr("User-defined intent/purpose of the transaction.");
685  case Amount:
686  return tr("Amount removed from or added to balance.");
687  }
688  }
689  }
690  return QVariant();
691 }
692 
693 QModelIndex TransactionTableModel::index(int row, int column, const QModelIndex &parent) const
694 {
695  Q_UNUSED(parent);
697  if(data)
698  {
699  return createIndex(row, column, data);
700  }
701  return QModelIndex();
702 }
703 
705 {
706  // emit dataChanged to update Amount column with the current unit
708  Q_EMIT dataChanged(index(0, Amount), index(priv->size()-1, Amount));
709 }
710 
712 {
713  // Find transaction in wallet
714  // Determine whether to show transaction or not (determine this here so that no relocking is needed in GUI thread)
715  bool showTransaction = TransactionRecord::showTransaction();
716 
717  TransactionNotification notification(hash, status, showTransaction);
718 
719  if (!m_loaded || m_loading)
720  {
721  vQueueNotifications.push_back(notification);
722  return;
723  }
724  notification.invoke(parent);
725 }
726 
728 {
729  if (!m_loaded || m_loading) return;
730 
731  if (vQueueNotifications.size() > 10) { // prevent balloon spam, show maximum 10 balloons
732  bool invoked = QMetaObject::invokeMethod(parent, "setProcessingQueuedTransactions", Qt::QueuedConnection, Q_ARG(bool, true));
733  assert(invoked);
734  }
735  for (unsigned int i = 0; i < vQueueNotifications.size(); ++i)
736  {
737  if (vQueueNotifications.size() - i <= 10) {
738  bool invoked = QMetaObject::invokeMethod(parent, "setProcessingQueuedTransactions", Qt::QueuedConnection, Q_ARG(bool, false));
739  assert(invoked);
740  }
741 
742  vQueueNotifications[i].invoke(parent);
743  }
744  vQueueNotifications.clear();
745 }
746 
748 {
749  // Connect signals to wallet
751  m_handler_show_progress = walletModel->wallet().handleShowProgress([this](const std::string&, int progress) {
752  priv->m_loading = progress < 100;
754  });
755 }
756 
758 {
759  // Disconnect signals from wallet
760  m_handler_transaction_changed->disconnect();
761  m_handler_show_progress->disconnect();
762 }
TransactionRecord::statusUpdateNeeded
bool statusUpdateNeeded(const uint256 &block_hash) const
Return whether a status update is needed.
Definition: transactionrecord.cpp:226
WalletModel::getOptionsModel
OptionsModel * getOptionsModel()
Definition: walletmodel.cpp:287
TransactionRecord::getTxHash
QString getTxHash() const
Return the unique identifier for this transaction (part)
Definition: transactionrecord.cpp:232
TransactionTableModel::txAddressDecoration
QVariant txAddressDecoration(const TransactionRecord *wtx) const
Definition: transactiontablemodel.cpp:392
transactiontablemodel.h
BitcoinUnits::SeparatorStyle::NEVER
@ NEVER
TransactionTableModel::formatTxStatus
QString formatTxStatus(const TransactionRecord *wtx) const
Definition: transactiontablemodel.cpp:313
TransactionTableModel::TxHexRole
@ TxHexRole
Transaction data, hex-encoded.
Definition: transactiontablemodel.h:66
TransactionTableModel::updateConfirmations
void updateConfirmations()
Definition: transactiontablemodel.cpp:287
TransactionTableModel::txStatusDecoration
QVariant txStatusDecoration(const TransactionRecord *wtx) const
Definition: transactiontablemodel.cpp:468
TransactionRecord::decomposeTransaction
static QList< TransactionRecord > decomposeTransaction(const interfaces::WalletTx &wtx)
Definition: transactionrecord.cpp:32
assert
assert(!tx.IsCoinBase())
TransactionStatus::sortKey
std::string sortKey
Sorting key based on status.
Definition: transactionrecord.h:45
WalletModel::getLastBlockProcessed
uint256 getLastBlockProcessed() const
Definition: walletmodel.cpp:598
TransactionTablePriv::index
TransactionRecord * index(interfaces::Wallet &wallet, const uint256 &cur_block_hash, const int idx)
Definition: transactiontablemodel.cpp:216
TransactionStatus::needsUpdate
bool needsUpdate
Definition: transactionrecord.h:64
TransactionTablePriv::size
int size()
Definition: transactiontablemodel.cpp:211
TransactionTableModel::Date
@ Date
Definition: transactiontablemodel.h:37
WalletModel
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:52
TxLessThan
Definition: transactiontablemodel.cpp:44
TransactionTableModel::AddressRole
@ AddressRole
Address of transaction.
Definition: transactiontablemodel.h:58
TransactionNotification::invoke
void invoke(QObject *ttm)
Definition: transactiontablemodel.cpp:68
TransactionRecord::status
TransactionStatus status
Status: can change with block chain update.
Definition: transactionrecord.h:125
TransactionRecord::hash
uint256 hash
Definition: transactionrecord.h:113
transactiondesc.h
TransactionTableModel::formatTxDate
QString formatTxDate(const TransactionRecord *wtx) const
Definition: transactiontablemodel.cpp:345
TransactionTableModel::headerData
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
Definition: transactiontablemodel.cpp:660
TransactionRecord::RecvWithAddress
@ RecvWithAddress
Definition: transactionrecord.h:79
TransactionTableModel::TxPlainTextRole
@ TxPlainTextRole
Whole transaction as plain text.
Definition: transactiontablemodel.h:68
walletmodel.h
TransactionTablePriv::TransactionTablePriv
TransactionTablePriv(TransactionTableModel *_parent)
Definition: transactiontablemodel.cpp:88
TransactionTablePriv::NotifyTransactionChanged
void NotifyTransactionChanged(const uint256 &hash, ChangeType status)
Definition: transactiontablemodel.cpp:711
uint256.h
WalletModel::getAddressTableModel
AddressTableModel * getAddressTableModel()
Definition: walletmodel.cpp:292
TransactionTableModel::WatchonlyRole
@ WatchonlyRole
Watch-only boolean.
Definition: transactiontablemodel.h:52
AddressTableModel::labelForAddress
QString labelForAddress(const QString &address) const
Look up label for address in address book, if not found return empty string.
Definition: addresstablemodel.cpp:412
TransactionTablePriv::DispatchNotifications
void DispatchNotifications()
Definition: transactiontablemodel.cpp:727
TransactionStatus::Conflicted
@ Conflicted
Conflicts with other transaction or mempool.
Definition: transactionrecord.h:35
handler.h
CT_DELETED
@ CT_DELETED
Definition: ui_change_type.h:12
TransactionRecord::credit
CAmount credit
Definition: transactionrecord.h:118
COLOR_BLACK
#define COLOR_BLACK
Definition: guiconstants.h:39
OptionsModel::displayUnitChanged
void displayUnitChanged(int unit)
CT_UPDATED
@ CT_UPDATED
Definition: ui_change_type.h:11
TransactionTablePriv::describe
QString describe(interfaces::Node &node, interfaces::Wallet &wallet, TransactionRecord *rec, int unit)
Definition: transactiontablemodel.cpp:235
wallet
Definition: node.h:38
TransactionTablePriv::parent
TransactionTableModel * parent
Definition: transactiontablemodel.cpp:93
COLOR_TX_STATUS_DANGER
#define COLOR_TX_STATUS_DANGER
Definition: guiconstants.h:37
TransactionTableModel::txWatchonlyDecoration
QVariant txWatchonlyDecoration(const TransactionRecord *wtx) const
Definition: transactiontablemodel.cpp:501
COLOR_BAREADDRESS
#define COLOR_BAREADDRESS
Definition: guiconstants.h:35
TransactionDesc::toHTML
static QString toHTML(interfaces::Node &node, interfaces::Wallet &wallet, TransactionRecord *rec, int unit)
Definition: transactiondesc.cpp:80
TransactionNotification::hash
uint256 hash
Definition: transactiontablemodel.cpp:79
TransactionRecord::RecommendedNumConfirmations
static const int RecommendedNumConfirmations
Number of confirmation recommended for accepting a transaction.
Definition: transactionrecord.h:85
core_io.h
COLOR_NEGATIVE
#define COLOR_NEGATIVE
Definition: guiconstants.h:33
TransactionNotification::TransactionNotification
TransactionNotification(uint256 _hash, ChangeType _status, bool _showTransaction)
Definition: transactiontablemodel.cpp:65
TransactionRecord::RecvFromOther
@ RecvFromOther
Definition: transactionrecord.h:80
TransactionRecord
UI model for a transaction.
Definition: transactionrecord.h:70
TransactionRecord::time
qint64 time
Definition: transactionrecord.h:114
TransactionTableModel::ColumnIndex
ColumnIndex
Definition: transactiontablemodel.h:34
TransactionTableModel::updateDisplayUnit
void updateDisplayUnit()
Definition: transactiontablemodel.cpp:704
TransactionTableModel::updateTransaction
void updateTransaction(const QString &hash, int status, bool showTransaction)
Definition: transactiontablemodel.cpp:279
WalletModel::node
interfaces::Node & node() const
Definition: walletmodel.h:144
TransactionTableModel::index
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Definition: transactiontablemodel.cpp:693
TransactionTableModel::RawDecorationRole
@ RawDecorationRole
Unprocessed icon.
Definition: transactiontablemodel.h:76
TransactionTableModel::AmountRole
@ AmountRole
Net amount of transaction.
Definition: transactiontablemodel.h:62
TransactionTableModel::subscribeToCoreSignals
void subscribeToCoreSignals()
Definition: transactiontablemodel.cpp:747
WalletModel::wallet
interfaces::Wallet & wallet() const
Definition: walletmodel.h:145
ChangeType
ChangeType
General change type (added, updated, removed).
Definition: ui_change_type.h:9
TransactionNotification::status
ChangeType status
Definition: transactiontablemodel.cpp:80
TransactionTableModel::m_handler_show_progress
std::unique_ptr< interfaces::Handler > m_handler_show_progress
Definition: transactiontablemodel.h:89
PlatformStyle::TextColorIcon
QIcon TextColorIcon(const QIcon &icon) const
Colorize an icon (given object) with the text color.
Definition: platformstyle.cpp:119
TransactionTableModel::unsubscribeFromCoreSignals
void unsubscribeFromCoreSignals()
Definition: transactiontablemodel.cpp:757
TransactionTablePriv::cachedWallet
QList< TransactionRecord > cachedWallet
Definition: transactiontablemodel.cpp:99
TransactionRecord::SendToOther
@ SendToOther
Definition: transactionrecord.h:78
TransactionTableModel::ToAddress
@ ToAddress
Definition: transactiontablemodel.h:39
TransactionTableModel::formatTxToAddress
QString formatTxToAddress(const TransactionRecord *wtx, bool tooltip) const
Definition: transactiontablemodel.cpp:409
TransactionRecord::involvesWatchAddress
bool involvesWatchAddress
Whether the transaction was sent/received with a watch-only address.
Definition: transactionrecord.h:128
TransactionTableModel::rowCount
int rowCount(const QModelIndex &parent) const override
Definition: transactiontablemodel.cpp:297
interfaces::WalletTx
Definition: wallet.h:385
column_alignments
static int column_alignments[]
Definition: transactiontablemodel.cpp:34
TransactionTableModel::priv
TransactionTablePriv * priv
Definition: transactiontablemodel.h:91
TransactionTableModel::columnCount
int columnCount(const QModelIndex &parent) const override
Definition: transactiontablemodel.cpp:305
base_blob::GetHex
std::string GetHex() const
Definition: uint256.cpp:20
TransactionNotification::showTransaction
bool showTransaction
Definition: transactiontablemodel.cpp:81
BitcoinUnits::SeparatorStyle
SeparatorStyle
Definition: bitcoinunits.h:49
TransactionTableModel::StatusRole
@ StatusRole
Transaction status (TransactionRecord::Status)
Definition: transactiontablemodel.h:74
TransactionTablePriv::vQueueNotifications
std::vector< TransactionNotification > vQueueNotifications
Definition: transactiontablemodel.cpp:105
interfaces::Wallet::handleShowProgress
virtual std::unique_ptr< Handler > handleShowProgress(ShowProgressFn fn)=0
guiutil.h
TransactionRecord::Generated
@ Generated
Definition: transactionrecord.h:76
TransactionTableModel::Amount
@ Amount
Definition: transactiontablemodel.h:40
TransactionTableModel::columns
QStringList columns
Definition: transactiontablemodel.h:90
base_blob::ToString
std::string ToString() const
Definition: uint256.cpp:64
uint256
256-bit opaque blob.
Definition: uint256.h:126
interfaces::WalletTxStatus
Updated transaction status.
Definition: wallet.h:401
TransactionRecord::debit
CAmount debit
Definition: transactionrecord.h:117
TransactionTableModel::m_handler_transaction_changed
std::unique_ptr< interfaces::Handler > m_handler_transaction_changed
Definition: transactiontablemodel.h:88
TransactionStatus::Abandoned
@ Abandoned
Abandoned from the wallet.
Definition: transactionrecord.h:36
interfaces::Wallet
Interface for accessing a wallet.
Definition: wallet.h:56
TransactionRecord::SendToSelf
@ SendToSelf
Definition: transactionrecord.h:81
TransactionStatus::Immature
@ Immature
Generated (mined) transactions.
Definition: transactionrecord.h:38
TxLessThan::operator()
bool operator()(const TransactionRecord &a, const TransactionRecord &b) const
Definition: transactiontablemodel.cpp:46
interfaces::Node
Top-level interface for a bitcoin node (bitcoind process).
Definition: node.h:68
TransactionRecord::type
Type type
Definition: transactionrecord.h:115
TransactionTableModel::FormattedAmountRole
@ FormattedAmountRole
Formatted amount, without brackets when unconfirmed.
Definition: transactiontablemodel.h:72
TransactionStatus::Confirmed
@ Confirmed
Have 6 or more confirmations (normal tx) or fully mature (mined tx)
Definition: transactionrecord.h:31
EncodeHexTx
std::string EncodeHexTx(const CTransaction &tx, const int serializeFlags=0)
Definition: core_write.cpp:139
TransactionTableModel::LongDescriptionRole
@ LongDescriptionRole
Long description (HTML format)
Definition: transactiontablemodel.h:56
BitcoinUnits::SeparatorStyle::ALWAYS
@ ALWAYS
TransactionTableModel::addressColor
QVariant addressColor(const TransactionRecord *wtx) const
Definition: transactiontablemodel.cpp:434
transactionrecord.h
platformstyle.h
TransactionTablePriv::refreshWallet
void refreshWallet(interfaces::Wallet &wallet)
Definition: transactiontablemodel.cpp:112
TransactionRecord::address
std::string address
Definition: transactionrecord.h:116
TransactionTableModel::TransactionTableModel
TransactionTableModel(const PlatformStyle *platformStyle, WalletModel *parent=nullptr)
Definition: transactiontablemodel.cpp:251
TransactionTablePriv::m_loading
bool m_loading
True when transactions are being notified, for instance when scanning.
Definition: transactiontablemodel.cpp:104
TransactionTableModel
UI model for the transaction table of a wallet.
Definition: transactiontablemodel.h:26
base_blob::IsNull
bool IsNull() const
Definition: uint256.h:33
guiconstants.h
TransactionStatus::Confirming
@ Confirming
Confirmed, but waiting for the recommended number of confirmations.
Definition: transactionrecord.h:34
TransactionTableModel::formatTxType
QString formatTxType(const TransactionRecord *wtx) const
Definition: transactiontablemodel.cpp:372
TransactionNotification
Definition: transactiontablemodel.cpp:61
TransactionStatus::status
Status status
Definition: transactionrecord.h:54
TransactionTablePriv
Definition: transactiontablemodel.cpp:85
OptionsModel::getDisplayUnit
int getDisplayUnit() const
Definition: optionsmodel.h:89
TransactionStatus::matures_in
int matures_in
Definition: transactionrecord.h:49
TransactionTablePriv::getTxHex
QString getTxHex(interfaces::Wallet &wallet, TransactionRecord *rec)
Definition: transactiontablemodel.cpp:240
TransactionTableModel::~TransactionTableModel
~TransactionTableModel()
Definition: transactiontablemodel.cpp:266
TransactionTableModel::WatchonlyDecorationRole
@ WatchonlyDecorationRole
Watch-only icon.
Definition: transactiontablemodel.h:54
BitcoinUnits::getAmountColumnTitle
static QString getAmountColumnTitle(int unit)
Gets title for amount column including current display unit if optionsModel reference available *‍/.
Definition: bitcoinunits.cpp:213
TransactionTableModel::Type
@ Type
Definition: transactiontablemodel.h:38
TransactionTablePriv::m_loaded
bool m_loaded
True when model finishes loading all wallet transactions on start.
Definition: transactiontablemodel.cpp:102
TxLessThan::operator()
bool operator()(const uint256 &a, const TransactionRecord &b) const
Definition: transactiontablemodel.cpp:54
TransactionTableModel::lookupAddress
QString lookupAddress(const std::string &address, bool tooltip) const
Definition: transactiontablemodel.cpp:357
TxLessThan::operator()
bool operator()(const TransactionRecord &a, const uint256 &b) const
Definition: transactiontablemodel.cpp:50
TransactionNotification::TransactionNotification
TransactionNotification()
Definition: transactiontablemodel.cpp:64
TransactionRecord::SendToAddress
@ SendToAddress
Definition: transactionrecord.h:77
TransactionTableModel::TxHashRole
@ TxHashRole
Transaction hash.
Definition: transactiontablemodel.h:64
node
Definition: init.h:22
TransactionTableModel::Status
@ Status
Definition: transactiontablemodel.h:35
TransactionTableModel::formatTxAmount
QString formatTxAmount(const TransactionRecord *wtx, bool showUnconfirmed=true, BitcoinUnits::SeparatorStyle separators=BitcoinUnits::SeparatorStyle::STANDARD) const
Definition: transactiontablemodel.cpp:455
TransactionTableModel::platformStyle
const PlatformStyle * platformStyle
Definition: transactiontablemodel.h:93
GUIUtil::dateTimeStr
QString dateTimeStr(const QDateTime &date)
Definition: guiutil.cpp:84
TransactionTableModel::DateRole
@ DateRole
Date and time this transaction was created.
Definition: transactiontablemodel.h:50
TransactionStatus::depth
qint64 depth
Definition: transactionrecord.h:55
CT_NEW
@ CT_NEW
Definition: ui_change_type.h:10
TransactionStatus::NotAccepted
@ NotAccepted
Mined but not accepted.
Definition: transactionrecord.h:39
optionsmodel.h
TransactionStatus::countsForBalance
bool countsForBalance
Transaction counts towards available balance.
Definition: transactionrecord.h:43
TransactionStatus::Unconfirmed
@ Unconfirmed
Normal (sent/received) transactions.
Definition: transactionrecord.h:33
TransactionTableModel::TypeRole
@ TypeRole
Type of transaction.
Definition: transactiontablemodel.h:48
PlatformStyle
Definition: platformstyle.h:13
TransactionTableModel::updateAmountColumnTitle
void updateAmountColumnTitle()
Updates the column title to "Amount (DisplayUnit)" and emits headerDataChanged() signal for table hea...
Definition: transactiontablemodel.cpp:273
interfaces::WalletTx::tx
CTransactionRef tx
Definition: wallet.h:387
TransactionTableModel::LabelRole
@ LabelRole
Label of address related to transaction.
Definition: transactiontablemodel.h:60
addresstablemodel.h
TransactionTableModel::Watchonly
@ Watchonly
Definition: transactiontablemodel.h:36
base_blob::SetHex
void SetHex(const char *psz)
Definition: uint256.cpp:30
TransactionTableModel::formatTooltip
QString formatTooltip(const TransactionRecord *rec) const
Definition: transactiontablemodel.cpp:509
TransactionTablePriv::updateWallet
void updateWallet(interfaces::Wallet &wallet, const uint256 &hash, int status, bool showTransaction)
Definition: transactiontablemodel.cpp:131
TransactionTableModel::walletModel
WalletModel * walletModel
Definition: transactiontablemodel.h:87
COLOR_UNCONFIRMED
#define COLOR_UNCONFIRMED
Definition: guiconstants.h:31
interfaces::Wallet::handleTransactionChanged
virtual std::unique_ptr< Handler > handleTransactionChanged(TransactionChangedFn fn)=0
clientmodel.h
TransactionRecord::updateStatus
void updateStatus(const interfaces::WalletTxStatus &wtx, const uint256 &block_hash, int numBlocks, int64_t block_time)
Update status from core wallet tx.
Definition: transactionrecord.cpp:168
TransactionTableModel::ConfirmedRole
@ ConfirmedRole
Is transaction confirmed?
Definition: transactiontablemodel.h:70
BitcoinUnits::format
static QString format(int unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=SeparatorStyle::STANDARD, bool justify=false)
Format as string.
Definition: bitcoinunits.cpp:103
TransactionRecord::showTransaction
static bool showTransaction()
Decompose CWallet transaction to model transaction records.
Definition: transactionrecord.cpp:22
TransactionTableModel::data
QVariant data(const QModelIndex &index, int role) const override
Definition: transactiontablemodel.cpp:520