Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions src/qt/transactiondesc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,18 @@ using wallet::ISMINE_SPENDABLE;
using wallet::ISMINE_WATCH_ONLY;
using wallet::isminetype;

QString TransactionDesc::FormatTxStatus(const interfaces::WalletTx& wtx, const interfaces::WalletTxStatus& status, bool inMempool, int numBlocks)
QString TransactionDesc::FormatTxStatus(const interfaces::WalletTxStatus& status, bool inMempool)
{
{
int nDepth = status.depth_in_main_chain;
if (nDepth < 0) {
return tr("conflicted with a transaction with %1 confirmations").arg(-nDepth);
} else if (nDepth == 0) {
const QString abandoned{status.is_abandoned ? QLatin1String(", ") + tr("abandoned") : QString()};
return tr("0/unconfirmed, %1").arg(inMempool ? tr("in memory pool") : tr("not in memory pool")) + abandoned;
} else if (nDepth < 6) {
return tr("%1/unconfirmed").arg(nDepth);
} else {
return tr("%1 confirmations").arg(nDepth);
}
int depth = status.depth_in_main_chain;
if (depth < 0) {
return tr("conflicted with a transaction with %1 confirmations").arg(-depth);
} else if (depth == 0) {
const QString abandoned{status.is_abandoned ? QLatin1String(", ") + tr("abandoned") : QString()};
return tr("0/unconfirmed, %1").arg(inMempool ? tr("in memory pool") : tr("not in memory pool")) + abandoned;
} else if (depth < 6) {
return tr("%1/unconfirmed").arg(depth);
} else {
return tr("%1 confirmations").arg(depth);
}
}

Expand Down Expand Up @@ -95,7 +93,7 @@ QString TransactionDesc::toHTML(interfaces::Node& node, interfaces::Wallet& wall
CAmount nDebit = wtx.debit;
CAmount nNet = nCredit - nDebit;

strHTML += "<b>" + tr("Status") + ":</b> " + FormatTxStatus(wtx, status, inMempool, numBlocks);
strHTML += "<b>" + tr("Status") + ":</b> " + FormatTxStatus(status, inMempool);
strHTML += "<br>";

strHTML += "<b>" + tr("Date") + ":</b> " + (nTime ? GUIUtil::dateTimeStr(nTime) : "") + "<br>";
Expand Down
2 changes: 1 addition & 1 deletion src/qt/transactiondesc.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class TransactionDesc: public QObject
private:
TransactionDesc() {}

static QString FormatTxStatus(const interfaces::WalletTx& wtx, const interfaces::WalletTxStatus& status, bool inMempool, int numBlocks);
static QString FormatTxStatus(const interfaces::WalletTxStatus& status, bool inMempool);
};

#endif // BITCOIN_QT_TRANSACTIONDESC_H
21 changes: 6 additions & 15 deletions src/qt/transactionrecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,7 @@ struct WalletTxStatus;

/** UI model for transaction status. The transaction status is the part of a transaction that will change over time.
*/
class TransactionStatus
{
public:
TransactionStatus() : countsForBalance(false), sortKey(""),
matures_in(0), status(Unconfirmed), depth(0), open_for(0)
{ }

struct TransactionStatus {
enum Status {
Confirmed, /**< Have 6 or more confirmations (normal tx) or fully mature (mined tx) **/
/// Normal (sent/received) transactions
Expand All @@ -40,28 +34,25 @@ class TransactionStatus
};

/// Transaction counts towards available balance
bool countsForBalance;
bool countsForBalance{false};
/// Sorting key based on status
std::string sortKey;

/** @name Generated (mined) transactions
@{*/
int matures_in;
int matures_in{0};
/**@}*/

/** @name Reported status
@{*/
Status status;
qint64 depth;
qint64 open_for; /**< Timestamp if status==OpenUntilDate, otherwise number
of additional blocks that need to be mined before
finalization */
Status status{Unconfirmed};
qint64 depth{0};
/**@}*/

/** Current block hash (to know whether cached status is still valid) */
uint256 m_cur_block_hash{};

bool needsUpdate;
bool needsUpdate{false};
};

/** UI model for a transaction. A core transaction can be represented by multiple UI transactions if it has
Expand Down