30 #include <QLatin1Char> 31 #include <QLatin1String> 37 Qt::AlignLeft|Qt::AlignVCenter,
38 Qt::AlignLeft|Qt::AlignVCenter,
39 Qt::AlignLeft|Qt::AlignVCenter,
40 Qt::AlignLeft|Qt::AlignVCenter,
41 Qt::AlignLeft|Qt::AlignVCenter,
42 Qt::AlignRight|Qt::AlignVCenter
72 QString strHash = QString::fromStdString(
hash.
GetHex());
73 qDebug() <<
"NotifyTransactionChanged: " + strHash +
" status= " + QString::number(
status);
74 bool invoked = QMetaObject::invokeMethod(ttm,
"updateTransaction", Qt::QueuedConnection,
75 Q_ARG(QString, strHash),
115 for (
const auto& wtx :
wallet.getWalletTxs()) {
132 qDebug() <<
"TransactionTablePriv::updateWallet: " + QString::fromStdString(hash.
ToString()) +
" " + QString::number(status);
135 QList<TransactionRecord>::iterator lower = std::lower_bound(
137 QList<TransactionRecord>::iterator upper = std::upper_bound(
141 bool inModel = (lower != upper);
145 if(showTransaction && !inModel)
147 if(!showTransaction && inModel)
151 qDebug() <<
" inModel=" + QString::number(inModel) +
152 " Index=" + QString::number(lowerIndex) +
"-" + QString::number(upperIndex) +
153 " showTransaction=" + QString::number(showTransaction) +
" derivedStatus=" + QString::number(status);
160 qWarning() <<
"TransactionTablePriv::updateWallet: Warning: Got CT_NEW, but transaction is already in model";
169 qWarning() <<
"TransactionTablePriv::updateWallet: Warning: Got CT_NEW, but transaction is not in wallet";
173 QList<TransactionRecord> toInsert =
175 if(!toInsert.isEmpty())
177 parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex+toInsert.size()-1);
178 int insert_idx = lowerIndex;
191 qWarning() <<
"TransactionTablePriv::updateWallet: Warning: Got CT_DELETED, but transaction is not in model";
195 parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1);
202 for (
int i = lowerIndex; i < upperIndex; i++) {
227 rec->
updateStatus(wtx, cur_block_hash, numBlocks, block_time);
244 return QString::fromStdString(strHex);
251 QAbstractTableModel(parent),
254 platformStyle(_platformStyle)
297 if (parent.isValid()) {
305 if (parent.isValid()) {
318 status = tr(
"Unconfirmed");
321 status = tr(
"Abandoned");
327 status = tr(
"Confirmed (%1 confirmations)").arg(wtx->
status.
depth);
330 status = tr(
"Conflicted");
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");
393 return QIcon(
":/icons/tx_mined");
396 return QIcon(
":/icons/tx_input");
399 return QIcon(
":/icons/tx_output");
401 return QIcon(
":/icons/tx_inout");
407 QString watchAddress;
410 watchAddress = QLatin1String(
" (") + tr(
"watch-only") + QLatin1Char(
')');
416 return QString::fromStdString(wtx->
address) + watchAddress;
422 return QString::fromStdString(wtx->
address) + watchAddress;
424 return tr(
"(n/a)") + watchAddress;
454 str = QString(
"[") + str + QString(
"]");
465 return QIcon(
":/icons/transaction_0");
467 return QIcon(
":/icons/transaction_abandoned");
471 case 1:
return QIcon(
":/icons/transaction_1");
472 case 2:
return QIcon(
":/icons/transaction_2");
473 case 3:
return QIcon(
":/icons/transaction_3");
474 case 4:
return QIcon(
":/icons/transaction_4");
475 default:
return QIcon(
":/icons/transaction_5");
478 return QIcon(
":/icons/transaction_confirmed");
480 return QIcon(
":/icons/transaction_conflicted");
484 return QIcon(QString(
":/icons/transaction_%1").arg(part));
487 return QIcon(
":/icons/transaction_0");
496 return QIcon(
":/icons/eye");
526 case Date:
return {};
527 case Type:
return {};
533 case Qt::DecorationRole:
538 case Qt::DisplayRole:
569 case Qt::ToolTipRole:
571 case Qt::TextAlignmentRole:
573 case Qt::ForegroundRole:
596 return QDateTime::fromSecsSinceEpoch(rec->
time);
604 return QString::fromStdString(rec->
address);
616 QDateTime date = QDateTime::fromSecsSinceEpoch(rec->
time);
619 details.append(date.toString(
"M/d/yy HH:mm"));
622 details.append(
". ");
628 if(txLabel.isEmpty())
629 details.append(tr(
"(no label)") +
" ");
632 details.append(txLabel);
633 details.append(
") ");
635 details.append(QString::fromStdString(rec->
address));
642 return rec->
status.
status == TransactionStatus::Status::Confirming || rec->
status.
status == TransactionStatus::Status::Confirmed;
654 if(orientation == Qt::Horizontal)
656 if(role == Qt::DisplayRole)
660 else if (role == Qt::TextAlignmentRole)
663 }
else if (role == Qt::ToolTipRole)
668 return tr(
"Transaction status. Hover over this field to show number of confirmations.");
670 return tr(
"Date and time that the transaction was received.");
672 return tr(
"Type of transaction.");
674 return tr(
"Whether or not a watch-only address is involved in this transaction.");
676 return tr(
"User-defined intent/purpose of the transaction.");
678 return tr(
"Amount removed from or added to balance.");
691 return createIndex(row, column,
data);
693 return QModelIndex();
724 bool invoked = QMetaObject::invokeMethod(
parent,
"setProcessingQueuedTransactions", Qt::QueuedConnection, Q_ARG(
bool,
true));
730 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
Local cache of wallet sorted by transaction hash.
void SetHexDeprecated(std::string_view str)
Unlike FromHex this accepts any invalid input, thus it is fragile and deprecated! ...
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
constexpr bool IsNull() const
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.
std::string EncodeHexTx(const CTransaction &tx)
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)
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.
#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