PR24067 follow-ups #538

issue MarcoFalke openend this issue on January 26, 2022
  1. MarcoFalke commented at 6:41 am on January 26, 2022: contributor

    Some follow up ideas for https://github.com/bitcoin/bitcoin/pull/24067

    • Remove now unused open_for
    • Use C++11 member initializers
    • Fix whitespace

    Useful skills:

    • Building Bitcoin Core GUI
    • C++

    Want to work on this issue?

    For guidance on contributing, please read CONTRIBUTING.md before opening your pull request.

  2. MarcoFalke added the label good first issue on Jan 26, 2022
  3. MarcoFalke commented at 6:42 am on January 26, 2022: contributor

    This is the diff I drafted, but it needs to be split into separate commits, ideally:

     0diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp
     1index be5851d627..4f18c58b20 100644
     2--- a/src/qt/transactiondesc.cpp
     3+++ b/src/qt/transactiondesc.cpp
     4@@ -1,4 +1,4 @@
     5-// Copyright (c) 2011-2021 The Bitcoin Core developers
     6+// Copyright (c) 2011-2022 The Bitcoin Core developers
     7 // Distributed under the MIT software license, see the accompanying
     8 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
     9 
    10@@ -34,18 +34,16 @@ using wallet::isminetype;
    11 
    12 QString TransactionDesc::FormatTxStatus(const interfaces::WalletTx& wtx, const interfaces::WalletTxStatus& status, bool inMempool, int numBlocks)
    13 {
    14-    {
    15-        int nDepth = status.depth_in_main_chain;
    16-        if (nDepth < 0) {
    17-            return tr("conflicted with a transaction with %1 confirmations").arg(-nDepth);
    18-        } else if (nDepth == 0) {
    19-            const QString abandoned{status.is_abandoned ? QLatin1String(", ") + tr("abandoned") : QString()};
    20-            return tr("0/unconfirmed, %1").arg(inMempool ? tr("in memory pool") : tr("not in memory pool")) + abandoned;
    21-        } else if (nDepth < 6) {
    22-            return tr("%1/unconfirmed").arg(nDepth);
    23-        } else {
    24-            return tr("%1 confirmations").arg(nDepth);
    25-        }
    26+    int nDepth = status.depth_in_main_chain;
    27+    if (nDepth < 0) {
    28+        return tr("conflicted with a transaction with %1 confirmations").arg(-nDepth);
    29+    } else if (nDepth == 0) {
    30+        const QString abandoned{status.is_abandoned ? QLatin1String(", ") + tr("abandoned") : QString()};
    31+        return tr("0/unconfirmed, %1").arg(inMempool ? tr("in memory pool") : tr("not in memory pool")) + abandoned;
    32+    } else if (nDepth < 6) {
    33+        return tr("%1/unconfirmed").arg(nDepth);
    34+    } else {
    35+        return tr("%1 confirmations").arg(nDepth);
    36     }
    37 }
    38 
    39diff --git a/src/qt/transactionrecord.h b/src/qt/transactionrecord.h
    40index dd34656d5f..b2912f17c9 100644
    41--- a/src/qt/transactionrecord.h
    42+++ b/src/qt/transactionrecord.h
    43@@ -1,4 +1,4 @@
    44-// Copyright (c) 2011-2021 The Bitcoin Core developers
    45+// Copyright (c) 2011-2022 The Bitcoin Core developers
    46 // Distributed under the MIT software license, see the accompanying
    47 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
    48 
    49@@ -20,13 +20,7 @@ struct WalletTxStatus;
    50 
    51 /** UI model for transaction status. The transaction status is the part of a transaction that will change over time.
    52  */
    53-class TransactionStatus
    54-{
    55-public:
    56-    TransactionStatus() : countsForBalance(false), sortKey(""),
    57-                          matures_in(0), status(Unconfirmed), depth(0), open_for(0)
    58-    { }
    59-
    60+struct TransactionStatus {
    61     enum Status {
    62         Confirmed,          /**< Have 6 or more confirmations (normal tx) or fully mature (mined tx) **/
    63         /// Normal (sent/received) transactions
    64@@ -40,22 +34,19 @@ public:
    65     };
    66 
    67     /// Transaction counts towards available balance
    68-    bool countsForBalance;
    69+    bool countsForBalance{false};
    70     /// Sorting key based on status
    71-    std::string sortKey;
    72+    std::string sortKey{};
    73 
    74     /** [@name](/bitcoin-core-gui/contributor/name/) Generated (mined) transactions
    75        @{*/
    76-    int matures_in;
    77+    int matures_in{0};
    78     /**@}*/
    79 
    80     /** [@name](/bitcoin-core-gui/contributor/name/) Reported status
    81        @{*/
    82-    Status status;
    83-    qint64 depth;
    84-    qint64 open_for; /**< Timestamp if status==OpenUntilDate, otherwise number
    85-                      of additional blocks that need to be mined before
    86-                      finalization */
    87+    Status status{Unconfirmed};
    88+    qint64 depth{0};
    89     /**@}*/
    90 
    91     /** Current block hash (to know whether cached status is still valid) */
    
  4. hebasto renamed this:
    24067 follow-ups
    PR24067 follow-ups
    on Jan 26, 2022
  5. hebasto added the label Refactoring on Apr 14, 2022
  6. hebasto closed this on Apr 15, 2022

  7. sidhujag referenced this in commit 5c6c60dd11 on Apr 18, 2022
  8. bitcoin-core locked this on Apr 15, 2023

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/gui. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-21 12:20 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me