libwalletqt: cleanup

This commit is contained in:
tobtoht 2025-03-12 11:23:03 +01:00
parent 4f28d83ac3
commit 2c5f766a7b
No known key found for this signature in database
GPG key ID: E45B10DD027D2472
33 changed files with 317 additions and 404 deletions

View file

@ -26,7 +26,7 @@
#include "dialog/WalletCacheDebugDialog.h"
#include "libwalletqt/AddressBook.h"
#include "libwalletqt/rows/CoinsInfo.h"
#include "libwalletqt/Transfer.h"
#include "libwalletqt/rows/Output.h"
#include "libwalletqt/TransactionHistory.h"
#include "model/AddressBookModel.h"
#include "plugins/PluginRegistry.h"

View file

@ -10,8 +10,8 @@
#include "constants.h"
#include "dialog/QrCodeDialog.h"
#include "libwalletqt/Input.h"
#include "libwalletqt/Transfer.h"
#include "libwalletqt/rows/Input.h"
#include "libwalletqt/rows/Output.h"
#include "libwalletqt/WalletManager.h"
#include "qrcode/QrCode.h"
#include "utils/AppData.h"

View file

@ -12,7 +12,7 @@
#include "libwalletqt/Coins.h"
#include "libwalletqt/rows/CoinsInfo.h"
#include "libwalletqt/TransactionHistory.h"
#include "libwalletqt/Transfer.h"
#include "libwalletqt/rows/Output.h"
#include "libwalletqt/WalletManager.h"
#include "utils/Icons.h"
#include "utils/Utils.h"

View file

@ -6,7 +6,7 @@
#include <QMessageBox>
#include "libwalletqt/Transfer.h"
#include "libwalletqt/rows/Output.h"
#include "utils/Icons.h"
#include "utils/Utils.h"

View file

