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
43 return a.txid <
b.txid;
64 " status= " + QString::number(
status);
65 bool invoked = QMetaObject::invokeMethod(
66 ttm,
"updateTransaction", Qt::QueuedConnection,
102 qDebug() <<
"TransactionTablePriv::refreshWallet";
104 for (
const auto &wtx :
wallet.getWalletTxs()) {
118 bool showTransaction) {
119 qDebug() <<
"TransactionTablePriv::updateWallet: " +
120 QString::fromStdString(txid.
ToString()) +
" " +
121 QString::number(status);
124 QList<TransactionRecord>::iterator
lower = std::lower_bound(
126 QList<TransactionRecord>::iterator
upper = std::upper_bound(
134 if (showTransaction && !
inModel) {
138 if (!showTransaction &&
inModel) {
144 " Index=" + QString::number(
lowerIndex) +
"-" +
146 " showTransaction=" + QString::number(showTransaction) +
147 " derivedStatus=" + QString::number(status);
152 qWarning() <<
"TransactionTablePriv::updateWallet: "
153 "Warning: Got CT_NEW, but transaction is "
157 if (showTransaction) {
161 qWarning() <<
"TransactionTablePriv::updateWallet: "
162 "Warning: Got CT_NEW, but transaction is "
185 qWarning() <<
"TransactionTablePriv::updateWallet: "
186 "Warning: Got CT_DELETED, but transaction is "
236 return QString::fromStdString(
strHex);
244 : QAbstractTableModel(parent), walletModel(parent),
272 bool showTransaction) {
304 status =
tr(
"Unconfirmed");
307 status =
tr(
"Abandoned");
310 status =
tr(
"Confirming (%1 of %2 recommended confirmations)")
315 status =
tr(
"Confirmed (%1 confirmations)").arg(wtx->
status.
depth);
318 status =
tr(
"Conflicted");
322 tr(
"Immature (%1 confirmations, will be available after %2)")
327 status =
tr(
"Generated but not accepted");
349 QString::fromStdString(address));
351 if (!label.isEmpty()) {
352 description += label;
354 if (label.isEmpty() ||
tooltip) {
365 return tr(
"Received with");
367 return tr(
"Received from");
370 return tr(
"Sent to");
372 return tr(
"Payment to yourself");
384 return QIcon(
":/icons/tx_mined");
387 return QIcon(
":/icons/tx_input");
390 return QIcon(
":/icons/tx_output");
392 return QIcon(
":/icons/tx_inout");
432 QString::fromStdString(wtx->
address));
433 if (label.isEmpty()) {
463 return QIcon(
":/icons/transaction_0");
465 return QIcon(
":/icons/transaction_abandoned");
469 return QIcon(
":/icons/transaction_1");
471 return QIcon(
":/icons/transaction_2");
473 return QIcon(
":/icons/transaction_3");
475 return QIcon(
":/icons/transaction_4");
477 return QIcon(
":/icons/transaction_5");
480 return QIcon(
":/icons/transaction_confirmed");
482 return QIcon(
":/icons/transaction_conflicted");
489 return QIcon(
":/icons/transaction_0");
498 return QIcon(
":/icons/eye");
517 if (!
index.isValid()) {
526 switch (
index.column()) {
535 case Qt::DecorationRole: {
539 case Qt::DisplayRole:
540 switch (
index.column()) {
554 switch (
index.column()) {
556 return QString::fromStdString(
rec->status.sortKey);
562 return (
rec->involvesWatchAddress ? 1 : 0);
569 case Qt::ToolTipRole:
571 case Qt::TextAlignmentRole:
573 case Qt::ForegroundRole:
579 if (!
rec->status.countsForBalance &&
594 return QDateTime::fromTime_t(
static_cast<uint>(
rec->time));
596 return rec->involvesWatchAddress;
604 return QString::fromStdString(
rec->address);
607 QString::fromStdString(
rec->address));
611 return rec->getTxID();
613 return QString::fromStdString(
rec->txid.ToString());
619 QDateTime::fromTime_t(
static_cast<uint>(
rec->time));
622 QString::fromStdString(
rec->address));
624 details.append(date.toString(
"M/d/yy HH:mm"));
627 details.append(
". ");
632 if (!
rec->address.empty()) {
634 details.append(
tr(
"(no label)") +
" ");
638 details.append(
") ");
640 details.append(QString::fromStdString(
rec->address));
648 return rec->status.status ==
656 return rec->status.status;
665 if (role == Qt::DisplayRole) {
667 }
else if (role == Qt::TextAlignmentRole) {
669 }
else if (role == Qt::ToolTipRole) {
672 return tr(
"Transaction status. Hover over this field to "
673 "show number of confirmations.");
676 "Date and time that the transaction was received.");
678 return tr(
"Type of transaction.");
680 return tr(
"Whether or not a watch-only address is involved "
681 "in this transaction.");
684 "User-defined intent/purpose of the transaction.");
686 return tr(
"Amount removed from or added to balance.");
736 bool invoked = QMetaObject::invokeMethod(
737 parent,
"setProcessingQueuedTransactions", Qt::QueuedConnection,
744 bool invoked = QMetaObject::invokeMethod(
745 parent,
"setProcessingQueuedTransactions",
746 Qt::QueuedConnection,
Q_ARG(
bool,
false));
761 std::placeholders::_1, std::placeholders::_2));
764 std::placeholders::_1, std::placeholders::_2));
static constexpr Amount SATOSHI
QString labelForAddress(const QString &address) const
Look up label for address in address book, if not found return empty string.
static QString format(int unit, const Amount amount, bool plussign=false, SeparatorStyle separators=SeparatorStyle::STANDARD, bool justify=false)
Format as string.
static QString getAmountColumnTitle(int unit)
Gets title for amount column including current display unit if optionsModel reference available */.
int getDisplayUnit() const
void displayUnitChanged(int unit)
static QString toHTML(interfaces::Node &node, interfaces::Wallet &wallet, TransactionRecord *rec, int unit)
UI model for a transaction.
static QList< TransactionRecord > decomposeTransaction(const interfaces::WalletTx &wtx)
Decompose CWallet transaction to model transaction records.
static const int RecommendedNumConfirmations
Number of confirmation recommended for accepting a transaction.
static bool showTransaction()
Decompose CWallet transaction to model transaction records.
TransactionStatus status
Status: can change with block chain update.
bool involvesWatchAddress
Whether the transaction was sent/received with a watch-only address.
bool countsForBalance
Transaction counts towards available balance.
@ Confirmed
Have 6 or more confirmations (normal tx) or fully mature (mined tx)
@ Unconfirmed
Normal (sent/received) transactions.
@ Immature
Generated (mined) transactions.
@ Confirming
Confirmed, but waiting for the recommended number of confirmations.
@ NotAccepted
Mined but not accepted.
@ Conflicted
Conflicts with other transaction or mempool.
@ Abandoned
Abandoned from the wallet.
UI model for the transaction table of a wallet.
QVariant txStatusDecoration(const TransactionRecord *wtx) const
void subscribeToCoreSignals()
TransactionTablePriv * priv
void unsubscribeFromCoreSignals()
QVariant addressColor(const TransactionRecord *wtx) const
@ TxPlainTextRole
Whole transaction as plain text.
@ LabelRole
Label of address related to transaction.
@ LongDescriptionRole
Long description (HTML format)
@ TypeRole
Type of transaction.
@ StatusRole
Transaction status (TransactionRecord::Status)
@ DateRole
Date and time this transaction was created.
@ TxHashRole
Transaction hash.
@ TxHexRole
Transaction data, hex-encoded.
@ RawDecorationRole
Unprocessed icon.
@ TxIDRole
Unique identifier.
@ AddressRole
Address of transaction.
@ WatchonlyDecorationRole
Watch-only icon.
@ WatchonlyRole
Watch-only boolean.
@ AmountRole
Net amount of transaction.
@ ConfirmedRole
Is transaction confirmed?
@ FormattedAmountRole
Formatted amount, without brackets when unconfirmed.
QString formatTooltip(const TransactionRecord *rec) const
QString formatTxAmount(const TransactionRecord *wtx, bool showUnconfirmed=true, BitcoinUnits::SeparatorStyle separators=BitcoinUnits::SeparatorStyle::STANDARD) const
void updateConfirmations()
QVariant data(const QModelIndex &index, int role) const override
QVariant txWatchonlyDecoration(const TransactionRecord *wtx) const
void updateTransaction(const QString &hash, int status, bool showTransaction)
New transaction, or transaction changed status.
QString formatTxStatus(const TransactionRecord *wtx) const
WalletModel * walletModel
std::unique_ptr< interfaces::Handler > m_handler_transaction_changed
int columnCount(const QModelIndex &parent) const override
std::unique_ptr< interfaces::Handler > m_handler_show_progress
TransactionTableModel(const PlatformStyle *platformStyle, WalletModel *parent=nullptr)
int rowCount(const QModelIndex &parent) const override
void updateAmountColumnTitle()
Updates the column title to "Amount (DisplayUnit)" and emits headerDataChanged() signal for table hea...
QString formatTxToAddress(const TransactionRecord *wtx, bool tooltip) const
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
const PlatformStyle * platformStyle
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
QString formatTxType(const TransactionRecord *wtx) const
QString lookupAddress(const std::string &address, bool tooltip) const
Look up address in address book, if found return label (address) otherwise just return (address)
QVariant txAddressDecoration(const TransactionRecord *wtx) const
QString formatTxDate(const TransactionRecord *wtx) const
QString getTxHex(interfaces::Wallet &wallet, TransactionRecord *rec)
void updateWallet(interfaces::Wallet &wallet, const TxId &txid, int status, bool showTransaction)
Update our model of the wallet incrementally, to synchronize our model of the wallet with that of the...
TransactionTablePriv(TransactionTableModel *_parent)
TransactionTableModel * parent
QList< TransactionRecord > cachedWallet
std::vector< TransactionNotification > vQueueNotifications
void refreshWallet(interfaces::Wallet &wallet)
Query entire wallet anew from core.
QString describe(interfaces::Node &node, interfaces::Wallet &wallet, TransactionRecord *rec, int unit)
void ShowProgress(const std::string &title, int nProgress)
void NotifyTransactionChanged(const TxId &txidc, ChangeType status)
TransactionRecord * index(interfaces::Wallet &wallet, const BlockHash &cur_block_hash, const int idx)
Interface to Bitcoin wallet from Qt view code.
interfaces::Node & node() const
BlockHash getLastBlockProcessed() const
AddressTableModel * getAddressTableModel()
OptionsModel * getOptionsModel()
interfaces::Wallet & wallet() const
void SetHex(const char *psz)
std::string ToString() const
std::string GetHex() const
Top-level interface for a bitcoin node (bitcoind process).
Interface for accessing a wallet.
virtual std::unique_ptr< Handler > handleShowProgress(ShowProgressFn fn)=0
virtual std::unique_ptr< Handler > handleTransactionChanged(TransactionChangedFn fn)=0
std::string EncodeHexTx(const CTransaction &tx, const int serializeFlags=0)
#define COLOR_TX_STATUS_DANGER
#define COLOR_UNCONFIRMED
#define COLOR_BAREADDRESS
QString dateTimeStr(const QDateTime &date)
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
static constexpr Amount zero() noexcept
A BlockHash is a unqiue identifier for a block.
TransactionNotification(TxId _txid, ChangeType _status, bool _showTransaction)
void invoke(QObject *ttm)
TransactionNotification()
A TxId is the identifier of a transaction.
bool operator()(const TransactionRecord &a, const TxId &b) const
bool operator()(const TransactionRecord &a, const TransactionRecord &b) const
bool operator()(const TxId &a, const TransactionRecord &b) const
Updated transaction status.
static int column_alignments[]
ChangeType
General change type (added, updated, removed).