History: set default description to Coinbase for mining outputs

This commit is contained in:
tobtoht 2024-01-04 22:23:16 +01:00
parent 4a3604a3b8
commit c247962c21
No known key found for this signature in database
GPG key ID: E45B10DD027D2472
2 changed files with 20 additions and 10 deletions

View 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;
}

View 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;