From b1bc1431db1e86eefaf4a91e08663628d94656fc Mon Sep 17 00:00:00 2001
From: w0xlt <94266259+w0xlt@users.noreply.github.com>
Date: Fri, 18 Feb 2022 15:41:05 -0300
Subject: [PATCH 1/5] qt, refactor: remove redundant scope in
`TransactionDesc::FormatTxStatus()`
---
src/qt/transactiondesc.cpp | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp
index be5851d627..94aa3c409f 100644
--- a/src/qt/transactiondesc.cpp
+++ b/src/qt/transactiondesc.cpp
@@ -34,18 +34,16 @@ using wallet::isminetype;
QString TransactionDesc::FormatTxStatus(const interfaces::WalletTx& wtx, const interfaces::WalletTxStatus& status, bool inMempool, int numBlocks)
{
- {
- 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 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);
}
}
From 045f8d0310d2340aa32db6f7e582dea45950d28a Mon Sep 17 00:00:00 2001
From: w0xlt <94266259+w0xlt@users.noreply.github.com>
Date: Mon, 21 Feb 2022 15:17:24 -0300
Subject: [PATCH 2/5] scripted-diff: rename nDepth -> depth
-BEGIN VERIFY SCRIPT-
s() { sed -i -e 's/nDepth/depth/g' $(git grep -l 'nDepth' $1); }
s src/qt/transactiondesc.cpp
-END VERIFY SCRIPT-
---
src/qt/transactiondesc.cpp | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp
index 94aa3c409f..27dc234241 100644
--- a/src/qt/transactiondesc.cpp
+++ b/src/qt/transactiondesc.cpp
@@ -34,16 +34,16 @@ using wallet::isminetype;
QString TransactionDesc::FormatTxStatus(const interfaces::WalletTx& wtx, const interfaces::WalletTxStatus& status, bool inMempool, int numBlocks)
{
- 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) {
+ 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 (nDepth < 6) {
- return tr("%1/unconfirmed").arg(nDepth);
+ } else if (depth < 6) {
+ return tr("%1/unconfirmed").arg(depth);
} else {
- return tr("%1 confirmations").arg(nDepth);
+ return tr("%1 confirmations").arg(depth);
}
}
From ad6adedb46e25870bcdabeca93c51c3ac2a33de7 Mon Sep 17 00:00:00 2001
From: w0xlt <94266259+w0xlt@users.noreply.github.com>
Date: Mon, 21 Feb 2022 15:22:48 -0300
Subject: [PATCH 3/5] qt, refactor: remove unused parameters in
`TransactionDesc::FormatTxStatus()`
---
src/qt/transactiondesc.cpp | 4 ++--
src/qt/transactiondesc.h | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp
index 27dc234241..142db592ab 100644
--- a/src/qt/transactiondesc.cpp
+++ b/src/qt/transactiondesc.cpp
@@ -32,7 +32,7 @@ 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 depth = status.depth_in_main_chain;
if (depth < 0) {
@@ -93,7 +93,7 @@ QString TransactionDesc::toHTML(interfaces::Node& node, interfaces::Wallet& wall
CAmount nDebit = wtx.debit;
CAmount nNet = nCredit - nDebit;
- strHTML += "" + tr("Status") + ": " + FormatTxStatus(wtx, status, inMempool, numBlocks);
+ strHTML += "" + tr("Status") + ": " + FormatTxStatus(status, inMempool);
strHTML += "
";
strHTML += "" + tr("Date") + ": " + (nTime ? GUIUtil::dateTimeStr(nTime) : "") + "
";
diff --git a/src/qt/transactiondesc.h b/src/qt/transactiondesc.h
index cf955a433c..91c257e519 100644
--- a/src/qt/transactiondesc.h
+++ b/src/qt/transactiondesc.h
@@ -29,7 +29,7 @@ public:
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
From 66d58ad7a99a98b5e78fd97ddf777ea00e6091cf Mon Sep 17 00:00:00 2001
From: w0xlt <94266259+w0xlt@users.noreply.github.com>
Date: Mon, 21 Feb 2022 15:33:42 -0300
Subject: [PATCH 4/5] qt, refactor: remove unused field `qint64
TransactionStatus::open_for`
---
src/qt/transactionrecord.h | 3 ---
1 file changed, 3 deletions(-)
diff --git a/src/qt/transactionrecord.h b/src/qt/transactionrecord.h
index dd34656d5f..2898a2739e 100644
--- a/src/qt/transactionrecord.h
+++ b/src/qt/transactionrecord.h
@@ -53,9 +53,6 @@ public:
@{*/
Status status;
qint64 depth;
- qint64 open_for; /**< Timestamp if status==OpenUntilDate, otherwise number
- of additional blocks that need to be mined before
- finalization */
/**@}*/
/** Current block hash (to know whether cached status is still valid) */
From 343f83d0886ae39c9dacb29762ce712711b2bad2 Mon Sep 17 00:00:00 2001
From: w0xlt <94266259+w0xlt@users.noreply.github.com>
Date: Fri, 18 Feb 2022 15:45:53 -0300
Subject: [PATCH 5/5] qt, refactor: Use member initializers in
TransactionStatus
---
src/qt/transactionrecord.h | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/src/qt/transactionrecord.h b/src/qt/transactionrecord.h
index 2898a2739e..d8748d7dc9 100644
--- a/src/qt/transactionrecord.h
+++ b/src/qt/transactionrecord.h
@@ -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
@@ -40,25 +34,25 @@ public:
};
/// 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;
+ 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