PR24067 follow-ups #538

issue MarcoFalke opened 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:

    diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp
    index be5851d627..4f18c58b20 100644
    --- a/src/qt/transactiondesc.cpp
    +++ b/src/qt/transactiondesc.cpp
    @@ -1,4 +1,4 @@
    -// Copyright (c) 2011-2021 The Bitcoin Core developers
    +// Copyright (c) 2011-2022 The Bitcoin Core developers
     // Distributed under the MIT software license, see the accompanying
     // file COPYING or http://www.opensource.org/licenses/mit-license.php.
     
    @@ -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);
         }
     }
     
    diff --git a/src/qt/transactionrecord.h b/src/qt/transactionrecord.h
    index dd34656d5f..b2912f17c9 100644
    --- a/src/qt/transactionrecord.h
    +++ b/src/qt/transactionrecord.h
    @@ -1,4 +1,4 @@
    -// Copyright (c) 2011-2021 The Bitcoin Core developers
    +// Copyright (c) 2011-2022 The Bitcoin Core developers
     // Distributed under the MIT software license, see the accompanying
     // file COPYING or http://www.opensource.org/licenses/mit-license.php.
     
    @@ -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,22 +34,19 @@ public:
         };
     
         /// Transaction counts towards available balance
    -    bool countsForBalance;
    +    bool countsForBalance{false};
         /// Sorting key based on status
    -    std::string sortKey;
    +    std::string sortKey{};
     
         /** [@name](/bitcoin-core-gui/contributor/name/) Generated (mined) transactions
            @{*/
    -    int matures_in;
    +    int matures_in{0};
         /**@}*/
     
         /** [@name](/bitcoin-core-gui/contributor/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) */
    
  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: 2026-04-30 06:20 UTC

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