Bitcoin Core  21.99.0
P2P Digital Currency
transactiontablemodel.cpp
Go to the documentation of this file.
1 // Copyright (c) 2011-2020 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 <QList>
29 
30 
31 // Amount column is right-aligned it contains numbers
32 static int column_alignments[] = {
33  Qt::AlignLeft|Qt::AlignVCenter, /* status */
34  Qt::AlignLeft|Qt::AlignVCenter, /* watchonly */
35  Qt::AlignLeft|Qt::AlignVCenter, /* date */
36  Qt::AlignLeft|Qt::AlignVCenter, /* type */
37  Qt::AlignLeft|Qt::AlignVCenter, /* address */
38  Qt::AlignRight|Qt::AlignVCenter /* amount */
39  };
40 
41 // Comparison operator for sort/binary search of model tx list
42 struct TxLessThan
43 {
44  bool operator()(const TransactionRecord &a, const TransactionRecord &b) const
45  {
46  return a.hash < b.hash;
47  }
48  bool operator()(const TransactionRecord &a, const uint256 &b) const
49  {
50  return a.hash < b;
51  }
52  bool operator()(const uint256 &a, const TransactionRecord &b) const
53  {
54  return a < b.hash;
55  }
56 };
57 
58 // queue notifications to show a non freezing progress dialog e.g. for rescan
60 {
61 public:
63  TransactionNotification(uint256 _hash, ChangeType _status, bool _showTransaction):
64  hash(_hash), status(_status), showTransaction(_showTransaction) {}
65 
66  void invoke(QObject *ttm)
67  {
68  QString strHash = QString::fromStdString(hash.GetHex());
69  qDebug() << "NotifyTransactionChanged: " + strHash + " status= " + QString::number(status);
70  bool invoked = QMetaObject::invokeMethod(ttm, "updateTransaction", Qt::QueuedConnection,
71  Q_ARG(QString, strHash),
72  Q_ARG(int, status),
73  Q_ARG(bool, showTransaction));
74  assert(invoked);
75  }
76 private:
80 };
81 
82 // Private implementation
84 {
85 public:
87  parent(_parent)
88  {
89  }
90 
92 
93  /* Local cache of wallet.
94  * As it is in the same order as the CWallet, by definition
95  * this is sorted by sha256.
96  */
97  QList<TransactionRecord> cachedWallet;
98 
99  bool fQueueNotifications = false;
100  std::vector< TransactionNotification > vQueueNotifications;
101 
102  void NotifyTransactionChanged(const uint256 &hash, ChangeType status);
103  void ShowProgress(const std::string &title, int nProgress);
104 
105  /* Query entire wallet anew from core.
106  */
108  {
109  qDebug() << "TransactionTablePriv::refreshWallet";
110  cachedWallet.clear();
111  {
112  for (const auto& wtx : wallet.getWalletTxs()) {
115  }
116  }
117  }
118  }
119 
120  /* Update our model of the wallet incrementally, to synchronize our model of the wallet
121  with that of the core.
122 
123  Call with transaction that was added, removed or changed.
124  */
125  void updateWallet(interfaces::Wallet& wallet, const uint256 &hash, int status, bool showTransaction)
126  {
127  qDebug() << "TransactionTablePriv::updateWallet: " + QString::fromStdString(hash.ToString()) + " " + QString::number(status);
128 
129  // Find bounds of this transaction in model
130  QList<TransactionRecord>::iterator lower = std::lower_bound(
131  cachedWallet.begin(), cachedWallet.end(), hash, TxLessThan());
132  QList<TransactionRecord>::iterator upper = std::upper_bound(
133  cachedWallet.begin(), cachedWallet.end(), hash, TxLessThan());
134  int lowerIndex = (lower - cachedWallet.begin());
135  int upperIndex = (upper - cachedWallet.begin());
136  bool inModel = (lower != upper);
137 
138  if(status == CT_UPDATED)
139  {
140  if(showTransaction && !inModel)
141  status = CT_NEW; /* Not in model, but want to show, treat as new */
142  if(!showTransaction && inModel)
143  status = CT_DELETED; /* In model, but want to hide, treat as deleted */
144  }
145 
146  qDebug() << " inModel=" + QString::number(inModel) +
147  " Index=" + QString::number(lowerIndex) + "-" + QString::number(upperIndex) +
148  " showTransaction=" + QString::number(showTransaction) + " derivedStatus=" + QString::number(status);
149 
150  switch(status)
151  {
152  case CT_NEW:
153  if(inModel)
154  {
155  qWarning() << "TransactionTablePriv::updateWallet: Warning: Got CT_NEW, but transaction is already in model";
156  break;
157  }
158  if(showTransaction)
159  {
160  // Find transaction in wallet
161  interfaces::WalletTx wtx = wallet.getWalletTx(hash);
162  if(!wtx.tx)
163  {
164  qWarning() << "TransactionTablePriv::updateWallet: Warning: Got CT_NEW, but transaction is not in wallet";
165  break;
166  }
167  // Added -- insert at the right position
168  QList<TransactionRecord> toInsert =
170  if(!toInsert.isEmpty()) /* only if something to insert */
171  {
172  parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex+toInsert.size()-1);
173  int insert_idx = lowerIndex;
174  for (const TransactionRecord &rec : toInsert)
175  {
176  cachedWallet.insert(insert_idx, rec);
177  insert_idx += 1;
178  }
179  parent->endInsertRows();
180  }
181  }
182  break;
183  case CT_DELETED:
184  if(!inModel)
185  {
186  qWarning() << "TransactionTablePriv::updateWallet: Warning: Got CT_DELETED, but transaction is not in model";
187  break;
188  }
189  // Removed -- remove entire transaction from table
190  parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1);
191  cachedWallet.erase(lower, upper);
192  parent->endRemoveRows();
193  break;
194  case CT_UPDATED:
195  // Miscellaneous updates -- nothing to do, status update will take care of this, and is only computed for
196  // visible transactions.
197  for (int i = lowerIndex; i < upperIndex; i++) {
198  TransactionRecord *rec = &cachedWallet[i];
199  rec->status.needsUpdate = true;
200  }
201  break;
202  }
203  }
204 
205  int size()
206  {
207  return cachedWallet.size();
208  }
209 
210  TransactionRecord* index(interfaces::Wallet& wallet, const uint256& cur_block_hash, const int idx)
211  {
212  if (idx >= 0 && idx < cachedWallet.size()) {
213  TransactionRecord *rec = &cachedWallet[idx];
214 
215  // If a status update is needed (blocks came in since last check),
216  // try to update the status of this transaction from the wallet.
217  // Otherwise, simply re-use the cached status.
219  int numBlocks;
220  int64_t block_time;
221  if (!cur_block_hash.IsNull() && rec->statusUpdateNeeded(cur_block_hash) && wallet.tryGetTxStatus(rec->hash, wtx, numBlocks, block_time)) {
222  rec->updateStatus(wtx, cur_block_hash, numBlocks, block_time);
223  }
224  return rec;
225  }
226  return nullptr;
227  }
228 
230  {
231  return TransactionDesc::toHTML(node, wallet, rec, unit);
232  }
233 
235  {
236  auto tx = wallet.getTx(rec->hash);
237  if (tx) {
238  std::string strHex = EncodeHexTx(*tx);
239  return QString::fromStdString(strHex);
240  }
241  return QString();
242  }
243 };
244 
246  QAbstractTableModel(parent),
247  walletModel(parent),
248  priv(new TransactionTablePriv(this)),
249  fProcessingQueuedTransactions(false),
250  platformStyle(_platformStyle)
251 {
252  columns << QString() << QString() << tr("Date") << tr("Type") << tr("Label") << BitcoinUnits::getAmountColumnTitle(walletModel->getOptionsModel()->getDisplayUnit());
254 
256 
258 }
259 
261 {
263  delete priv;
264 }
265 
268 {
270  Q_EMIT headerDataChanged(Qt::Horizontal,Amount,Amount);
271 }
272 
273 void TransactionTableModel::updateTransaction(const QString &hash, int status, bool showTransaction)
274 {
275  uint256 updated;
276  updated.SetHex(hash.toStdString());
277 
278  priv->updateWallet(walletModel->wallet(), updated, status, showTransaction);
279 }
280 
282 {
283  // Blocks came in since last poll.
284  // Invalidate status (number of confirmations) and (possibly) description
285  // for all rows. Qt is smart enough to only actually request the data for the
286  // visible rows.
287  Q_EMIT dataChanged(index(0, Status), index(priv->size()-1, Status));
288  Q_EMIT dataChanged(index(0, ToAddress), index(priv->size()-1, ToAddress));
289 }
290 
291 int TransactionTableModel::rowCount(const QModelIndex &parent) const
292 {
293  if (parent.isValid()) {
294  return 0;
295  }
296  return priv->size();
297 }
298 
299 int TransactionTableModel::columnCount(const QModelIndex &parent) const
300 {
301  if (parent.isValid()) {
302  return 0;
303  }
304  return columns.length();
305 }
306 
308 {
309  QString status;
310 
311  switch(wtx->status.status)
312  {
314  status = tr("Open for %n more block(s)","",wtx->status.open_for);
315  break;
317  status = tr("Open until %1").arg(GUIUtil::dateTimeStr(wtx->status.open_for));
318  break;
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) {
413  // Mark transactions involving watch-only addresses by adding " (watch-only)"
414  watchAddress = wtx->involvesWatchAddress ? QString(" (") + tr("watch-only") + QString(")") : "";
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  {
476  return QIcon(":/icons/transaction_0");
478  return QIcon(":/icons/transaction_abandoned");
480  switch(wtx->status.depth)
481  {
482  case 1: return QIcon(":/icons/transaction_1");
483  case 2: return QIcon(":/icons/transaction_2");
484  case 3: return QIcon(":/icons/transaction_3");
485  case 4: return QIcon(":/icons/transaction_4");
486  default: return QIcon(":/icons/transaction_5");
487  };
489  return QIcon(":/icons/transaction_confirmed");
491  return QIcon(":/icons/transaction_conflicted");
493  int total = wtx->status.depth + wtx->status.matures_in;
494  int part = (wtx->status.depth * 4 / total) + 1;
495  return QIcon(QString(":/icons/transaction_%1").arg(part));
496  }
498  return QIcon(":/icons/transaction_0");
499  default:
500  return COLOR_BLACK;
501  }
502 }
503 
505 {
506  if (wtx->involvesWatchAddress)
507  return QIcon(":/icons/eye");
508  else
509  return QVariant();
510 }
511 
513 {
514  QString tooltip = formatTxStatus(rec) + QString("\n") + formatTxType(rec);
517  {
518  tooltip += QString(" ") + formatTxToAddress(rec, true);
519  }
520  return tooltip;
521 }
522 
523 QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
524 {
525  if(!index.isValid())
526  return QVariant();
527  TransactionRecord *rec = static_cast<TransactionRecord*>(index.internalPointer());
528 
529  const auto column = static_cast<ColumnIndex>(index.column());
530  switch (role) {
531  case RawDecorationRole:
532  switch (column) {
533  case Status:
534  return txStatusDecoration(rec);
535  case Watchonly:
536  return txWatchonlyDecoration(rec);
537  case Date: return {};
538  case Type: return {};
539  case ToAddress:
540  return txAddressDecoration(rec);
541  case Amount: return {};
542  } // no default case, so the compiler can warn about missing cases
543  assert(false);
544  case Qt::DecorationRole:
545  {
546  QIcon icon = qvariant_cast<QIcon>(index.data(RawDecorationRole));
547  return platformStyle->TextColorIcon(icon);
548  }
549  case Qt::DisplayRole:
550  switch (column) {
551  case Status: return {};
552  case Watchonly: return {};
553  case Date:
554  return formatTxDate(rec);
555  case Type:
556  return formatTxType(rec);
557  case ToAddress:
558  return formatTxToAddress(rec, false);
559  case Amount:
561  } // no default case, so the compiler can warn about missing cases
562  assert(false);
563  case Qt::EditRole:
564  // Edit role is used for sorting, so return the unformatted values
565  switch (column) {
566  case Status:
567  return QString::fromStdString(rec->status.sortKey);
568  case Date:
569  return rec->time;
570  case Type:
571  return formatTxType(rec);
572  case Watchonly:
573  return (rec->involvesWatchAddress ? 1 : 0);
574  case ToAddress:
575  return formatTxToAddress(rec, true);
576  case Amount:
577  return qint64(rec->credit + rec->debit);
578  } // no default case, so the compiler can warn about missing cases
579  assert(false);
580  case Qt::ToolTipRole:
581  return formatTooltip(rec);
582  case Qt::TextAlignmentRole:
583  return column_alignments[index.column()];
584  case Qt::ForegroundRole:
585  // Use the "danger" color for abandoned transactions
587  {
588  return COLOR_TX_STATUS_DANGER;
589  }
590  // Non-confirmed (but not immature) as transactions are grey
592  {
593  return COLOR_UNCONFIRMED;
594  }
595  if(index.column() == Amount && (rec->credit+rec->debit) < 0)
596  {
597  return COLOR_NEGATIVE;
598  }
599  if(index.column() == ToAddress)
600  {
601  return addressColor(rec);
602  }
603  break;
604  case TypeRole:
605  return rec->type;
606  case DateRole:
607  return QDateTime::fromTime_t(static_cast<uint>(rec->time));
608  case WatchonlyRole:
609  return rec->involvesWatchAddress;
611  return txWatchonlyDecoration(rec);
612  case LongDescriptionRole:
614  case AddressRole:
615  return QString::fromStdString(rec->address);
616  case LabelRole:
617  return walletModel->getAddressTableModel()->labelForAddress(QString::fromStdString(rec->address));
618  case AmountRole:
619  return qint64(rec->credit + rec->debit);
620  case TxHashRole:
621  return rec->getTxHash();
622  case TxHexRole:
623  return priv->getTxHex(walletModel->wallet(), rec);
624  case TxPlainTextRole:
625  {
626  QString details;
627  QDateTime date = QDateTime::fromTime_t(static_cast<uint>(rec->time));
628  QString txLabel = walletModel->getAddressTableModel()->labelForAddress(QString::fromStdString(rec->address));
629 
630  details.append(date.toString("M/d/yy HH:mm"));
631  details.append(" ");
632  details.append(formatTxStatus(rec));
633  details.append(". ");
634  if(!formatTxType(rec).isEmpty()) {
635  details.append(formatTxType(rec));
636  details.append(" ");
637  }
638  if(!rec->address.empty()) {
639  if(txLabel.isEmpty())
640  details.append(tr("(no label)") + " ");
641  else {
642  details.append("(");
643  details.append(txLabel);
644  details.append(") ");
645  }
646  details.append(QString::fromStdString(rec->address));
647  details.append(" ");
648  }
649  details.append(formatTxAmount(rec, false, BitcoinUnits::SeparatorStyle::NEVER));
650  return details;
651  }
652  case ConfirmedRole:
653  return rec->status.status == TransactionStatus::Status::Confirming || rec->status.status == TransactionStatus::Status::Confirmed;
654  case FormattedAmountRole:
655  // Used for copy/export, so don't include separators
657  case StatusRole:
658  return rec->status.status;
659  }
660  return QVariant();
661 }
662 
663 QVariant TransactionTableModel::headerData(int section, Qt::Orientation orientation, int role) const
664 {
665  if(orientation == Qt::Horizontal)
666  {
667  if(role == Qt::DisplayRole)
668  {
669  return columns[section];
670  }
671  else if (role == Qt::TextAlignmentRole)
672  {
673  return column_alignments[section];
674  } else if (role == Qt::ToolTipRole)
675  {
676  switch(section)
677  {
678  case Status:
679  return tr("Transaction status. Hover over this field to show number of confirmations.");
680  case Date:
681  return tr("Date and time that the transaction was received.");
682  case Type:
683  return tr("Type of transaction.");
684  case Watchonly:
685  return tr("Whether or not a watch-only address is involved in this transaction.");
686  case ToAddress:
687  return tr("User-defined intent/purpose of the transaction.");
688  case Amount:
689  return tr("Amount removed from or added to balance.");
690  }
691  }
692  }
693  return QVariant();
694 }
695 
696 QModelIndex TransactionTableModel::index(int row, int column, const QModelIndex &parent) const
697 {
698  Q_UNUSED(parent);
700  if(data)
701  {
702  return createIndex(row, column, data);
703  }
704  return QModelIndex();
705 }
706 
708 {
709  // emit dataChanged to update Amount column with the current unit
711  Q_EMIT dataChanged(index(0, Amount), index(priv->size()-1, Amount));
712 }
713 
715 {
716  // Find transaction in wallet
717  // Determine whether to show transaction or not (determine this here so that no relocking is needed in GUI thread)
718  bool showTransaction = TransactionRecord::showTransaction();
719 
720  TransactionNotification notification(hash, status, showTransaction);
721 
723  {
724  vQueueNotifications.push_back(notification);
725  return;
726  }
727  notification.invoke(parent);
728 }
729 
730 void TransactionTablePriv::ShowProgress(const std::string &title, int nProgress)
731 {
732  if (nProgress == 0)
733  fQueueNotifications = true;
734 
735  if (nProgress == 100)
736  {
737  fQueueNotifications = false;
738  if (vQueueNotifications.size() > 10) { // prevent balloon spam, show maximum 10 balloons
739  bool invoked = QMetaObject::invokeMethod(parent, "setProcessingQueuedTransactions", Qt::QueuedConnection, Q_ARG(bool, true));
740  assert(invoked);
741  }
742  for (unsigned int i = 0; i < vQueueNotifications.size(); ++i)
743  {
744  if (vQueueNotifications.size() - i <= 10) {
745  bool invoked = QMetaObject::invokeMethod(parent, "setProcessingQueuedTransactions", Qt::QueuedConnection, Q_ARG(bool, false));
746  assert(invoked);
747  }
748 
749  vQueueNotifications[i].invoke(parent);
750  }
751  vQueueNotifications.clear();
752  }
753 }
754 
756 {
757  // Connect signals to wallet
759  m_handler_show_progress = walletModel->wallet().handleShowProgress(std::bind(&TransactionTablePriv::ShowProgress, priv, std::placeholders::_1, std::placeholders::_2));
760 }
761 
763 {
764  // Disconnect signals from wallet
765  m_handler_transaction_changed->disconnect();
766  m_handler_show_progress->disconnect();
767 }
TransactionRecord::statusUpdateNeeded
bool statusUpdateNeeded(const uint256 &block_hash) const
Return whether a status update is needed.
Definition: transactionrecord.cpp:235
WalletModel::getOptionsModel
OptionsModel * getOptionsModel()
Definition: walletmodel.cpp:284
TransactionRecord::getTxHash
QString getTxHash() const
Return the unique identifier for this transaction (part)
Definition: transactionrecord.cpp:241
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:307
TransactionTableModel::TxHexRole
@ TxHexRole
Transaction data, hex-encoded.
Definition: transactiontablemodel.h:66
TransactionTableModel::updateConfirmations
void updateConfirmations()
Definition: transactiontablemodel.cpp:281
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:28
TransactionStatus::sortKey
std::string sortKey
Sorting key based on status.
Definition: transactionrecord.h:47
TransactionStatus::OpenUntilDate
@ OpenUntilDate
Normal (sent/received) transactions.
Definition: transactionrecord.h:33
WalletModel::getLastBlockProcessed
uint256 getLastBlockProcessed() const
Definition: walletmodel.cpp:600
TransactionTablePriv::index
TransactionRecord * index(interfaces::Wallet &wallet, const uint256 &cur_block_hash, const int idx)
Definition: transactiontablemodel.cpp:210
TransactionStatus::needsUpdate
bool needsUpdate
Definition: transactionrecord.h:66
TransactionTablePriv::size
int size()
Definition: transactiontablemodel.cpp:205
TransactionTableModel::Date
@ Date
Definition: transactiontablemodel.h:37
WalletModel
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:51
TxLessThan
Definition: transactiontablemodel.cpp:42
TransactionTableModel::AddressRole
@ AddressRole
Address of transaction.
Definition: transactiontablemodel.h:58
TransactionNotification::invoke
void invoke(QObject *ttm)
Definition: transactiontablemodel.cpp:66
TransactionRecord::status
TransactionStatus status
Status: can change with block chain update.
Definition: transactionrecord.h:127
TransactionRecord::hash
uint256 hash
Definition: transactionrecord.h:115
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:663
TransactionRecord::RecvWithAddress
@ RecvWithAddress
Definition: transactionrecord.h:81
TransactionTableModel::TxPlainTextRole
@ TxPlainTextRole
Whole transaction as plain text.
Definition: transactiontablemodel.h:68
walletmodel.h
TransactionTablePriv::TransactionTablePriv
TransactionTablePriv(TransactionTableModel *_parent)
Definition: transactiontablemodel.cpp:86
TransactionTablePriv::NotifyTransactionChanged
void NotifyTransactionChanged(const uint256 &hash, ChangeType status)
Definition: transactiontablemodel.cpp:714
uint256.h
WalletModel::getAddressTableModel
AddressTableModel * getAddressTableModel()
Definition: walletmodel.cpp:289
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
TransactionStatus::Conflicted
@ Conflicted
Conflicts with other transaction or mempool.
Definition: transactionrecord.h:37
handler.h
CT_DELETED
@ CT_DELETED
Definition: ui_change_type.h:12
TransactionRecord::credit
CAmount credit
Definition: transactionrecord.h:120
COLOR_BLACK
#define COLOR_BLACK
Definition: guiconstants.h:35
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:229
wallet
Definition: interfaces.cpp:47
TransactionTablePriv::parent
TransactionTableModel * parent
Definition: transactiontablemodel.cpp:91
COLOR_TX_STATUS_DANGER
#define COLOR_TX_STATUS_DANGER
Definition: guiconstants.h:33
TransactionTablePriv::fQueueNotifications
bool fQueueNotifications
Definition: transactiontablemodel.cpp:99
TransactionTableModel::txWatchonlyDecoration
QVariant txWatchonlyDecoration(const TransactionRecord *wtx) const
Definition: transactiontablemodel.cpp:504
COLOR_BAREADDRESS
#define COLOR_BAREADDRESS
Definition: guiconstants.h:29
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:77
TransactionRecord::RecommendedNumConfirmations
static const int RecommendedNumConfirmations
Number of confirmation recommended for accepting a transaction.
Definition: transactionrecord.h:87
core_io.h
COLOR_NEGATIVE
#define COLOR_NEGATIVE
Definition: guiconstants.h:27
TransactionNotification::TransactionNotification
TransactionNotification(uint256 _hash, ChangeType _status, bool _showTransaction)
Definition: transactiontablemodel.cpp:63
TransactionRecord::RecvFromOther
@ RecvFromOther
Definition: transactionrecord.h:82
TransactionRecord
UI model for a transaction.
Definition: transactionrecord.h:72
TransactionRecord::time
qint64 time
Definition: transactionrecord.h:116
TransactionTableModel::ColumnIndex
ColumnIndex
Definition: transactiontablemodel.h:34
TransactionTableModel::updateDisplayUnit
void updateDisplayUnit()
Definition: transactiontablemodel.cpp:707
TransactionTableModel::updateTransaction
void updateTransaction(const QString &hash, int status, bool showTransaction)
Definition: transactiontablemodel.cpp:273
WalletModel::node
interfaces::Node & node() const
Definition: walletmodel.h:145
TransactionTableModel::index
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Definition: transactiontablemodel.cpp:696
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:755
WalletModel::wallet
interfaces::Wallet & wallet() const
Definition: walletmodel.h:146
ChangeType
ChangeType
General change type (added, updated, removed).
Definition: ui_change_type.h:9
TransactionNotification::status
ChangeType status
Definition: transactiontablemodel.cpp:78
TransactionStatus::open_for
qint64 open_for
Timestamp if status==OpenUntilDate, otherwise number of additional blocks that need to be mined befor...
Definition: transactionrecord.h:58
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:116
TransactionTableModel::unsubscribeFromCoreSignals
void unsubscribeFromCoreSignals()
Definition: transactiontablemodel.cpp:762
TransactionTablePriv::cachedWallet
QList< TransactionRecord > cachedWallet
Definition: transactiontablemodel.cpp:97
TransactionRecord::SendToOther
@ SendToOther
Definition: transactionrecord.h:80
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:130
TransactionTableModel::rowCount
int rowCount(const QModelIndex &parent) const override
Definition: transactiontablemodel.cpp:291
interfaces::WalletTx
Definition: wallet.h:369
column_alignments
static int column_alignments[]
Definition: transactiontablemodel.cpp:32
TransactionTableModel::priv
TransactionTablePriv * priv
Definition: transactiontablemodel.h:91
TransactionTableModel::columnCount
int columnCount(const QModelIndex &parent) const override
Definition: transactiontablemodel.cpp:299
base_blob::GetHex
std::string GetHex() const
Definition: uint256.cpp:20
TransactionNotification::showTransaction
bool showTransaction
Definition: transactiontablemodel.cpp:79
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:100
interfaces::Wallet::handleShowProgress
virtual std::unique_ptr< Handler > handleShowProgress(ShowProgressFn fn)=0
guiutil.h
TransactionRecord::Generated
@ Generated
Definition: transactionrecord.h:78
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:124
interfaces::WalletTxStatus
Updated transaction status.
Definition: wallet.h:385
TransactionRecord::debit
CAmount debit
Definition: transactionrecord.h:119
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:38
interfaces::Wallet
Interface for accessing a wallet.
Definition: wallet.h:52
TransactionRecord::SendToSelf
@ SendToSelf
Definition: transactionrecord.h:83
TransactionStatus::Immature
@ Immature
Generated (mined) transactions.
Definition: transactionrecord.h:40
TxLessThan::operator()
bool operator()(const TransactionRecord &a, const TransactionRecord &b) const
Definition: transactiontablemodel.cpp:44
COLOR_TX_STATUS_OPENUNTILDATE
#define COLOR_TX_STATUS_OPENUNTILDATE
Definition: guiconstants.h:31
interfaces::Node
Top-level interface for a bitcoin node (bitcoind process).
Definition: node.h:53
TransactionStatus::OpenUntilBlock
@ OpenUntilBlock
Transaction not yet final, waiting for block.
Definition: transactionrecord.h:34
TransactionRecord::type
Type type
Definition: transactionrecord.h:117
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:137
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:107
TransactionRecord::address
std::string address
Definition: transactionrecord.h:118
TransactionTableModel::TransactionTableModel
TransactionTableModel(const PlatformStyle *platformStyle, WalletModel *parent=nullptr)
Definition: transactiontablemodel.cpp:245
TransactionTableModel
UI model for the transaction table of a wallet.
Definition: transactiontablemodel.h:26
base_blob::IsNull
bool IsNull() const
Definition: uint256.h:31
guiconstants.h
TransactionStatus::Confirming
@ Confirming
Confirmed, but waiting for the recommended number of confirmations.
Definition: transactionrecord.h:36
TransactionTableModel::formatTxType
QString formatTxType(const TransactionRecord *wtx) const
Definition: transactiontablemodel.cpp:372
TransactionNotification
Definition: transactiontablemodel.cpp:59
TransactionStatus::status
Status status
Definition: transactionrecord.h:56
TransactionTablePriv
Definition: transactiontablemodel.cpp:83
OptionsModel::getDisplayUnit
int getDisplayUnit() const
Definition: optionsmodel.h:86
TransactionStatus::matures_in
int matures_in
Definition: transactionrecord.h:51
TransactionTablePriv::getTxHex
QString getTxHex(interfaces::Wallet &wallet, TransactionRecord *rec)
Definition: transactiontablemodel.cpp:234
TransactionTableModel::~TransactionTableModel
~TransactionTableModel()
Definition: transactiontablemodel.cpp:260
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:211
TransactionTableModel::Type
@ Type
Definition: transactiontablemodel.h:38
TxLessThan::operator()
bool operator()(const uint256 &a, const TransactionRecord &b) const
Definition: transactiontablemodel.cpp:52
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:48
TransactionNotification::TransactionNotification
TransactionNotification()
Definition: transactiontablemodel.cpp:62
TransactionRecord::SendToAddress
@ SendToAddress
Definition: transactionrecord.h:79
TransactionTableModel::TxHashRole
@ TxHashRole
Transaction hash.
Definition: transactiontablemodel.h:64
node
Definition: interfaces.cpp:66
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:75
TransactionTableModel::DateRole
@ DateRole
Date and time this transaction was created.
Definition: transactiontablemodel.h:50
TransactionStatus::depth
qint64 depth
Definition: transactionrecord.h:57
CT_NEW
@ CT_NEW
Definition: ui_change_type.h:10
TransactionStatus::NotAccepted
@ NotAccepted
Mined but not accepted.
Definition: transactionrecord.h:41
optionsmodel.h
TransactionStatus::countsForBalance
bool countsForBalance
Transaction counts towards available balance.
Definition: transactionrecord.h:45
TransactionStatus::Unconfirmed
@ Unconfirmed
Not yet mined into a block.
Definition: transactionrecord.h:35
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:267
interfaces::WalletTx::tx
CTransactionRef tx
Definition: wallet.h:371
assert
assert(std::addressof(::ChainstateActive().CoinsTip())==std::addressof(coins_cache))
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:512
TransactionTablePriv::updateWallet
void updateWallet(interfaces::Wallet &wallet, const uint256 &hash, int status, bool showTransaction)
Definition: transactiontablemodel.cpp:125
TransactionTableModel::walletModel
WalletModel * walletModel
Definition: transactiontablemodel.h:87
COLOR_UNCONFIRMED
#define COLOR_UNCONFIRMED
Definition: guiconstants.h:25
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:164
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:101
TransactionRecord::showTransaction
static bool showTransaction()
Decompose CWallet transaction to model transaction records.
Definition: transactionrecord.cpp:18
TransactionTablePriv::ShowProgress
void ShowProgress(const std::string &title, int nProgress)
Definition: transactiontablemodel.cpp:730
TransactionTableModel::data
QVariant data(const QModelIndex &index, int role) const override
Definition: transactiontablemodel.cpp:523