32 Qt::AlignLeft|Qt::AlignVCenter,
33 Qt::AlignLeft|Qt::AlignVCenter,
34 Qt::AlignLeft|Qt::AlignVCenter,
35 Qt::AlignLeft|Qt::AlignVCenter,
36 Qt::AlignLeft|Qt::AlignVCenter,
37 Qt::AlignRight|Qt::AlignVCenter
67 QString strHash = QString::fromStdString(
hash.
GetHex());
68 qDebug() <<
"NotifyTransactionChanged: " + strHash +
" status= " + QString::number(
status);
69 bool invoked = QMetaObject::invokeMethod(ttm,
"updateTransaction", Qt::QueuedConnection,
70 Q_ARG(QString, strHash),
102 void ShowProgress(
const std::string &title,
int nProgress);
108 qDebug() <<
"TransactionTablePriv::refreshWallet";
126 qDebug() <<
"TransactionTablePriv::updateWallet: " + QString::fromStdString(hash.
ToString()) +
" " + QString::number(status);
129 QList<TransactionRecord>::iterator lower = std::lower_bound(
131 QList<TransactionRecord>::iterator upper = std::upper_bound(
135 bool inModel = (lower != upper);
139 if(showTransaction && !inModel)
141 if(!showTransaction && inModel)
145 qDebug() <<
" inModel=" + QString::number(inModel) +
146 " Index=" + QString::number(lowerIndex) +
"-" + QString::number(upperIndex) +
147 " showTransaction=" + QString::number(showTransaction) +
" derivedStatus=" + QString::number(status);
154 qWarning() <<
"TransactionTablePriv::updateWallet: Warning: Got CT_NEW, but transaction is already in model";
163 qWarning() <<
"TransactionTablePriv::updateWallet: Warning: Got CT_NEW, but transaction is not in wallet";
167 QList<TransactionRecord> toInsert =
169 if(!toInsert.isEmpty())
171 parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex+toInsert.size()-1);
172 int insert_idx = lowerIndex;
185 qWarning() <<
"TransactionTablePriv::updateWallet: Warning: Got CT_DELETED, but transaction is not in model";
189 parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1);
196 for (
int i = lowerIndex; i < upperIndex; i++) {
221 rec->
updateStatus(wtx, cur_block_hash, numBlocks, block_time);
238 return QString::fromStdString(strHex);
245 QAbstractTableModel(parent),
248 fProcessingQueuedTransactions(false),
249 platformStyle(_platformStyle)
275 updated.
SetHex(hash.toStdString());
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(
"Generated but not accepted");
358 description += label;
360 if(label.isEmpty() || tooltip)
362 description += QString(
" (") + QString::fromStdString(address) + QString(
")");
372 return tr(
"Received with");
374 return tr(
"Received from");
377 return tr(
"Sent to");
379 return tr(
"Payment to yourself");
392 return QIcon(
":/icons/tx_mined");
395 return QIcon(
":/icons/tx_input");
398 return QIcon(
":/icons/tx_output");
400 return QIcon(
":/icons/tx_inout");
406 QString watchAddress;
409 watchAddress = wtx->
involvesWatchAddress ? QString(
" (") + tr(
"watch-only") + QString(
")") :
"";
415 return QString::fromStdString(wtx->
address) + watchAddress;
421 return QString::fromStdString(wtx->
address) + watchAddress;
425 return tr(
"(n/a)") + watchAddress;
457 str = QString(
"[") + str + QString(
"]");
471 return QIcon(
":/icons/transaction_0");
473 return QIcon(
":/icons/transaction_abandoned");
477 case 1:
return QIcon(
":/icons/transaction_1");
478 case 2:
return QIcon(
":/icons/transaction_2");
479 case 3:
return QIcon(
":/icons/transaction_3");
480 case 4:
return QIcon(
":/icons/transaction_4");
481 default:
return QIcon(
":/icons/transaction_5");
484 return QIcon(
":/icons/transaction_confirmed");
486 return QIcon(
":/icons/transaction_conflicted");
490 return QIcon(QString(
":/icons/transaction_%1").arg(part));
493 return QIcon(
":/icons/transaction_0");
502 return QIcon(
":/icons/eye");
527 switch(
index.column())
537 case Qt::DecorationRole:
542 case Qt::DisplayRole:
543 switch(
index.column())
557 switch(
index.column())
573 case Qt::ToolTipRole:
575 case Qt::TextAlignmentRole:
577 case Qt::ForegroundRole:
600 return QDateTime::fromTime_t(
static_cast<uint
>(rec->
time));
608 return QString::fromStdString(rec->
address);
620 QDateTime date = QDateTime::fromTime_t(
static_cast<uint
>(rec->
time));
623 details.append(date.toString(
"M/d/yy HH:mm"));
626 details.append(
". ");
632 if(txLabel.isEmpty())
633 details.append(tr(
"(no label)") +
" ");
636 details.append(txLabel);
637 details.append(
") ");
639 details.append(QString::fromStdString(rec->
address));
646 return rec->
status.
status == TransactionStatus::Status::Confirming || rec->
status.
status == TransactionStatus::Status::Confirmed;
658 if(orientation == Qt::Horizontal)
660 if(role == Qt::DisplayRole)
664 else if (role == Qt::TextAlignmentRole)
667 }
else if (role == Qt::ToolTipRole)
672 return tr(
"Transaction status. Hover over this field to show number of confirmations.");
674 return tr(
"Date and time that the transaction was received.");
676 return tr(
"Type of transaction.");
678 return tr(
"Whether or not a watch-only address is involved in this transaction.");
680 return tr(
"User-defined intent/purpose of the transaction.");
682 return tr(
"Amount removed from or added to balance.");
695 return createIndex(row, column,
data);
697 return QModelIndex();
728 if (nProgress == 100)
732 bool invoked = QMetaObject::invokeMethod(
parent,
"setProcessingQueuedTransactions", Qt::QueuedConnection, Q_ARG(
bool,
true));
738 bool invoked = QMetaObject::invokeMethod(
parent,
"setProcessingQueuedTransactions", Qt::QueuedConnection, Q_ARG(
bool,
false));
QString labelForAddress(const QString &address) const
Look up label for address in address book, if not found return empty string.
static QString getAmountColumnTitle(int unit)
Gets title for amount column including current display unit if optionsModel reference available */.
static QString format(int unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=SeparatorStyle::STANDARD, bool justify=false)
Format as string.
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)
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.
QString getTxHash() const
Return the unique identifier for this transaction (part)
bool statusUpdateNeeded(const uint256 &block_hash) const
Return whether a status update is needed.
void updateStatus(const interfaces::WalletTxStatus &wtx, const uint256 &block_hash, int numBlocks, int64_t block_time)
Update status from core wallet tx.
bool involvesWatchAddress
Whether the transaction was sent/received with a watch-only address.
bool countsForBalance
Transaction counts towards available balance.
qint64 open_for
Timestamp if status==OpenUntilDate, otherwise number of additional blocks that need to be mined befor...
@ Confirmed
Have 6 or more confirmations (normal tx) or fully mature (mined tx)
@ OpenUntilDate
Normal (sent/received) transactions.
@ Unconfirmed
Not yet mined into a block.
@ Immature
Generated (mined) transactions.
@ Confirming
Confirmed, but waiting for the recommended number of confirmations.
@ NotAccepted
Mined but not accepted.
@ OpenUntilBlock
Transaction not yet final, waiting for block.
@ Conflicted
Conflicts with other transaction or mempool.
@ Abandoned
Abandoned from the wallet.
std::string sortKey
Sorting key based on status.
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.
@ 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)
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
QVariant txAddressDecoration(const TransactionRecord *wtx) const
QString formatTxDate(const TransactionRecord *wtx) const
QString getTxHex(interfaces::Wallet &wallet, TransactionRecord *rec)
TransactionRecord * index(interfaces::Wallet &wallet, const uint256 &cur_block_hash, const int idx)
TransactionTablePriv(TransactionTableModel *_parent)
TransactionTableModel * parent
QList< TransactionRecord > cachedWallet
void refreshWallet(interfaces::Wallet &wallet)
QString describe(interfaces::Node &node, interfaces::Wallet &wallet, TransactionRecord *rec, int unit)
void NotifyTransactionChanged(const uint256 &hash, ChangeType status)
void updateWallet(interfaces::Wallet &wallet, const uint256 &hash, int status, bool showTransaction)
void ShowProgress(const std::string &title, int nProgress)
std::vector< TransactionNotification > vQueueNotifications
Interface to Bitcoin wallet from Qt view code.
AddressTableModel * getAddressTableModel()
OptionsModel * getOptionsModel()
interfaces::Wallet & wallet() const
uint256 getLastBlockProcessed() const
interfaces::Node & node() 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 WalletTx getWalletTx(const uint256 &txid)=0
Get transaction information.
virtual bool tryGetTxStatus(const uint256 &txid, WalletTxStatus &tx_status, int &num_blocks, int64_t &block_time)=0
Try to get updated status for a particular transaction, if possible without blocking.
virtual std::unique_ptr< Handler > handleShowProgress(ShowProgressFn fn)=0
virtual CTransactionRef getTx(const uint256 &txid)=0
Get a transaction.
virtual std::vector< WalletTx > getWalletTxs()=0
Get list of all wallet transactions.
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_TX_STATUS_OPENUNTILDATE
#define COLOR_BAREADDRESS
QString dateTimeStr(const QDateTime &date)
void invoke(QObject *ttm)
TransactionNotification(uint256 _hash, ChangeType _status, bool _showTransaction)
TransactionNotification()
bool operator()(const TransactionRecord &a, const TransactionRecord &b) const
bool operator()(const TransactionRecord &a, const uint256 &b) const
bool operator()(const uint256 &a, const TransactionRecord &b) const
Updated transaction status.
static int column_alignments[]
ChangeType
General change type (added, updated, removed).