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