17 #include "validation.h" 29 #include <boost/foreach.hpp> 33 Qt::AlignLeft|Qt::AlignVCenter,
34 Qt::AlignLeft|Qt::AlignVCenter,
35 Qt::AlignLeft|Qt::AlignVCenter,
36 Qt::AlignLeft|Qt::AlignVCenter,
37 Qt::AlignLeft|Qt::AlignVCenter,
38 Qt::AlignRight|Qt::AlignVCenter
81 qDebug() <<
"TransactionTablePriv::refreshWallet";
85 for(std::map<uint256, CWalletTx>::iterator it =
wallet->mapWallet.begin(); it !=
wallet->mapWallet.end(); ++it)
100 qDebug() <<
"TransactionTablePriv::updateWallet: " + QString::fromStdString(hash.
ToString()) +
" " + QString::number(status);
103 QList<TransactionRecord>::iterator lower = qLowerBound(
105 QList<TransactionRecord>::iterator upper = qUpperBound(
109 bool inModel = (lower != upper);
113 if(showTransaction && !inModel)
115 if(!showTransaction && inModel)
119 qDebug() <<
" inModel=" + QString::number(inModel) +
120 " Index=" + QString::number(lowerIndex) +
"-" + QString::number(upperIndex) +
121 " showTransaction=" + QString::number(showTransaction) +
" derivedStatus=" + QString::number(status);
128 qWarning() <<
"TransactionTablePriv::updateWallet: Warning: Got CT_NEW, but transaction is already in model";
135 std::map<uint256, CWalletTx>::iterator mi =
wallet->mapWallet.find(hash);
136 if(mi ==
wallet->mapWallet.end())
138 qWarning() <<
"TransactionTablePriv::updateWallet: Warning: Got CT_NEW, but transaction is not in wallet";
142 QList<TransactionRecord> toInsert =
144 if(!toInsert.isEmpty())
146 parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex+toInsert.size()-1);
147 int insert_idx = lowerIndex;
160 qWarning() <<
"TransactionTablePriv::updateWallet: Warning: Got CT_DELETED, but transaction is not in model";
164 parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1);
199 std::map<uint256, CWalletTx>::iterator mi =
wallet->mapWallet.find(rec->
hash);
201 if(mi !=
wallet->mapWallet.end())
216 std::map<uint256, CWalletTx>::iterator mi =
wallet->mapWallet.find(rec->
hash);
217 if(mi !=
wallet->mapWallet.end())
228 std::map<uint256, CWalletTx>::iterator mi =
wallet->mapWallet.find(rec->
hash);
229 if(mi !=
wallet->mapWallet.end())
231 std::string strHex =
EncodeHexTx(static_cast<CTransaction>(mi->second));
232 return QString::fromStdString(strHex);
239 QAbstractTableModel(parent),
243 fProcessingQueuedTransactions(false),
244 platformStyle(platformStyle)
270 updated.
SetHex(hash.toStdString());
310 status = tr(
"Offline");
313 status = tr(
"Unconfirmed");
316 status = tr(
"Abandoned");
322 status = tr(
"Confirmed (%1 confirmations)").arg(wtx->
status.
depth);
325 status = tr(
"Conflicted");
331 status = tr(
"This block was not received by any other nodes and will probably not be accepted!");
334 status = tr(
"Generated but not accepted");
361 if(label.isEmpty() || tooltip)
363 description += QString(
" (") + QString::fromStdString(address) + QString(
")");
373 return tr(
"Received with");
375 return tr(
"Received from");
377 return tr(
"Received via PrivateSend");
380 return tr(
"Sent to");
382 return tr(
"Payment to yourself");
387 return tr(
"PrivateSend Denominate");
389 return tr(
"PrivateSend Collateral Payment");
391 return tr(
"PrivateSend Make Collateral Inputs");
393 return tr(
"PrivateSend Create Denominations");
395 return tr(
"PrivateSend");
408 return QIcon(
":/icons/" + theme +
"/tx_mined");
412 return QIcon(
":/icons/" + theme +
"/tx_input");
415 return QIcon(
":/icons/" + theme +
"/tx_output");
417 return QIcon(
":/icons/" + theme +
"/tx_inout");
423 QString watchAddress;
426 watchAddress = wtx->
involvesWatchAddress ? QString(
" (") + tr(
"watch-only") + QString(
")") :
"";
432 return QString::fromStdString(wtx->
address) + watchAddress;
440 return QString::fromStdString(wtx->
address) + watchAddress;
443 return tr(
"(n/a)") + watchAddress;
481 str = QString(
"[") + str + QString(
"]");
498 return QIcon(
":/icons/" + theme +
"/transaction_0");
500 return QIcon(
":/icons/" + theme +
"/transaction_abandoned");
504 case 1:
return QIcon(
":/icons/" + theme +
"/transaction_1");
505 case 2:
return QIcon(
":/icons/" + theme +
"/transaction_2");
506 case 3:
return QIcon(
":/icons/" + theme +
"/transaction_3");
507 case 4:
return QIcon(
":/icons/" + theme +
"/transaction_4");
508 default:
return QIcon(
":/icons/" + theme +
"/transaction_5");
511 return QIcon(
":/icons/" + theme +
"/transaction_confirmed");
513 return QIcon(
":/icons/" + theme +
"/transaction_conflicted");
517 return QIcon(QString(
":/icons/" + theme +
"/transaction_%1").arg(part));
521 return QIcon(
":/icons/" + theme +
"/transaction_0");
531 return QIcon(
":/icons/" + theme +
"/eye");
556 switch(
index.column())
566 case Qt::DecorationRole:
570 case Qt::DisplayRole:
571 switch(
index.column())
585 switch(
index.column())
601 case Qt::ToolTipRole:
603 case Qt::TextAlignmentRole:
605 case Qt::ForegroundRole:
628 return QDateTime::fromTime_t(static_cast<uint>(rec->
time));
636 return QString::fromStdString(rec->
address);
655 details.append(
". ");
661 if(txLabel.isEmpty())
662 details.append(tr(
"(no label)") +
" ");
665 details.append(txLabel);
666 details.append(
") ");
668 details.append(QString::fromStdString(rec->
address));
687 if(orientation == Qt::Horizontal)
689 if(role == Qt::DisplayRole)
693 else if (role == Qt::TextAlignmentRole)
696 }
else if (role == Qt::ToolTipRole)
701 return tr(
"Transaction status. Hover over this field to show number of confirmations.");
703 return tr(
"Date and time that the transaction was received.");
705 return tr(
"Type of transaction.");
707 return tr(
"Whether or not a watch-only address is involved in this transaction.");
709 return tr(
"User-defined intent/purpose of the transaction.");
711 return tr(
"Amount removed from or added to balance.");
724 return createIndex(row, column,
priv->
index(row));
726 return QModelIndex();
746 QString strHash = QString::fromStdString(
hash.
GetHex());
747 qDebug() <<
"NotifyTransactionChanged: " + strHash +
" status= " + QString::number(
status);
748 QMetaObject::invokeMethod(ttm,
"updateTransaction", Qt::QueuedConnection,
749 Q_ARG(QString, strHash),
765 std::map<uint256, CWalletTx>::iterator mi =
wallet->mapWallet.find(hash);
767 bool inWallet = mi !=
wallet->mapWallet.end();
785 if (nProgress == 100)
789 QMetaObject::invokeMethod(ttm,
"setProcessingQueuedTransactions", Qt::QueuedConnection, Q_ARG(
bool,
true));
793 QMetaObject::invokeMethod(ttm,
"setProcessingQueuedTransactions", Qt::QueuedConnection, Q_ARG(
bool,
false));
void updateStatus(const CWalletTx &wtx)
TransactionTableModel(const PlatformStyle *platformStyle, CWallet *wallet, WalletModel *parent=0)
#define TRY_LOCK(cs, name)
Normal (sent/received) transactions.
QVariant data(const QModelIndex &index, int role) const
void updateWallet(const uint256 &hash, int status, bool showTransaction)
QVariant headerData(int section, Qt::Orientation orientation, int role) const
bool operator()(const TransactionRecord &a, const TransactionRecord &b) const
void updateConfirmations()
static int column_alignments[]
static void NotifyTransactionChanged(TransactionTableModel *ttm, CWallet *wallet, const uint256 &hash, ChangeType status)
QString formatTxAmount(const TransactionRecord *wtx, bool showUnconfirmed=true, BitcoinUnits::SeparatorStyle separators=BitcoinUnits::separatorStandard) const
static QString getAmountColumnTitle(int unit)
Gets title for amount column including current display unit if optionsModel reference available */...
static bool showTransaction(const CWalletTx &wtx)
QVariant txAddressDecoration(const TransactionRecord *wtx) const
std::string sortKey
Sorting key based on status.
bool statusUpdateNeeded()
#define COLOR_TX_STATUS_OFFLINE
bool operator()(const TransactionRecord &a, const uint256 &b) const
TransactionNotification()
void updateTransaction(const QString &hash, int status, bool showTransaction)
bool involvesWatchAddress
QString formatTxStatus(const TransactionRecord *wtx) const
QVariant txWatchonlyDecoration(const TransactionRecord *wtx) const
static QString toHTML(CWallet *wallet, CWalletTx &wtx, TransactionRecord *rec, int unit)
QString labelForAddress(const QString &address) const
static void ShowProgress(TransactionTableModel *ttm, const std::string &title, int nProgress)
QVariant txStatusDecoration(const TransactionRecord *wtx) const
#define COLOR_TX_STATUS_DANGER
int columnCount(const QModelIndex &parent) const
void unsubscribeFromCoreSignals()
static QList< TransactionRecord > decomposeTransaction(const CWallet *wallet, const CWalletTx &wtx)
static const int RecommendedNumConfirmations
static QString format(int unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=separatorStandard)
Format as string.
void updateAmountColumnTitle()
OptionsModel * getOptionsModel()
std::string ToString() const
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
#define COLOR_UNCONFIRMED
QString lookupAddress(const std::string &address, bool tooltip) const
QString formatTxType(const TransactionRecord *wtx) const
QString getTxHex(TransactionRecord *rec)
QString formatTooltip(const TransactionRecord *rec) const
std::string EncodeHexTx(const CTransaction &tx)
TransactionTableModel * parent
TransactionNotification(uint256 hash, ChangeType status, bool showTransaction)
static std::vector< TransactionNotification > vQueueNotifications
Generated (mined) transactions.
TransactionTablePriv(CWallet *wallet, TransactionTableModel *parent)
TransactionRecord * index(int idx)
std::string GetHex() const
QString describe(TransactionRecord *rec, int unit)
WalletModel * walletModel
bool operator()(const uint256 &a, const TransactionRecord &b) const
bool countsForBalance
Transaction counts towards available balance.
static bool fQueueNotifications
int rowCount(const QModelIndex &parent) const
void invoke(QObject *ttm)
#define COLOR_TX_STATUS_OPENUNTILDATE
TransactionTablePriv * priv
void SetHex(const char *psz)
AddressTableModel * getAddressTableModel()
#define COLOR_BAREADDRESS
void subscribeToCoreSignals()
QString formatTxToAddress(const TransactionRecord *wtx, bool tooltip) const
QVariant addressColor(const TransactionRecord *wtx) const
QString formatTxDate(const TransactionRecord *wtx) const
QList< TransactionRecord > cachedWallet
QString dateTimeStr(const QDateTime &date)