29 #include <QLatin1Char> 30 #include <QLatin1String> 36 Qt::AlignLeft|Qt::AlignVCenter,
37 Qt::AlignLeft|Qt::AlignVCenter,
38 Qt::AlignLeft|Qt::AlignVCenter,
39 Qt::AlignLeft|Qt::AlignVCenter,
40 Qt::AlignLeft|Qt::AlignVCenter,
41 Qt::AlignRight|Qt::AlignVCenter
71 QString strHash = QString::fromStdString(
hash.
GetHex());
72 qDebug() <<
"NotifyTransactionChanged: " + strHash +
" status= " + QString::number(
status);
73 bool invoked = QMetaObject::invokeMethod(ttm,
"updateTransaction", Qt::QueuedConnection,
74 Q_ARG(QString, strHash),
117 for (
const auto& wtx :
wallet.getWalletTxs()) {
134 qDebug() <<
"TransactionTablePriv::updateWallet: " + QString::fromStdString(hash.
ToString()) +
" " + QString::number(status);
137 QList<TransactionRecord>::iterator lower = std::lower_bound(
139 QList<TransactionRecord>::iterator upper = std::upper_bound(
143 bool inModel = (lower != upper);
147 if(showTransaction && !inModel)
149 if(!showTransaction && inModel)
153 qDebug() <<
" inModel=" + QString::number(inModel) +
154 " Index=" + QString::number(lowerIndex) +
"-" + QString::number(upperIndex) +
155 " showTransaction=" + QString::number(showTransaction) +
" derivedStatus=" + QString::number(status);
162 qWarning() <<
"TransactionTablePriv::updateWallet: Warning: Got CT_NEW, but transaction is already in model";
171 qWarning() <<
"TransactionTablePriv::updateWallet: Warning: Got CT_NEW, but transaction is not in wallet";
175 QList<TransactionRecord> toInsert =
177 if(!toInsert.isEmpty())
179 parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex+toInsert.size()-1);
180 int insert_idx = lowerIndex;
193 qWarning() <<
"TransactionTablePriv::updateWallet: Warning: Got CT_DELETED, but transaction is not in model";
197 parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1);
204 for (
int i = lowerIndex; i < upperIndex; i++) {
229 rec->
updateStatus(wtx, cur_block_hash, numBlocks, block_time);
246 return QString::fromStdString(strHex);
253 QAbstractTableModel(parent),
256 fProcessingQueuedTransactions(false),
257 platformStyle(_platformStyle)
283 updated.
SetHex(hash.toStdString());
300 if (parent.isValid()) {
308 if (parent.isValid()) {
321 status = tr(
"Unconfirmed");
324 status = tr(
"Abandoned");
330 status = tr(
"Confirmed (%1 confirmations)").arg(wtx->
status.
depth);
333 status = tr(
"Conflicted");
339 status = tr(
"Generated but not accepted");
364 description += label;
366 if(label.isEmpty() || tooltip)
368 description += QString(
" (") + QString::fromStdString(address) + QString(
")");
378 return tr(
"Received with");
380 return tr(
"Received from");
383 return tr(
"Sent to");
385 return tr(
"Payment to yourself");
398 return QIcon(
":/icons/tx_mined");
401 return QIcon(
":/icons/tx_input");
404 return QIcon(
":/icons/tx_output");
406 return QIcon(
":/icons/tx_inout");
412 QString watchAddress;
415 watchAddress = QLatin1String(
" (") + tr(
"watch-only") + QLatin1Char(
')');
421 return QString::fromStdString(wtx->
address) + watchAddress;
427 return QString::fromStdString(wtx->
address) + watchAddress;
431 return tr(
"(n/a)") + watchAddress;
463 str = QString(
"[") + str + QString(
"]");
474 return QIcon(
":/icons/transaction_0");
476 return QIcon(
":/icons/transaction_abandoned");
480 case 1:
return QIcon(
":/icons/transaction_1");
481 case 2:
return QIcon(
":/icons/transaction_2");
482 case 3:
return QIcon(
":/icons/transaction_3");
483 case 4:
return QIcon(
":/icons/transaction_4");
484 default:
return QIcon(
":/icons/transaction_5");
487 return QIcon(
":/icons/transaction_confirmed");
489 return QIcon(
":/icons/transaction_conflicted");
493 return QIcon(QString(
":/icons/transaction_%1").arg(part));
496 return QIcon(
":/icons/transaction_0");
505 return QIcon(
":/icons/eye");
535 case Date:
return {};
536 case Type:
return {};
542 case Qt::DecorationRole:
547 case Qt::DisplayRole:
578 case Qt::ToolTipRole:
580 case Qt::TextAlignmentRole:
582 case Qt::ForegroundRole:
605 return QDateTime::fromSecsSinceEpoch(rec->
time);
613 return QString::fromStdString(rec->
address);
625 QDateTime date = QDateTime::fromSecsSinceEpoch(rec->
time);
628 details.append(date.toString(
"M/d/yy HH:mm"));
631 details.append(
". ");
637 if(txLabel.isEmpty())
638 details.append(tr(
"(no label)") +
" ");
641 details.append(txLabel);
642 details.append(
") ");
644 details.append(QString::fromStdString(rec->
address));
651 return rec->
status.
status == TransactionStatus::Status::Confirming || rec->
status.
status == TransactionStatus::Status::Confirmed;
663 if(orientation == Qt::Horizontal)
665 if(role == Qt::DisplayRole)
669 else if (role == Qt::TextAlignmentRole)
672 }
else if (role == Qt::ToolTipRole)
677 return tr(
"Transaction status. Hover over this field to show number of confirmations.");
679 return tr(
"Date and time that the transaction was received.");
681 return tr(
"Type of transaction.");
683 return tr(
"Whether or not a watch-only address is involved in this transaction.");
685 return tr(
"User-defined intent/purpose of the transaction.");
687 return tr(
"Amount removed from or added to balance.");
700 return createIndex(row, column,
data);
702 return QModelIndex();
733 bool invoked = QMetaObject::invokeMethod(
parent,
"setProcessingQueuedTransactions", Qt::QueuedConnection, Q_ARG(
bool,
true));
739 bool invoked = QMetaObject::invokeMethod(
parent,
"setProcessingQueuedTransactions", Qt::QueuedConnection, Q_ARG(
bool,
false));
void updateWallet(interfaces::Wallet &wallet, const uint256 &hash, int status, bool showTransaction)
bool statusUpdateNeeded(const uint256 &block_hash) const
Return whether a status update is needed.
void updateAmountColumnTitle()
Updates the column title to "Amount (DisplayUnit)" and emits headerDataChanged() signal for table hea...
TransactionRecord * index(interfaces::Wallet &wallet, const uint256 &cur_block_hash, const int idx)
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
OptionsModel * getOptionsModel() const
interfaces::Wallet & wallet() const
QVariant txWatchonlyDecoration(const TransactionRecord *wtx) const
Transaction status (TransactionRecord::Status)
Generated (mined) transactions.
TransactionNotification()=default
QString getTxHash() const
Return the unique identifier for this transaction (part)
static int column_alignments[]
QString formatTooltip(const TransactionRecord *rec) const
WalletModel * walletModel
void updateTransaction(const QString &hash, int status, bool showTransaction)
QString dateTimeStr(const QDateTime &date)
TransactionTablePriv(TransactionTableModel *_parent)
static QList< TransactionRecord > decomposeTransaction(const interfaces::WalletTx &wtx)
void unsubscribeFromCoreSignals()
QVariant txStatusDecoration(const TransactionRecord *wtx) const
void NotifyTransactionChanged(const uint256 &hash, ChangeType status)
bool operator()(const TransactionRecord &a, const TransactionRecord &b) const
BitcoinUnit getDisplayUnit() const
void DispatchNotifications()
int columnCount(const QModelIndex &parent) const override
Transaction data, hex-encoded.
TransactionTableModel * parent
QString describe(interfaces::Node &node, interfaces::Wallet &wallet, TransactionRecord *rec, BitcoinUnit unit)
int rowCount(const QModelIndex &parent) const override
Long description (HTML format)
TransactionTablePriv * priv
void updateStatus(const interfaces::WalletTxStatus &wtx, const uint256 &block_hash, int numBlocks, int64_t block_time)
Update status from core wallet tx.
bool operator()(const uint256 &a, const TransactionRecord &b) const
QList< TransactionRecord > cachedWallet
std::string sortKey
Sorting key based on status.
bool operator()(const TransactionRecord &a, const uint256 &b) const
uint256 getLastBlockProcessed() const
void displayUnitChanged(BitcoinUnit unit)
virtual std::unique_ptr< Handler > handleTransactionChanged(TransactionChangedFn fn)=0
UI model for a transaction.
TransactionStatus status
Status: can change with block chain update.
QString formatTxType(const TransactionRecord *wtx) const
virtual std::unique_ptr< Handler > handleShowProgress(ShowProgressFn fn)=0
Whole transaction as plain text.
std::unique_ptr< interfaces::Handler > m_handler_transaction_changed
static QString format(Unit unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=SeparatorStyle::STANDARD, bool justify=false)
Format as string.
std::vector< TransactionNotification > vQueueNotifications
#define COLOR_TX_STATUS_DANGER
QString labelForAddress(const QString &address) const
Look up label for address in address book, if not found return empty string.
Interface for accessing a wallet.
Is transaction confirmed?
TransactionNotification(uint256 _hash, ChangeType _status, bool _showTransaction)
Have 6 or more confirmations (normal tx) or fully mature (mined tx)
TransactionTableModel(const PlatformStyle *platformStyle, WalletModel *parent=nullptr)
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Date and time this transaction was created.
std::string ToString() const
interfaces::Node & node() const
UI model for the transaction table of a wallet.
#define COLOR_UNCONFIRMED
void refreshWallet(interfaces::Wallet &wallet)
QString lookupAddress(const std::string &address, bool tooltip) const
void subscribeToCoreSignals()
std::unique_ptr< interfaces::Handler > m_handler_show_progress
static bool showTransaction()
Decompose CWallet transaction to model transaction records.
Net amount of transaction.
QString formatTxToAddress(const TransactionRecord *wtx, bool tooltip) const
bool m_loading
True when transactions are being notified, for instance when scanning.
Interface to Bitcoin wallet from Qt view code.
bool countsForBalance
Transaction counts towards available balance.
bool involvesWatchAddress
Whether the transaction was sent/received with a watch-only address.
std::string GetHex() const
QString getTxHex(interfaces::Wallet &wallet, TransactionRecord *rec)
std::string EncodeHexTx(const CTransaction &tx, const int serializeFlags=0)
Label of address related to transaction.
bool m_loaded
True when model finishes loading all wallet transactions on start.
static QString getAmountColumnTitle(Unit unit)
Gets title for amount column including current display unit if optionsModel reference available */...
QString formatTxStatus(const TransactionRecord *wtx) const
AddressTableModel * getAddressTableModel() const
Normal (sent/received) transactions.
QVariant addressColor(const TransactionRecord *wtx) const
void invoke(QObject *ttm)
QVariant txAddressDecoration(const TransactionRecord *wtx) const
Confirmed, but waiting for the recommended number of confirmations.
Formatted amount, without brackets when unconfirmed.
QVariant data(const QModelIndex &index, int role) const override
ChangeType
General change type (added, updated, removed).
void updateConfirmations()
Abandoned from the wallet.
void SetHex(const char *psz)
#define COLOR_BAREADDRESS
Top-level interface for a bitcoin node (bitcoind process).
const PlatformStyle * platformStyle
Updated transaction status.
Conflicts with other transaction or mempool.
static const int RecommendedNumConfirmations
Number of confirmation recommended for accepting a transaction.
QString formatTxAmount(const TransactionRecord *wtx, bool showUnconfirmed=true, BitcoinUnits::SeparatorStyle separators=BitcoinUnits::SeparatorStyle::STANDARD) const
static QString toHTML(interfaces::Node &node, interfaces::Wallet &wallet, TransactionRecord *rec, BitcoinUnit unit)
QString formatTxDate(const TransactionRecord *wtx) const