17 #include <validation.h> 30 static int column_alignments[] = {
31 Qt::AlignLeft|Qt::AlignVCenter,
32 Qt::AlignLeft|Qt::AlignVCenter,
33 Qt::AlignLeft|Qt::AlignVCenter,
34 Qt::AlignLeft|Qt::AlignVCenter,
35 Qt::AlignLeft|Qt::AlignVCenter,
36 Qt::AlignRight|Qt::AlignVCenter
79 qDebug() <<
"TransactionTablePriv::refreshWallet";
83 for(std::map<uint256, CWalletTx>::iterator it = wallet->
mapWallet.begin(); it != wallet->
mapWallet.end(); ++it)
98 qDebug() <<
"TransactionTablePriv::updateWallet: " + QString::fromStdString(hash.
ToString()) +
" " + QString::number(status);
101 QList<TransactionRecord>::iterator lower = qLowerBound(
102 cachedWallet.begin(), cachedWallet.end(), hash,
TxLessThan());
103 QList<TransactionRecord>::iterator upper = qUpperBound(
104 cachedWallet.begin(), cachedWallet.end(), hash,
TxLessThan());
105 int lowerIndex = (lower - cachedWallet.begin());
106 int upperIndex = (upper - cachedWallet.begin());
107 bool inModel = (lower != upper);
111 if(showTransaction && !inModel)
113 if(!showTransaction && inModel)
117 qDebug() <<
" inModel=" + QString::number(inModel) +
118 " Index=" + QString::number(lowerIndex) +
"-" + QString::number(upperIndex) +
119 " showTransaction=" + QString::number(showTransaction) +
" derivedStatus=" + QString::number(status);
126 qWarning() <<
"TransactionTablePriv::updateWallet: Warning: Got CT_NEW, but transaction is already in model";
133 std::map<uint256, CWalletTx>::iterator mi = wallet->
mapWallet.find(hash);
136 qWarning() <<
"TransactionTablePriv::updateWallet: Warning: Got CT_NEW, but transaction is not in wallet";
140 QList<TransactionRecord> toInsert =
142 if(!toInsert.isEmpty())
144 parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex+toInsert.size()-1);
145 int insert_idx = lowerIndex;
148 cachedWallet.insert(insert_idx, rec);
151 parent->endInsertRows();
158 qWarning() <<
"TransactionTablePriv::updateWallet: Warning: Got CT_DELETED, but transaction is not in model";
162 parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1);
163 cachedWallet.erase(lower, upper);
164 parent->endRemoveRows();
169 for (
int i = lowerIndex; i < upperIndex; i++) {
179 return cachedWallet.size();
184 if(idx >= 0 && idx < cachedWallet.size())
201 std::map<uint256, CWalletTx>::iterator mi = wallet->
mapWallet.find(rec->
hash);
218 std::map<uint256, CWalletTx>::iterator mi = wallet->
mapWallet.find(rec->
hash);
230 std::map<uint256, CWalletTx>::iterator mi = wallet->
mapWallet.find(rec->
hash);
233 std::string strHex =
EncodeHexTx(static_cast<CTransaction>(mi->second));
234 return QString::fromStdString(strHex);
241 QAbstractTableModel(parent),
245 fProcessingQueuedTransactions(false),
246 platformStyle(_platformStyle)
272 updated.
SetHex(hash.toStdString());
312 status = tr(
"Offline");
315 status = tr(
"Unconfirmed");
318 status = tr(
"Abandoned");
324 status = tr(
"Confirmed (%1 confirmations)").arg(wtx->
status.
depth);
327 status = tr(
"Conflicted");
333 status = tr(
"This block was not received by any other nodes and will probably not be accepted!");
336 status = tr(
"Generated but not accepted");
361 description += label;
363 if(label.isEmpty() || tooltip)
365 description += QString(
" (") + QString::fromStdString(address) + QString(
")");
375 return tr(
"Received with");
377 return tr(
"Received from");
380 return tr(
"Sent to");
382 return tr(
"Payment to yourself");
386 return tr(
"Contract receive");
388 return tr(
"Contract send");
417 QString watchAddress;
420 watchAddress = wtx->
involvesWatchAddress ? QString(
" (") + tr(
"watch-only") + QString(
")") :
"";
426 return QString::fromStdString(wtx->
address) + watchAddress;
434 return QString::fromStdString(wtx->
address) + watchAddress;
437 return tr(
"(n/a)") + watchAddress;
471 str = QString(
"[") + str + QString(
"]");
540 switch(index.column())
550 case Qt::DecorationRole:
554 case Qt::DisplayRole:
555 switch(index.column())
569 switch(index.column())
585 case Qt::ToolTipRole:
587 case Qt::TextAlignmentRole:
588 return column_alignments[index.column()];
589 case Qt::ForegroundRole:
612 return QDateTime::fromTime_t(static_cast<uint>(rec->
time));
620 return QString::fromStdString(rec->
address);
634 QDateTime date = QDateTime::fromTime_t(static_cast<uint>(rec->
time));
637 details.append(date.toString(
"M/d/yy HH:mm"));
640 details.append(
". ");
646 if(txLabel.isEmpty())
647 details.append(tr(
"(no label)") +
" ");
650 details.append(txLabel);
651 details.append(
") ");
653 details.append(QString::fromStdString(rec->
address));
672 if(orientation == Qt::Horizontal)
674 if(role == Qt::DisplayRole)
678 else if (role == Qt::TextAlignmentRole)
680 return column_alignments[section];
681 }
else if (role == Qt::ToolTipRole)
686 return tr(
"Transaction status. Hover over this field to show number of confirmations.");
688 return tr(
"Date and time that the transaction was received.");
690 return tr(
"Type of transaction.");
692 return tr(
"Whether or not a watch-only address is involved in this transaction.");
694 return tr(
"User-defined intent/purpose of the transaction.");
696 return tr(
"Amount removed from or added to balance.");
709 return createIndex(row, column,
priv->
index(row));
711 return QModelIndex();
727 hash(_hash), status(_status), showTransaction(_showTransaction) {}
731 QString strHash = QString::fromStdString(hash.GetHex());
732 qDebug() <<
"NotifyTransactionChanged: " + strHash +
" status= " + QString::number(status);
733 QMetaObject::invokeMethod(ttm,
"updateTransaction", Qt::QueuedConnection,
734 Q_ARG(QString, strHash),
736 Q_ARG(
bool, showTransaction));
744 static bool fQueueNotifications =
false;
745 static std::vector< TransactionNotification > vQueueNotifications;
750 std::map<uint256, CWalletTx>::iterator mi = wallet->
mapWallet.find(hash);
752 bool inWallet = mi != wallet->
mapWallet.end();
757 if (fQueueNotifications)
759 vQueueNotifications.push_back(notification);
768 fQueueNotifications =
true;
770 if (nProgress == 100)
772 fQueueNotifications =
false;
773 if (vQueueNotifications.size() > 10)
774 QMetaObject::invokeMethod(ttm,
"setProcessingQueuedTransactions", Qt::QueuedConnection, Q_ARG(
bool,
true));
775 for (
unsigned int i = 0; i < vQueueNotifications.size(); ++i)
777 if (vQueueNotifications.size() - i <= 10)
778 QMetaObject::invokeMethod(ttm,
"setProcessingQueuedTransactions", Qt::QueuedConnection, Q_ARG(
bool,
false));
780 vQueueNotifications[i].invoke(ttm);
782 std::vector<TransactionNotification >().
swap(vQueueNotifications);
QVariant addressColor(const TransactionRecord *wtx) const
void updateAmountColumnTitle()
Updates the column title to "Amount (DisplayUnit)" and emits headerDataChanged() signal for table hea...
int columnCount(const QModelIndex &parent) const
QVariant data(const QModelIndex &index, int role) const
QVariant txStatusDecoration(const TransactionRecord *wtx) const
QString describe(TransactionRecord *rec, int unit)
Confirmed, but waiting for the recommended number of confirmations.
bool operator()(const uint256 &a, const TransactionRecord &b) const
Transaction not yet final, waiting for block.
Transaction status (TransactionRecord::Status)
#define TRY_LOCK(cs, name)
QString formatTxAmount(const TransactionRecord *wtx, bool showUnconfirmed=true, FabcoinUnits::SeparatorStyle separators=FabcoinUnits::separatorStandard) const
void swap(dev::eth::Watch &_a, dev::eth::Watch &_b)
QString getTxID() const
Return the unique identifier for this transaction (part)
Not sent to any other nodes.
CCriticalSection cs_wallet
Generated (mined) transactions.
QString formatTxToAddress(const TransactionRecord *wtx, bool tooltip) const
WalletModel * walletModel
Have 6 or more confirmations (normal tx) or fully mature (mined tx)
std::string sortKey
Sorting key based on status.
void updateTransaction(const QString &hash, int status, bool showTransaction)
QString dateTimeStr(const QDateTime &date)
QVariant txAddressDecoration(const TransactionRecord *wtx) const
void unsubscribeFromCoreSignals()
TransactionRecord * index(int idx)
Not yet mined into a block.
QString lookupAddress(const std::string &address, bool tooltip) const
#define COLOR_TX_STATUS_OFFLINE
static bool showTransaction(const CWalletTx &wtx)
Decompose CWallet transaction to model transaction records.
AddressTableModel * getAddressTableModel()
Transaction data, hex-encoded.
TransactionTableModel * parent
QVariant headerData(int section, Qt::Orientation orientation, int role) const
TransactionTableModel(const PlatformStyle *platformStyle, CWallet *wallet, WalletModel *parent=0)
void updateWallet(const uint256 &hash, int status, bool showTransaction)
Long description (HTML format)
TransactionTablePriv * priv
QString formatTxStatus(const TransactionRecord *wtx) const
std::string ToString() const
QList< TransactionRecord > cachedWallet
boost::signals2::signal< void(CWallet *wallet, const uint256 &hashTx, ChangeType status)> NotifyTransactionChanged
Wallet transaction added, removed or updated.
UI model for a transaction.
TransactionStatus status
Status: can change with block chain update.
TransactionTablePriv(CWallet *_wallet, TransactionTableModel *_parent)
TransactionNotification()
Whole transaction as plain text.
static QList< TransactionRecord > decomposeTransaction(const CWallet *wallet, const CWalletTx &wtx)
ChangeType
General change type (added, updated, removed).
static QString format(int unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=separatorStandard)
Format as string.
bool operator()(const TransactionRecord &a, const uint256 &b) const
#define COLOR_TX_STATUS_DANGER
Is transaction confirmed?
TransactionNotification(uint256 _hash, ChangeType _status, bool _showTransaction)
bool countsForBalance
Transaction counts towards available balance.
void updateStatus(const CWalletTx &wtx)
Update status from core wallet tx.
QString getTxHex(TransactionRecord *rec)
Date and time this transaction was created.
UI model for the transaction table of a wallet.
#define COLOR_UNCONFIRMED
Normal (sent/received) transactions.
QString formatTxType(const TransactionRecord *wtx) const
QString formatTooltip(const TransactionRecord *rec) const
void subscribeToCoreSignals()
QVariant txWatchonlyDecoration(const TransactionRecord *wtx) const
Net amount of transaction.
static QString getAmountColumnTitle(int unit)
Gets title for amount column including current display unit if optionsModel reference available */...
bool operator()(const TransactionRecord &a, const TransactionRecord &b) const
QString labelForAddress(const QString &address) const
Conflicts with other transaction or mempool.
Interface to Fabcoin wallet from Qt view code.
int rowCount(const QModelIndex &parent) const
bool involvesWatchAddress
Whether the transaction was sent/received with a watch-only address.
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances...
std::string EncodeHexTx(const CTransaction &tx, const int serializeFlags=0)
Label of address related to transaction.
bool statusUpdateNeeded()
Return whether a status update is needed.
std::map< uint256, CWalletTx > mapWallet
boost::signals2::signal< void(const std::string &title, int nProgress)> ShowProgress
Show progress e.g.
struct evm_uint160be address(struct evm_env *env)
void invoke(QObject *ttm)
#define COLOR_TX_STATUS_OPENUNTILDATE
qint64 open_for
Timestamp if status==OpenUntilDate, otherwise number of additional blocks that need to be mined befor...
Formatted amount, without brackets when unconfirmed.
void updateConfirmations()
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
void SetHex(const char *psz)
static QString toHTML(CWallet *wallet, CWalletTx &wtx, TransactionRecord *rec, int unit)
Abandoned from the wallet.
#define COLOR_BAREADDRESS
const PlatformStyle * platformStyle
QString formatTxDate(const TransactionRecord *wtx) const
static const int RecommendedNumConfirmations
Number of confirmation recommended for accepting a transaction.
Transaction will likely not mature because no nodes have confirmed.
OptionsModel * getOptionsModel()