@@ -33,6 +33,10 @@ static const bool DEFAULT_SPLASHSCREEN = true;
|
||||
#define COLOR_TX_STATUS_DANGER QColor(200, 100, 100)
|
||||
/* Transaction list -- TX status decoration - default color */
|
||||
#define COLOR_BLACK QColor(0, 0, 0)
|
||||
/* Transaction list -- has conflicting transactions */
|
||||
#define COLOR_HASCONFLICTING QColor(255, 255, 255)
|
||||
/* Transaction list -- has conflicting transactions - background */
|
||||
#define COLOR_HASCONFLICTING_BG QColor(192, 0, 0)
|
||||
|
||||
/* Tooltips longer than this (in characters) are converted into rich text,
|
||||
so that they can be word-wrapped.
|
||||
|
||||
@@ -25,7 +25,7 @@ TransactionFilterProxy::TransactionFilterProxy(QObject *parent) :
|
||||
watchOnlyFilter(WatchOnlyFilter_All),
|
||||
minAmount(0),
|
||||
limitRows(-1),
|
||||
showInactive(true)
|
||||
showInactive(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ bool TransactionFilterProxy::filterAcceptsRow(int sourceRow, const QModelIndex &
|
||||
qint64 amount = llabs(index.data(TransactionTableModel::AmountRole).toLongLong());
|
||||
int status = index.data(TransactionTableModel::StatusRole).toInt();
|
||||
|
||||
if(!showInactive && status == TransactionStatus::Conflicted)
|
||||
if(!showInactive && status == TransactionStatus::Conflicted && type == TransactionRecord::Other)
|
||||
return false;
|
||||
if(!(TYPE(type) & typeFilter))
|
||||
return false;
|
||||
|
||||
@@ -195,6 +195,8 @@ void TransactionRecord::updateStatus(const CWalletTx &wtx)
|
||||
status.depth = wtx.GetDepthInMainChain();
|
||||
status.cur_num_blocks = chainActive.Height();
|
||||
|
||||
status.hasConflicting = false;
|
||||
|
||||
if (!CheckFinalTx(wtx))
|
||||
{
|
||||
if (wtx.nLockTime < LOCKTIME_THRESHOLD)
|
||||
@@ -238,6 +240,7 @@ void TransactionRecord::updateStatus(const CWalletTx &wtx)
|
||||
if (status.depth < 0)
|
||||
{
|
||||
status.status = TransactionStatus::Conflicted;
|
||||
status.hasConflicting = !(wtx.GetConflicts().empty());
|
||||
}
|
||||
else if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0)
|
||||
{
|
||||
@@ -246,6 +249,7 @@ void TransactionRecord::updateStatus(const CWalletTx &wtx)
|
||||
else if (status.depth == 0)
|
||||
{
|
||||
status.status = TransactionStatus::Unconfirmed;
|
||||
status.hasConflicting = !(wtx.GetConflicts().empty());
|
||||
if (wtx.isAbandoned())
|
||||
status.status = TransactionStatus::Abandoned;
|
||||
}
|
||||
@@ -261,10 +265,10 @@ void TransactionRecord::updateStatus(const CWalletTx &wtx)
|
||||
|
||||
}
|
||||
|
||||
bool TransactionRecord::statusUpdateNeeded()
|
||||
bool TransactionRecord::statusUpdateNeeded(int64_t nConflictsReceived)
|
||||
{
|
||||
AssertLockHeld(cs_main);
|
||||
return status.cur_num_blocks != chainActive.Height();
|
||||
return (status.cur_num_blocks != chainActive.Height() || status.cur_num_conflicts != nConflictsReceived);
|
||||
}
|
||||
|
||||
QString TransactionRecord::getTxID() const
|
||||
|
||||
@@ -20,9 +20,17 @@ class TransactionStatus
|
||||
{
|
||||
public:
|
||||
TransactionStatus():
|
||||
countsForBalance(false), sortKey(""),
|
||||
matures_in(0), status(Offline), depth(0), open_for(0), cur_num_blocks(-1)
|
||||
{ }
|
||||
countsForBalance(false),
|
||||
sortKey(""),
|
||||
matures_in(0),
|
||||
status(Offline),
|
||||
hasConflicting(false),
|
||||
depth(0),
|
||||
open_for(0),
|
||||
cur_num_blocks(-1),
|
||||
cur_num_conflicts(-1)
|
||||
{
|
||||
}
|
||||
|
||||
enum Status {
|
||||
Confirmed, /**< Have 6 or more confirmations (normal tx) or fully mature (mined tx) **/
|
||||
@@ -53,6 +61,10 @@ public:
|
||||
/** @name Reported status
|
||||
@{*/
|
||||
Status status;
|
||||
|
||||
// Has conflicting transactions spending same prevout
|
||||
bool hasConflicting;
|
||||
|
||||
qint64 depth;
|
||||
qint64 open_for; /**< Timestamp if status==OpenUntilDate, otherwise number
|
||||
of additional blocks that need to be mined before
|
||||
@@ -61,6 +73,9 @@ public:
|
||||
|
||||
/** Current number of blocks (to know whether cached status is still valid) */
|
||||
int cur_num_blocks;
|
||||
|
||||
/** Number of conflicts received into wallet as of last status update */
|
||||
int64_t cur_num_conflicts;
|
||||
};
|
||||
|
||||
/** UI model for a transaction. A core transaction can be represented by multiple UI transactions if it has
|
||||
@@ -138,7 +153,7 @@ public:
|
||||
|
||||
/** Return whether a status update is needed.
|
||||
*/
|
||||
bool statusUpdateNeeded();
|
||||
bool statusUpdateNeeded(int64_t nConflictsReceived);
|
||||
};
|
||||
|
||||
#endif // BITCOIN_QT_TRANSACTIONRECORD_H
|
||||
|
||||
@@ -166,8 +166,12 @@ public:
|
||||
parent->endRemoveRows();
|
||||
break;
|
||||
case CT_UPDATED:
|
||||
// Miscellaneous updates -- nothing to do, status update will take care of this, and is only computed for
|
||||
// visible transactions.
|
||||
Q_EMIT parent->dataChanged(parent->index(lowerIndex, parent->Status), parent->index(upperIndex-1, parent->Amount));
|
||||
break;
|
||||
case CT_GOT_CONFLICT:
|
||||
Q_EMIT parent->message(parent->tr("Conflict Received"),
|
||||
parent->tr("WARNING: Transaction may never be confirmed. Its input was seen being spent by another transaction on the network."),
|
||||
CClientUIInterface::MSG_WARNING);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -187,20 +191,21 @@ public:
|
||||
// stuck if the core is holding the locks for a longer time - for
|
||||
// example, during a wallet rescan.
|
||||
//
|
||||
// If a status update is needed (blocks came in since last check),
|
||||
// update the status of this transaction from the wallet. Otherwise,
|
||||
// If a status update is needed (blocks or conflicts came in since last check),
|
||||
// update the status of this transaction from the wallet. Otherwise,
|
||||
// simply re-use the cached status.
|
||||
TRY_LOCK(cs_main, lockMain);
|
||||
if(lockMain)
|
||||
{
|
||||
TRY_LOCK(wallet->cs_wallet, lockWallet);
|
||||
if(lockWallet && rec->statusUpdateNeeded())
|
||||
if(lockWallet && rec->statusUpdateNeeded(wallet->nConflictsReceived))
|
||||
{
|
||||
std::map<uint256, CWalletTx>::iterator mi = wallet->mapWallet.find(rec->hash);
|
||||
|
||||
if(mi != wallet->mapWallet.end())
|
||||
{
|
||||
rec->updateStatus(mi->second);
|
||||
rec->status.cur_num_conflicts = wallet->nConflictsReceived;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -247,6 +252,7 @@ TransactionTableModel::TransactionTableModel(const PlatformStyle *platformStyle,
|
||||
priv->refreshWallet();
|
||||
|
||||
connect(walletModel->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
|
||||
connect(this, SIGNAL(message(QString,QString,unsigned int)), walletModel, SIGNAL(message(QString,QString,unsigned int)));
|
||||
|
||||
subscribeToCoreSignals();
|
||||
}
|
||||
@@ -380,6 +386,8 @@ QString TransactionTableModel::formatTxType(const TransactionRecord *wtx) const
|
||||
return tr("Payment to yourself");
|
||||
case TransactionRecord::Generated:
|
||||
return tr("Mined");
|
||||
case TransactionRecord::Other:
|
||||
return tr("Other");
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
@@ -577,7 +585,13 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
|
||||
return formatTooltip(rec);
|
||||
case Qt::TextAlignmentRole:
|
||||
return column_alignments[index.column()];
|
||||
case Qt::BackgroundColorRole:
|
||||
if (rec->status.hasConflicting)
|
||||
return COLOR_HASCONFLICTING_BG;
|
||||
break;
|
||||
case Qt::ForegroundRole:
|
||||
if (rec->status.hasConflicting)
|
||||
return COLOR_HASCONFLICTING;
|
||||
// Use the "danger" color for abandoned transactions
|
||||
if(rec->status.status == TransactionStatus::Abandoned)
|
||||
{
|
||||
|
||||
@@ -104,6 +104,10 @@ private:
|
||||
QVariant txWatchonlyDecoration(const TransactionRecord *wtx) const;
|
||||
QVariant txAddressDecoration(const TransactionRecord *wtx) const;
|
||||
|
||||
Q_SIGNALS:
|
||||
// Fired when a message should be reported to the user
|
||||
void message(const QString &title, const QString &message, unsigned int style);
|
||||
|
||||
public Q_SLOTS:
|
||||
/* New transaction, or transaction changed status */
|
||||
void updateTransaction(const QString &hash, int status, bool showTransaction);
|
||||
|
||||
@@ -22,7 +22,8 @@ enum ChangeType
|
||||
{
|
||||
CT_NEW,
|
||||
CT_UPDATED,
|
||||
CT_DELETED
|
||||
CT_DELETED,
|
||||
CT_GOT_CONFLICT
|
||||
};
|
||||
|
||||
/** Signals for UI communication. */
|
||||
|
||||
@@ -1196,6 +1196,20 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet, CWalletD
|
||||
// Notify UI of new or updated transaction
|
||||
NotifyTransactionChanged(this, hash, fInsertedNew ? CT_NEW : CT_UPDATED);
|
||||
|
||||
// Notifications for existing transactions that now have conflicts with this one
|
||||
if (fInsertedNew)
|
||||
{
|
||||
BOOST_FOREACH(const uint256& conflictHash, wtxIn.GetConflicts())
|
||||
{
|
||||
CWalletTx& txConflict = mapWallet[conflictHash];
|
||||
NotifyTransactionChanged(this, conflictHash, CT_UPDATED); //Updates UI table
|
||||
if (IsFromMe(txConflict) || IsMine(txConflict))
|
||||
{
|
||||
NotifyTransactionChanged(this, conflictHash, CT_GOT_CONFLICT); //Throws dialog
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// notify an external script when a wallet transaction comes in or is updated
|
||||
std::string strCmd = GetArg("-walletnotify", "");
|
||||
|
||||
|
||||
@@ -535,6 +535,9 @@ public:
|
||||
MasterKeyMap mapMasterKeys;
|
||||
unsigned int nMasterKeyMaxID;
|
||||
|
||||
// Increment to cause UI refresh, similar to new block
|
||||
int64_t nConflictsReceived;
|
||||
|
||||
CWallet()
|
||||
{
|
||||
SetNull();
|
||||
@@ -566,6 +569,7 @@ public:
|
||||
nLastResend = 0;
|
||||
nTimeFirstKey = 0;
|
||||
fBroadcastTransactions = false;
|
||||
nConflictsReceived = 0;
|
||||
}
|
||||
|
||||
std::map<uint256, CWalletTx> mapWallet;
|
||||
|
||||
Reference in New Issue
Block a user