@ -13,21 +13,11 @@ AddressBook::AddressBook(tools::wallet2 *wallet2, QObject *parent)
this->refresh();
}
QString AddressBook::errorString() const
{
return m_errorString;
}
AddressBook::ErrorCode AddressBook::errorCode() const
{
return m_errorCode;
}
void AddressBook::refresh()
{
emit refreshStarted();
clearRows();
m_rows.clear();
for (const auto &row : m_wallet2->get_address_book()) {
std::string address;
@ -42,19 +32,24 @@ void AddressBook::refresh()
emit refreshFinished();
}
qsizetype AddressBook::count() const
{
return m_rows.length();
}
const ContactRow& AddressBook::getRow(const qsizetype index)
{
if (index < 0 || index >= m_rows.size()) {
throw std::out_of_range("Index out of range");
}
return m_rows[index];
}
const QList<ContactRow>& AddressBook::getRows()
{
return m_rows;
}
const ContactRow& AddressBook::getRow(const qsizetype i)
{
if (i < 0 || i >= m_rows.size()) {
throw std::out_of_range("Index out of range");
}
return m_rows[i];
}
bool AddressBook::addRow(const QString &address, const QString &description)
{
m_errorString = "";
@ -74,7 +69,7 @@ bool AddressBook::addRow(const QString &address, const QString &description)
return r;
}
bool AddressBook::setDescription(int index, const QString &description) {
bool AddressBook::setDescription(qsizetype index, const QString &description) {
m_errorString = "";
const auto ab = m_wallet2->get_address_book();
@ -92,20 +87,20 @@ bool AddressBook::setDescription(int index, const QString &description) {
return r;
}
bool AddressBook::deleteRow(int rowId)
bool AddressBook::deleteRow(qsizetype index)
{
bool r = m_wallet2->delete_address_book_row(rowId);
bool r = m_wallet2->delete_address_book_row(index);
if (r)
refresh();
return r;
}
qsizetype AddressBook::count() const
QString AddressBook::errorString() const
{
return m_rows.length();
return m_errorString;
}
void AddressBook::clearRows()
AddressBook::ErrorCode AddressBook::errorCode() const
{
m_rows.clear();
return m_errorCode;
}

View file

@ -1,8 +1,8 @@
// SPDX-License-Identifier: BSD-3-Clause
// SPDX-FileCopyrightText: The Monero Project
#ifndef ADDRESSBOOK_H
#define ADDRESSBOOK_H
#ifndef FEATHER_ADDRESSBOOK_H
#define FEATHER_ADDRESSBOOK_H
#include <QObject>
#include <QList>
@ -31,23 +31,22 @@ public:
};
Q_ENUM(ErrorCode);
void refresh();
qsizetype count() const;
const ContactRow& getRow(qsizetype index);
const QList<ContactRow>& getRows();
const ContactRow& getRow(qsizetype i);
bool addRow(const QString &address, const QString &description);
bool deleteRow(int rowId);
bool setDescription(int index, const QString &label);
qsizetype count() const;
bool setDescription(qsizetype index, const QString &description);
bool deleteRow(qsizetype index);
QString errorString() const;
ErrorCode errorCode() const;
void refresh();
void clearRows();
signals:
void refreshStarted() const;
void refreshFinished() const;
void descriptionChanged() const;
private:
explicit AddressBook(tools::wallet2 *wallet2, QObject *parent);
@ -60,4 +59,4 @@ private:
ErrorCode m_errorCode;
};
#endif // ADDRESSBOOK_H
#endif // FEATHER_ADDRESSBOOK_H

View file

@ -3,6 +3,7 @@
#include "Coins.h"
#include "rows/CoinsInfo.h"
#include "Wallet.h"
#include <wallet/wallet2.h>
Coins::Coins(Wallet *wallet, tools::wallet2 *wallet2, QObject *parent)
@ -13,19 +14,6 @@ Coins::Coins(Wallet *wallet, tools::wallet2 *wallet2, QObject *parent)
}
const QList<CoinsInfo>& Coins::getRows()
{
return m_rows;
}
const CoinsInfo& Coins::getRow(const qsizetype i)
{
if (i < 0 || i >= m_rows.size()) {
throw std::out_of_range("Index out of range");
}
return m_rows[i];
}
void Coins::refresh()
{
qDebug() << Q_FUNC_INFO;
@ -34,47 +22,41 @@ void Coins::refresh()
boost::shared_lock<boost::shared_mutex> transfers_lock(m_wallet2->m_transfers_mutex);
m_rows.clear();
for (size_t i = 0; i < m_wallet2->get_num_transfer_details(); ++i)
{
QWriteLocker locker(&m_lock);
const tools::wallet2::transfer_details &td = m_wallet2->get_transfer_details(i);
clearRows();
uint32_t account = m_wallet->currentSubaddressAccount();
for (size_t i = 0; i < m_wallet2->get_num_transfer_details(); ++i)
{
const tools::wallet2::transfer_details &td = m_wallet2->get_transfer_details(i);
if (td.m_subaddr_index.major != account) {
continue;
}
CoinsInfo ci;
ci.blockHeight = td.m_block_height;
ci.hash = QString::fromStdString(epee::string_tools::pod_to_hex(td.m_txid));
ci.internalOutputIndex = td.m_internal_output_index;
ci.globalOutputIndex = td.m_global_output_index;
ci.spent = td.m_spent;
ci.frozen = td.m_frozen;
ci.spentHeight = td.m_spent_height;
ci.amount = td.m_amount;
ci.rct = td.m_rct;
ci.keyImageKnown = td.m_key_image_known;
ci.pkIndex = td.m_pk_index;
ci.subaddrIndex = td.m_subaddr_index.minor;
ci.subaddrAccount = td.m_subaddr_index.major;
ci.address = QString::fromStdString(m_wallet2->get_subaddress_as_str(td.m_subaddr_index)); // todo: this is expensive, cache maybe?
ci.addressLabel = QString::fromStdString(m_wallet2->get_subaddress_label(td.m_subaddr_index));
ci.txNote = QString::fromStdString(m_wallet2->get_tx_note(td.m_txid));
ci.keyImage = QString::fromStdString(epee::string_tools::pod_to_hex(td.m_key_image));
ci.unlockTime = td.m_tx.unlock_time;
ci.unlocked = m_wallet2->is_transfer_unlocked(td);
ci.pubKey = QString::fromStdString(epee::string_tools::pod_to_hex(td.get_public_key()));
ci.coinbase = td.m_tx.vin.size() == 1 && td.m_tx.vin[0].type() == typeid(cryptonote::txin_gen);
ci.description = m_wallet->getCacheAttribute(QString("coin.description:%1").arg(ci.pubKey));
ci.change = m_wallet2->is_change(td);
m_rows.push_back(ci);
if (td.m_subaddr_index.major != m_wallet->currentSubaddressAccount()) {
continue;
}
CoinsInfo ci;
ci.blockHeight = td.m_block_height;
ci.hash = QString::fromStdString(epee::string_tools::pod_to_hex(td.m_txid));
ci.internalOutputIndex = td.m_internal_output_index;
ci.globalOutputIndex = td.m_global_output_index;
ci.spent = td.m_spent;
ci.frozen = td.m_frozen;
ci.spentHeight = td.m_spent_height;
ci.amount = td.m_amount;
ci.rct = td.m_rct;
ci.keyImageKnown = td.m_key_image_known;
ci.pkIndex = td.m_pk_index;
ci.subaddrIndex = td.m_subaddr_index.minor;
ci.subaddrAccount = td.m_subaddr_index.major;
ci.address = QString::fromStdString(m_wallet2->get_subaddress_as_str(td.m_subaddr_index)); // todo: this is expensive, cache maybe?
ci.addressLabel = QString::fromStdString(m_wallet2->get_subaddress_label(td.m_subaddr_index));
ci.txNote = QString::fromStdString(m_wallet2->get_tx_note(td.m_txid));
ci.keyImage = QString::fromStdString(epee::string_tools::pod_to_hex(td.m_key_image));
ci.unlockTime = td.m_tx.unlock_time;
ci.unlocked = m_wallet2->is_transfer_unlocked(td);
ci.pubKey = QString::fromStdString(epee::string_tools::pod_to_hex(td.get_public_key()));
ci.coinbase = td.m_tx.vin.size() == 1 && td.m_tx.vin[0].type() == typeid(cryptonote::txin_gen);
ci.description = m_wallet->getCacheAttribute(QString("coin.description:%1").arg(ci.pubKey));
ci.change = m_wallet2->is_change(td);
m_rows.push_back(ci);
}
emit refreshFinished();
@ -82,8 +64,6 @@ void Coins::refresh()
void Coins::refreshUnlocked()
{
QWriteLocker locker(&m_lock);
for (CoinsInfo& c : m_rows) {
if (!c.unlocked) {
bool unlocked = m_wallet2->is_transfer_unlocked(c.unlockTime, c.blockHeight);
@ -94,11 +74,29 @@ void Coins::refreshUnlocked()
quint64 Coins::count() const
{
QReadLocker locker(&m_lock);
return m_rows.length();
}
const CoinsInfo& Coins::getRow(const qsizetype i)
{
if (i < 0 || i >= m_rows.size()) {
throw std::out_of_range("Index out of range");
}
return m_rows[i];
}
const QList<CoinsInfo>& Coins::getRows()
{
return m_rows;
}
void Coins::setDescription(const QString &publicKey, quint32 accountIndex, const QString &description)
{
m_wallet->setCacheAttribute(QString("coin.description:%1").arg(publicKey), description);
this->refresh();
emit descriptionChanged();
}
void Coins::freeze(QStringList &publicKeys)
{
crypto::public_key pk;
@ -163,14 +161,3 @@ quint64 Coins::sumAmounts(const QStringList &keyImages) {
return amount;
}
void Coins::setDescription(const QString &publicKey, quint32 accountIndex, const QString &description)
{
m_wallet->setCacheAttribute(QString("coin.description:%1").arg(publicKey), description);
this->refresh();
emit descriptionChanged();
}
void Coins::clearRows() {
m_rows.clear();
}

View file

@ -8,8 +8,6 @@
#include <QList>
#include <QReadWriteLock>
#include "Wallet.h"
namespace Monero {
struct TransactionHistory;
}
@ -19,27 +17,23 @@ namespace tools {
}
class CoinsInfo;
class Wallet;
class Coins : public QObject
{
Q_OBJECT
public:
const QList<CoinsInfo>& getRows();
const CoinsInfo& getRow(qsizetype i);
void refresh();
void refreshUnlocked();
quint64 count() const;
void freeze(QStringList &publicKeys);
void thaw(QStringList &publicKeys);
quint64 sumAmounts(const QStringList &keyImages);
const CoinsInfo& getRow(qsizetype i);
const QList<CoinsInfo>& getRows();
void setDescription(const QString &publicKey, quint32 accountIndex, const QString &description);
quint64 count() const;
void clearRows();
void freeze(QStringList &publicKeys);
void thaw(QStringList &publicKeys);
quint64 sumAmounts(const QStringList &keyImages);
signals:
void refreshStarted() const;
@ -48,15 +42,11 @@ signals:
private:
explicit Coins(Wallet *wallet, tools::wallet2 *wallet2, QObject *parent = nullptr);
private:
friend class Wallet;
Wallet *m_wallet;
tools::wallet2 *m_wallet2;
QList<CoinsInfo> m_rows;
mutable QReadWriteLock m_lock;
};
#endif //FEATHER_COINS_H

View file

@ -1,8 +1,8 @@
// SPDX-License-Identifier: BSD-3-Clause
// SPDX-FileCopyrightText: The Monero Project
#ifndef MONERO_GUI_PASSPHRASEHELPER_H
#define MONERO_GUI_PASSPHRASEHELPER_H
#ifndef FEATHER_PASSPHRASEHELPER_H
#define FEATHER_PASSPHRASEHELPER_H
#include <QMutex>
#include <QPointer>
@ -43,4 +43,4 @@ private:
};
#endif //MONERO_GUI_PASSPHRASEHELPER_H
#endif //FEATHER_PASSPHRASEHELPER_H

View file

@ -1,13 +1,13 @@
// SPDX-License-Identifier: BSD-3-Clause
// SPDX-FileCopyrightText: The Monero Project
#ifndef PENDINGTRANSACTION_H
#define PENDINGTRANSACTION_H
#ifndef FEATHER_PENDINGTRANSACTION_H
#define FEATHER_PENDINGTRANSACTION_H
#include <QObject>
#include <QList>
#include "PendingTransactionInfo.h"
#include "rows/PendingTransactionInfo.h"
namespace Monero {
class PendingTransaction;
@ -53,4 +53,4 @@ private:
mutable QList<PendingTransactionInfo> m_pending_tx_info;
};
#endif // PENDINGTRANSACTION_H
#endif // FEATHER_PENDINGTRANSACTION_H

View file

@ -3,6 +3,7 @@
#include "Subaddress.h"
#include "Wallet.h"
#include <wallet/wallet2.h>
Subaddress::Subaddress(Wallet *wallet, tools::wallet2 *wallet2, QObject *parent)
@ -17,9 +18,65 @@ Subaddress::Subaddress(Wallet *wallet, tools::wallet2 *wallet2, QObject *parent)
m_hidden = hidden.split(",");
}
const QList<SubaddressRow>& Subaddress::getRows()
bool Subaddress::refresh(quint32 accountIndex)
{
return m_rows;
emit refreshStarted();
m_rows.clear();
bool potentialWalletFileCorruption = false;
for (quint32 i = 0; i < m_wallet2->get_num_subaddresses(accountIndex); ++i)
{
cryptonote::subaddress_index index = {accountIndex, i};
cryptonote::account_public_address address = m_wallet2->get_subaddress(index);
// Make sure we have previously generated Di
auto idx = m_wallet2->get_subaddress_index(address);
if (!idx) {
potentialWalletFileCorruption = true;
break;
}
// Verify mapping
if (idx != index) {
potentialWalletFileCorruption = true;
break;
}
QString addressStr = QString::fromStdString(cryptonote::get_account_address_as_str(m_wallet2->nettype(), !index.is_zero(), address));
m_rows.emplace_back(
addressStr,
QString::fromStdString(m_wallet2->get_subaddress_label(index)),
m_wallet2->get_subaddress_used({accountIndex, (uint32_t)i}),
this->isHidden(addressStr),
this->isPinned(addressStr)
);
}
// Make sure keys are intact. We NEVER want to display incorrect addresses in case of memory corruption.
potentialWalletFileCorruption = potentialWalletFileCorruption || (m_wallet2->get_device_type() == hw::device::SOFTWARE && !m_wallet2->verify_keys());
if (potentialWalletFileCorruption) {
LOG_ERROR("KEY INCONSISTENCY DETECTED, WALLET IS IN CORRUPT STATE.");
m_rows.clear();
emit corrupted();
}
emit refreshFinished();
return !potentialWalletFileCorruption;
}
qsizetype Subaddress::count() const
{
return m_rows.length();
}
const SubaddressRow& Subaddress::row(int index) const
{
return m_rows[index];
}
const SubaddressRow& Subaddress::getRow(const qsizetype i)
@ -30,6 +87,11 @@ const SubaddressRow& Subaddress::getRow(const qsizetype i)
return m_rows[i];
}
const QList<SubaddressRow>& Subaddress::getRows()
{
return m_rows;
}
bool Subaddress::addRow(quint32 accountIndex, const QString &label)
{
// This can fail if hardware device is unplugged during operating, catch here to prevent crash
@ -85,12 +147,7 @@ bool Subaddress::setHidden(const QString &address, bool hidden)
return r;
}
bool Subaddress::isHidden(const QString &address)
{
return m_hidden.contains(address);
}
bool Subaddress::setPinned(const QString &address, bool pinned)
bool Subaddress::setPinned(const QString &address, bool pinned)
{
if (pinned) {
if (m_pinned.contains(address)) {
@ -104,82 +161,23 @@ bool Subaddress::setPinned(const QString &address, bool pinned)
}
m_pinned.removeAll(address);
}
bool r = m_wallet->setCacheAttribute("feather.pinnedaddresses", m_pinned.join(","));
refresh(m_wallet->currentSubaddressAccount());
return r;
}
bool Subaddress::isHidden(const QString &address)
{
return m_hidden.contains(address);
}
bool Subaddress::isPinned(const QString &address)
{
return m_pinned.contains(address);
}
bool Subaddress::refresh(quint32 accountIndex)
{
emit refreshStarted();
this->clearRows();
bool potentialWalletFileCorruption = false;
for (quint32 i = 0; i < m_wallet2->get_num_subaddresses(accountIndex); ++i)
{
cryptonote::subaddress_index index = {accountIndex, i};
cryptonote::account_public_address address = m_wallet2->get_subaddress(index);
// Make sure we have previously generated Di
auto idx = m_wallet2->get_subaddress_index(address);
if (!idx) {
potentialWalletFileCorruption = true;
break;
}
// Verify mapping
if (idx != index) {
potentialWalletFileCorruption = true;
break;
}
QString addressStr = QString::fromStdString(cryptonote::get_account_address_as_str(m_wallet2->nettype(), !index.is_zero(), address));
m_rows.emplace_back(
addressStr,
QString::fromStdString(m_wallet2->get_subaddress_label(index)),
m_wallet2->get_subaddress_used({accountIndex, (uint32_t)i}),
this->isHidden(addressStr),
this->isPinned(addressStr)
);
}
// Make sure keys are intact. We NEVER want to display incorrect addresses in case of memory corruption.
potentialWalletFileCorruption = potentialWalletFileCorruption || (m_wallet2->get_device_type() == hw::device::SOFTWARE && !m_wallet2->verify_keys());
if (potentialWalletFileCorruption) {
LOG_ERROR("KEY INCONSISTENCY DETECTED, WALLET IS IN CORRUPT STATE.");
clearRows();
emit corrupted();
}
emit refreshFinished();
return !potentialWalletFileCorruption;
}
qsizetype Subaddress::count() const
{
return m_rows.length();
}
void Subaddress::clearRows() {
m_rows.clear();
}
const SubaddressRow& Subaddress::row(int index) const {
return m_rows[index];
}
QString Subaddress::getError() const {
return m_errorString;
}

View file

@ -5,42 +5,33 @@
#define SUBADDRESS_H
#include <QObject>
#include <QReadWriteLock>
#include <QList>
#include <QDateTime>
#include <QString>
#include "Wallet.h"
#include "rows/SubaddressRow.h"
namespace tools {
class wallet2;
}
class Wallet;
class Subaddress : public QObject
{
Q_OBJECT
public:
const QList<SubaddressRow>& getRows();
const SubaddressRow& getRow(qsizetype i);
bool addRow(quint32 accountIndex, const QString &label);
bool setLabel(quint32 accountIndex, quint32 addressIndex, const QString &label);
bool setHidden(const QString& address, bool hidden);
bool isHidden(const QString& address);
bool isHidden(const SubaddressRow& row);
bool setPinned(const QString& address, bool pinned);
bool isPinned(const QString& address);
bool refresh(quint32 accountIndex);
[[nodiscard]] qsizetype count() const;
void clearRows();
const SubaddressRow& row(int index) const;
const SubaddressRow& getRow(qsizetype i);
const QList<SubaddressRow>& getRows();
bool addRow(quint32 accountIndex, const QString &label);
bool setLabel(quint32 accountIndex, quint32 addressIndex, const QString &label);
bool setHidden(const QString& address, bool hidden);
bool setPinned(const QString& address, bool pinned);
bool isHidden(const QString& address);
bool isPinned(const QString& address);
QString getError() const;

View file

@ -10,23 +10,11 @@ SubaddressAccount::SubaddressAccount(tools::wallet2 *wallet2, QObject *parent)
{
}
void SubaddressAccount::addRow(const QString &label)
{
m_wallet2->add_subaddress_account(label.toStdString());
refresh();
}
void SubaddressAccount::setLabel(quint32 accountIndex, const QString &label)
{
m_wallet2->set_subaddress_label({accountIndex, 0}, label.toStdString());
refresh();
}
void SubaddressAccount::refresh()
{
emit refreshStarted();
this->clearRows();
m_rows.clear();
for (uint32_t i = 0; i < m_wallet2->get_num_subaddress_accounts(); ++i)
{
@ -45,16 +33,6 @@ qsizetype SubaddressAccount::count() const
return m_rows.length();
}
void SubaddressAccount::clearRows()
{
m_rows.clear();
}
const QList<AccountRow>& SubaddressAccount::getRows()
{
return m_rows;
}
const AccountRow& SubaddressAccount::row(const int index) const
{
if (index < 0 || index >= m_rows.size()) {
@ -62,3 +40,20 @@ const AccountRow& SubaddressAccount::row(const int index) const
}
return m_rows[index];
}
const QList<AccountRow>& SubaddressAccount::getRows()
{
return m_rows;
}
void SubaddressAccount::addRow(const QString &label)
{
m_wallet2->add_subaddress_account(label.toStdString());
refresh();
}
void SubaddressAccount::setLabel(quint32 accountIndex, const QString &label)
{
m_wallet2->set_subaddress_label({accountIndex, 0}, label.toStdString());
refresh();
}

View file

@ -1,8 +1,8 @@
// SPDX-License-Identifier: BSD-3-Clause
// SPDX-FileCopyrightText: The Monero Project
#ifndef SUBADDRESSACCOUNT_H
#define SUBADDRESSACCOUNT_H
#ifndef FEATHER_SUBADDRESSACCOUNT_H
#define FEATHER_SUBADDRESSACCOUNT_H
#include <QObject>
#include <QList>
@ -18,15 +18,14 @@ class SubaddressAccount : public QObject
Q_OBJECT
public:
const QList<AccountRow>& getRows();
void refresh();
qsizetype count() const;
const AccountRow& row(int index) const;
const QList<AccountRow>& getRows();
void addRow(const QString &label);
void setLabel(quint32 accountIndex, const QString &label);
qsizetype count() const;
void refresh();
void clearRows();
signals:
void refreshStarted() const;
@ -40,4 +39,4 @@ private:
QList<AccountRow> m_rows;
};
#endif // SUBADDRESSACCOUNT_H
#endif // FEATHER_SUBADDRESSACCOUNT_H

View file

@ -6,10 +6,20 @@
#include "utils/AppData.h"
#include "utils/config.h"
#include "constants.h"
#include "Wallet.h"
#include "WalletManager.h"
#include "Transfer.h"
#include "rows/Output.h"
#include "wallet/wallet2.h"
TransactionHistory::TransactionHistory(Wallet *wallet, tools::wallet2 *wallet2, QObject *parent)
: QObject(parent)
, m_wallet(wallet)
, m_wallet2(wallet2)
, m_locked(false)
{
}
QString description(tools::wallet2 *wallet2, const tools::wallet2::payment_details &pd)
{
QString description = QString::fromStdString(wallet2->get_tx_note(pd.m_tx_hash));
@ -27,37 +37,20 @@ QString description(tools::wallet2 *wallet2, const tools::wallet2::payment_detai
return description;
}
const TransactionRow& TransactionHistory::transaction(int index)
{
if (index < 0 || index >= m_rows.size()) {
throw std::out_of_range("Index out of range");
}
return m_rows[index];
}
const QList<TransactionRow>& TransactionHistory::getRows()
{
return m_rows;
}
void TransactionHistory::refresh()
{
qDebug() << Q_FUNC_INFO;
QDateTime firstDateTime = QDate(2014, 4, 18).startOfDay();
QDateTime lastDateTime = QDateTime::currentDateTime().addDays(1); // tomorrow (guard against jitter and timezones)
emit refreshStarted();
{
QWriteLocker locker(&m_lock);
clearRows();
m_rows.clear();
quint64 lastTxHeight = 0;
bool hasFakePaymentId = m_wallet->isTrezor();
m_locked = false;
m_minutesToUnlock = 0;
uint64_t min_height = 0;
uint64_t max_height = (uint64_t)-1;
@ -264,6 +257,26 @@ void TransactionHistory::refresh()
emit refreshFinished();
}
quint64 TransactionHistory::count() const
{
QReadLocker locker(&m_lock);
return m_rows.length();
}
const TransactionRow& TransactionHistory::transaction(int index)
{
if (index < 0 || index >= m_rows.size()) {
throw std::out_of_range("Index out of range");
}
return m_rows[index];
}
const QList<TransactionRow>& TransactionHistory::getRows()
{
return m_rows;
}
void TransactionHistory::setTxNote(const QString &txid, const QString &note)
{
cryptonote::blobdata txid_data;
@ -278,53 +291,11 @@ void TransactionHistory::setTxNote(const QString &txid, const QString &note)
emit txNoteChanged();
}
quint64 TransactionHistory::count() const
{
QReadLocker locker(&m_lock);
return m_rows.length();
}
QDateTime TransactionHistory::firstDateTime() const
{
return m_firstDateTime;
}
QDateTime TransactionHistory::lastDateTime() const
{
return m_lastDateTime;
}
quint64 TransactionHistory::minutesToUnlock() const
{
return m_minutesToUnlock;
}
bool TransactionHistory::TransactionHistory::locked() const
bool TransactionHistory::locked() const
{
return m_locked;
}
TransactionHistory::TransactionHistory(Wallet *wallet, tools::wallet2 *wallet2, QObject *parent)
: QObject(parent)
, m_wallet(wallet)
, m_wallet2(wallet2)
, m_minutesToUnlock(0)
, m_locked(false)
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
m_firstDateTime = QDate(2014, 4, 18).startOfDay();
#else
m_firstDateTime = QDateTime(QDate(2014, 4, 18)); // the genesis block
#endif
m_lastDateTime = QDateTime::currentDateTime().addDays(1); // tomorrow (guard against jitter and timezones)
}
void TransactionHistory::clearRows() {
m_rows.clear();
}
QStringList parseCSVLine(const QString &line) {
QStringList result;
QString currentField;

View file

@ -1,18 +1,12 @@
// SPDX-License-Identifier: BSD-3-Clause
// SPDX-FileCopyrightText: The Monero Project
#ifndef TRANSACTIONHISTORY_H
#define TRANSACTIONHISTORY_H
#ifndef FEATHER_TRANSACTIONHISTORY_H
#define FEATHER_TRANSACTIONHISTORY_H
#include <functional>
#include <QObject>
#include <QList>
#include <QReadWriteLock>
#include <QDateTime>
#include "rows/TransactionRow.h"
#include "Wallet.h"
namespace tools {
class wallet2;
@ -23,23 +17,20 @@ struct TransactionHistory;
}
class TransactionInfo;
class Wallet;
class TransactionHistory : public QObject
{
Q_OBJECT
public:
void refresh();
quint64 count() const;
const TransactionRow& transaction(int index);
const QList<TransactionRow>& getRows();
void refresh();
void setTxNote(const QString &txid, const QString &note);
quint64 count() const;
QDateTime firstDateTime() const;
QDateTime lastDateTime() const;
quint64 minutesToUnlock() const;
bool locked() const;
void clearRows();
QString importLabelsFromCSV(const QString &fileName);
@ -70,4 +61,4 @@ private:
quint32 lastAccountIndex = 0;
};
#endif // TRANSACTIONHISTORY_H
#endif // FEATHER_TRANSACTIONHISTORY_H

View file

@ -1,17 +0,0 @@
// SPDX-License-Identifier: BSD-3-Clause
// SPDX-FileCopyrightText: The Monero Project
#ifndef TRANSFER_H
#define TRANSFER_H
struct Transfer
{
QString address;
quint64 amount;
explicit Transfer(uint64_t amount_, QString address_)
: address(std::move(address_))
, amount(amount_) {}
};
#endif // TRANSFER_H

View file

@ -3,7 +3,7 @@
#include "UnsignedTransaction.h"
#include "ConstructionInfo.h"
#include "rows/ConstructionInfo.h"
#include <wallet/api/wallet2_api.h>
UnsignedTransaction::Status UnsignedTransaction::status() const

View file

@ -1,8 +1,8 @@
// SPDX-License-Identifier: BSD-3-Clause
// SPDX-FileCopyrightText: The Monero Project
#ifndef UNSIGNEDTRANSACTION_H
#define UNSIGNEDTRANSACTION_H
#ifndef FEATHER_UNSIGNEDTRANSACTION_H
#define FEATHER_UNSIGNEDTRANSACTION_H
#include <QObject>
@ -54,4 +54,4 @@ private:
mutable QList<ConstructionInfo> m_construction_info;
};
#endif // UNSIGNEDTRANSACTION_H
#endif // FEATHER_UNSIGNEDTRANSACTION_H

View file

@ -1,8 +1,8 @@
// SPDX-License-Identifier: BSD-3-Clause
// SPDX-FileCopyrightText: The Monero Project
#ifndef WALLET_H
#define WALLET_H
#ifndef FEATHER_WALLET_H
#define FEATHER_WALLET_H
#include <QObject>
#include <QMutex>
@ -533,4 +533,4 @@ private:
std::set<std::string> m_selectedInputs;
};
#endif // WALLET_H
#endif // FEATHER_WALLET_H

View file

@ -1,8 +1,8 @@
// SPDX-License-Identifier: BSD-3-Clause
// SPDX-FileCopyrightText: The Monero Project
#ifndef MONERO_GUI_WALLETLISTENERIMPL_H
#define MONERO_GUI_WALLETLISTENERIMPL_H
#ifndef FEATHER_WALLETLISTENERIMPL_H
#define FEATHER_WALLETLISTENERIMPL_H
#include "wallet/api/wallet2_api.h"
#include "PassphraseHelper.h"
@ -14,32 +14,32 @@ class WalletListenerImpl : public Monero::WalletListener, public PassphraseRecei
public:
WalletListenerImpl(Wallet * w);
virtual void moneySpent(const std::string &txId, uint64_t amount) override;
void moneySpent(const std::string &txId, uint64_t amount) override;
virtual void moneyReceived(const std::string &txId, uint64_t amount, bool coinbase) override;
void moneyReceived(const std::string &txId, uint64_t amount, bool coinbase) override;
virtual void unconfirmedMoneyReceived(const std::string &txId, uint64_t amount) override;
void unconfirmedMoneyReceived(const std::string &txId, uint64_t amount) override;
virtual void newBlock(uint64_t height) override;
void newBlock(uint64_t height) override;
virtual void updated() override;
void updated() override;
// called when wallet refreshed by background thread or explicitly
virtual void refreshed(bool success) override;
void refreshed(bool success) override;
virtual void onDeviceButtonRequest(uint64_t code) override;
void onDeviceButtonRequest(uint64_t code) override;
virtual void onDeviceButtonPressed() override;
void onDeviceButtonPressed() override;
virtual void onDeviceError(const std::string &message, unsigned int error_code) override;
void onDeviceError(const std::string &message, unsigned int error_code) override;
virtual void onPassphraseEntered(const QString &passphrase, bool enter_on_device, bool entry_abort) override;
void onPassphraseEntered(const QString &passphrase, bool enter_on_device, bool entry_abort) override;
virtual std::optional<std::string> onDevicePassphraseRequest(bool & on_device) override;
std::optional<std::string> onDevicePassphraseRequest(bool & on_device) override;
private:
Wallet * m_wallet;
PassphraseHelper m_phelper;
};
#endif //MONERO_GUI_WALLETLISTENERIMPL_H
#endif //FEATHER_WALLETLISTENERIMPL_H

View file

@ -1,8 +1,8 @@
// SPDX-License-Identifier: BSD-3-Clause
// SPDX-FileCopyrightText: The Monero Project
#ifndef WALLETMANAGER_H
#define WALLETMANAGER_H
#ifndef FEATHER_WALLETMANAGER_H
#define FEATHER_WALLETMANAGER_H
#include <QObject>
#include <QMutex>
@ -138,4 +138,4 @@ private:
FutureScheduler m_scheduler;
};
#endif // WALLETMANAGER_H
#endif // FEATHER_WALLETMANAGER_H

View file

@ -13,11 +13,11 @@ struct AccountRow
quint64 balance;
quint64 unlockedBalance;
AccountRow(const QString& address_, const QString &label_, uint64_t balance_, uint64_t unlockedBalance_)
: address(address_)
, label(label_)
, balance(balance_)
, unlockedBalance(unlockedBalance_) {}
AccountRow(const QString& address, const QString &label, uint64_t balance, uint64_t unlockedBalance)
: address(address)
, label(label)
, balance(balance)
, unlockedBalance(unlockedBalance) {}
};
#endif //FEATHER_ACCOUNTROW_H

View file

@ -2,9 +2,6 @@
// SPDX-FileCopyrightText: The Monero Project
#include "ConstructionInfo.h"
#include "Input.h"
#include "Transfer.h"
#include <wallet/api/wallet2_api.h>
ConstructionInfo::ConstructionInfo(const Monero::TransactionConstructionInfo *pimpl)

View file

@ -6,7 +6,7 @@
#include <QSet>
#include "Transfer.h"
#include "Output.h"
#include "Input.h"
namespace Monero {
@ -20,7 +20,7 @@ struct ConstructionInfo
QVector<QString> subaddresses;
quint64 minMixinCount;
QList<Input> inputs;
QList<Transfer> outputs;
QList<Output> outputs;
explicit ConstructionInfo(const Monero::TransactionConstructionInfo *pimpl);
};

View file

@ -11,9 +11,9 @@ struct ContactRow
QString address;
QString label;
ContactRow(const QString address_, const QString &label_)
: address(address_)
, label(label_) {}
ContactRow(const QString address, const QString& label)
: address(address)
, label(label) {}
};
#endif //FEATHER_CONTACTROW_H

