]> Nutra Git (v1) - gamesguru/feather.git/commitdiff
History: set default description to Coinbase for mining outputs
authortobtoht <tob@featherwallet.org>
Thu, 4 Jan 2024 21:23:16 +0000 (22:23 +0100)
committertobtoht <tob@featherwallet.org>
Thu, 4 Jan 2024 21:23:16 +0000 (22:23 +0100)
src/libwalletqt/TransactionHistory.cpp
src/libwalletqt/TransactionHistory.h

index 7218aa34ed2536da4bcdd260d7beaedc50ece033..aaa543acf46aa7c996f89d8ddb45b0beacd84798 100644 (file)
@@ -103,11 +103,7 @@ void TransactionHistory::refresh()
             t->m_timestamp = QDateTime::fromSecsSinceEpoch(pd.m_timestamp);
             t->m_confirmations = (wallet_height > pd.m_block_height) ? wallet_height - pd.m_block_height : 0;
             t->m_unlockTime = pd.m_unlock_time;
-
-            t->m_description = QString::fromStdString(m_wallet2->get_tx_note(pd.m_tx_hash));
-            if (t->m_description.isEmpty()) {
-                t->m_description = QString::fromStdString(m_wallet2->get_subaddress_label(pd.m_subaddr_index));
-            }
+            t->m_description = description(pd);
 
             m_rows.append(t);
         }
@@ -254,11 +250,7 @@ void TransactionHistory::refresh()
             t->m_label = QString::fromStdString(m_wallet2->get_subaddress_label(pd.m_subaddr_index));
             t->m_timestamp = QDateTime::fromSecsSinceEpoch(pd.m_timestamp);
             t->m_confirmations = 0;
-
-            t->m_description = QString::fromStdString(m_wallet2->get_tx_note(pd.m_tx_hash));
-            if (t->m_description.isEmpty()) {
-                t->m_description = QString::fromStdString(m_wallet2->get_subaddress_label(pd.m_subaddr_index));
-            }
+            t->m_description = description(pd);
 
             m_rows.append(t);
 
@@ -393,3 +385,20 @@ bool TransactionHistory::writeCSV(const QString &path) {
     data = QString("blockHeight,timestamp,date,accountIndex,direction,balanceDelta,amount,fee,txid,description,paymentId,fiatAmount,fiatCurrency%1").arg(data);
     return Utils::fileWrite(path, data);
 }
+
+QString TransactionHistory::description(const tools::wallet2::payment_details &pd)
+{
+    QString description = QString::fromStdString(m_wallet2->get_tx_note(pd.m_tx_hash));
+    if (description.isEmpty()) {
+        if (pd.m_coinbase) {
+            description = "Coinbase";
+        }
+        else if (pd.m_subaddr_index.major == 0 && pd.m_subaddr_index.minor == 0) {
+            description = "Primary address";
+        }
+        else {
+            description = QString::fromStdString(m_wallet2->get_subaddress_label(pd.m_subaddr_index));
+        }
+    }
+    return description;
+}
\ No newline at end of file
index ce10b8e7dd7452d21edbcc9889e5b4c1b1e651ce..24e60c6f013e317e6e33087d044143eca6c79242 100644 (file)
@@ -51,6 +51,7 @@ signals:
 
 private:
     explicit TransactionHistory(Wallet *wallet, tools::wallet2 *wallet2, QObject *parent = nullptr);
+    QString description(const tools::wallet2::payment_details &pd);
 
 private:
     friend class Wallet;