View file

@ -9,9 +9,9 @@ struct Input
QString pubKey;
quint64 amount;
explicit Input(uint64_t _amount, QString _pubkey)
: pubKey(std::move(_pubkey))
, amount(_amount) {}
explicit Input(uint64_t amount, QString pubkey)
: pubKey(std::move(pubkey))
, amount(amount) {}
};
#endif //FEATHER_INPUT_H

View file

@ -0,0 +1,17 @@
// SPDX-License-Identifier: BSD-3-Clause
// SPDX-FileCopyrightText: The Monero Project
#ifndef FEATHER_TRANSFER_H
#define FEATHER_TRANSFER_H
struct Output
{
QString address;
quint64 amount;
explicit Output(uint64_t amount, QString address)
: address(std::move(address))
, amount(amount) {}
};
#endif // FEATHER_TRANSFER_H

View file

@ -6,7 +6,7 @@
#include "ConstructionInfo.h"
#include <QObject>
#include <QString>
namespace Monero {
class PendingTransactionInfo;

View file

@ -14,12 +14,12 @@ struct SubaddressRow
bool hidden = false;
bool pinned = false;
SubaddressRow(const QString& address_, const QString &label_, bool used_, bool hidden_, bool pinned_)
: address(address_)
, label(label_)
, used(used_)
, hidden(hidden_)
, pinned(pinned_) {}
SubaddressRow(const QString& address, const QString &label, bool used, bool hidden, bool pinned)
: address(address)
, label(label)
, used(used)
, hidden(hidden)
, pinned(pinned) {}
};
#endif //FEATHER_SUBADDRESSROW_H

View file

@ -3,7 +3,7 @@
#include "TransactionRow.h"
#include "WalletManager.h"
#include "Transfer.h"
#include "Output.h"
TransactionRow::TransactionRow()
: amount(0)

View file

@ -12,11 +12,11 @@ struct Ring
QString keyImage;
std::vector<uint64_t> ringMembers;
explicit Ring(QString _keyImage, std::vector<uint64_t> _ringMembers)
: keyImage(std::move(_keyImage))
, ringMembers(std::move(_ringMembers)) {}
explicit Ring(QString keyImage, std::vector<uint64_t> ringMembers)
: keyImage(std::move(keyImage))
, ringMembers(std::move(ringMembers)) {}
};
struct Transfer;
struct Output;
struct TransactionRow
{
@ -26,7 +26,7 @@ struct TransactionRow
Direction_Both // invalid direction value, used for filtering
};
QList<Transfer> transfers;
QList<Output> transfers;
QList<Ring> rings;
qint64 amount; // Amount that was sent (to destinations) or received, excludes tx fee
qint64 balanceDelta; // How much the total balance was mutated as a result of this tx (includes tx fee)