#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"
#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"
#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"
#include <QMessageBox>
-#include "libwalletqt/Transfer.h"
+#include "libwalletqt/rows/Output.h"
#include "utils/Icons.h"
#include "utils/Utils.h"
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;
emit refreshFinished();
}
-const QList<ContactRow>& AddressBook::getRows()
+qsizetype AddressBook::count() const
{
- return m_rows;
+ return m_rows.length();
}
-const ContactRow& AddressBook::getRow(const qsizetype i)
+const ContactRow& AddressBook::getRow(const qsizetype index)
{
- if (i < 0 || i >= m_rows.size()) {
+ if (index < 0 || index >= m_rows.size()) {
throw std::out_of_range("Index out of range");
}
- return m_rows[i];
+ return m_rows[index];
+}
+
+const QList<ContactRow>& AddressBook::getRows()
+{
+ return m_rows;
}
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();
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;
}
// 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>
};
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);
ErrorCode m_errorCode;
};
-#endif // ADDRESSBOOK_H
+#endif // FEATHER_ADDRESSBOOK_H
#include "Coins.h"
#include "rows/CoinsInfo.h"
+#include "Wallet.h"
#include <wallet/wallet2.h>
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;
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);
-
- clearRows();
- uint32_t account = m_wallet->currentSubaddressAccount();
+ const tools::wallet2::transfer_details &td = m_wallet2->get_transfer_details(i);
- 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();
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);
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;
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();
-}
#include <QList>
#include <QReadWriteLock>
-#include "Wallet.h"
-
namespace Monero {
struct TransactionHistory;
}
}
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;
+
+ const CoinsInfo& getRow(qsizetype i);
+ const QList<CoinsInfo>& getRows();
+ void setDescription(const QString &publicKey, quint32 accountIndex, const QString &description);
void freeze(QStringList &publicKeys);
void thaw(QStringList &publicKeys);
-
quint64 sumAmounts(const QStringList &keyImages);
- void setDescription(const QString &publicKey, quint32 accountIndex, const QString &description);
-
- quint64 count() const;
- void clearRows();
-
signals:
void refreshStarted() const;
void refreshFinished() const;
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
// 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>
};
-#endif //MONERO_GUI_PASSPHRASEHELPER_H
+#endif //FEATHER_PASSPHRASEHELPER_H
// 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;
mutable QList<PendingTransactionInfo> m_pending_tx_info;
};
-#endif // PENDINGTRANSACTION_H
+#endif // FEATHER_PENDINGTRANSACTION_H
#include "Subaddress.h"
+#include "Wallet.h"
#include <wallet/wallet2.h>
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)
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
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)) {
}
m_pinned.removeAll(address);
}
-
+
bool r = m_wallet->setCacheAttribute("feather.pinnedaddresses", m_pinned.join(","));
refresh(m_wallet->currentSubaddressAccount());
return r;
}
-bool Subaddress::isPinned(const QString &address)
-{
- return m_pinned.contains(address);
-}
-
-bool Subaddress::refresh(quint32 accountIndex)
+bool Subaddress::isHidden(const QString &address)
{
- 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;
+ return m_hidden.contains(address);
}
-qsizetype Subaddress::count() const
+bool Subaddress::isPinned(const QString &address)
{
- return m_rows.length();
-}
-
-void Subaddress::clearRows() {
- m_rows.clear();
-}
-
-const SubaddressRow& Subaddress::row(int index) const {
- return m_rows[index];
+ return m_pinned.contains(address);
}
QString Subaddress::getError() const {
#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();
+ bool refresh(quint32 accountIndex);
+ [[nodiscard]] qsizetype count() const;
+
+ 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 isHidden(const QString& address);
- bool isHidden(const SubaddressRow& row);
-
bool setPinned(const QString& address, bool pinned);
+ bool isHidden(const QString& address);
bool isPinned(const QString& address);
-
- bool refresh(quint32 accountIndex);
-
- [[nodiscard]] qsizetype count() const;
- void clearRows();
-
- const SubaddressRow& row(int index) const;
QString getError() const;
{
}
-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)
{
return m_rows.length();
}
-void SubaddressAccount::clearRows()
+const AccountRow& SubaddressAccount::row(const int index) const
{
- m_rows.clear();
+ if (index < 0 || index >= m_rows.size()) {
+ throw std::out_of_range("Index out of range");
+ }
+ return m_rows[index];
}
const QList<AccountRow>& SubaddressAccount::getRows()
return m_rows;
}
-const AccountRow& SubaddressAccount::row(const int index) const
+void SubaddressAccount::addRow(const QString &label)
{
- if (index < 0 || index >= m_rows.size()) {
- throw std::out_of_range("Index out of range");
- }
- return m_rows[index];
+ 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();
}
// 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>
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;
QList<AccountRow> m_rows;
};
-#endif // SUBADDRESSACCOUNT_H
+#endif // FEATHER_SUBADDRESSACCOUNT_H
#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));
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;
emit refreshFinished();
}
-void TransactionHistory::setTxNote(const QString &txid, const QString ¬e)
-{
- cryptonote::blobdata txid_data;
- if (!epee::string_tools::parse_hexstr_to_binbuff(txid.toStdString(), txid_data) || txid_data.size() != sizeof(crypto::hash)) {
- qDebug() << Q_FUNC_INFO << "invalid txid";
- return;
- }
-
- const crypto::hash htxid = *reinterpret_cast<const crypto::hash*>(txid_data.data());
-
- m_wallet2->set_tx_note(htxid, note.toStdString());
- 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
+const TransactionRow& TransactionHistory::transaction(int index)
{
- return m_lastDateTime;
+ if (index < 0 || index >= m_rows.size()) {
+ throw std::out_of_range("Index out of range");
+ }
+ return m_rows[index];
}
-quint64 TransactionHistory::minutesToUnlock() const
+const QList<TransactionRow>& TransactionHistory::getRows()
{
- return m_minutesToUnlock;
+ return m_rows;
}
-bool TransactionHistory::TransactionHistory::locked() const
+void TransactionHistory::setTxNote(const QString &txid, const QString ¬e)
{
- return m_locked;
-}
+ cryptonote::blobdata txid_data;
+ if (!epee::string_tools::parse_hexstr_to_binbuff(txid.toStdString(), txid_data) || txid_data.size() != sizeof(crypto::hash)) {
+ qDebug() << Q_FUNC_INFO << "invalid txid";
+ return;
+ }
+ const crypto::hash htxid = *reinterpret_cast<const crypto::hash*>(txid_data.data());
-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)
+ m_wallet2->set_tx_note(htxid, note.toStdString());
+ emit txNoteChanged();
}
-void TransactionHistory::clearRows() {
- m_rows.clear();
+bool TransactionHistory::locked() const
+{
+ return m_locked;
}
QStringList parseCSVLine(const QString &line) {
// 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;
}
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 ¬e);
- quint64 count() const;
- QDateTime firstDateTime() const;
- QDateTime lastDateTime() const;
- quint64 minutesToUnlock() const;
bool locked() const;
- void clearRows();
QString importLabelsFromCSV(const QString &fileName);
quint32 lastAccountIndex = 0;
};
-#endif // TRANSACTIONHISTORY_H
+#endif // FEATHER_TRANSACTIONHISTORY_H
+++ /dev/null
-// 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
#include "UnsignedTransaction.h"
-#include "ConstructionInfo.h"
+#include "rows/ConstructionInfo.h"
#include <wallet/api/wallet2_api.h>
UnsignedTransaction::Status UnsignedTransaction::status() const
// 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>
mutable QList<ConstructionInfo> m_construction_info;
};
-#endif // UNSIGNEDTRANSACTION_H
+#endif // FEATHER_UNSIGNEDTRANSACTION_H
// 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>
std::set<std::string> m_selectedInputs;
};
-#endif // WALLET_H
+#endif // FEATHER_WALLET_H
// 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"
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
// 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>
FutureScheduler m_scheduler;
};
-#endif // WALLETMANAGER_H
+#endif // FEATHER_WALLETMANAGER_H
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
// 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)
#include <QSet>
-#include "Transfer.h"
+#include "Output.h"
#include "Input.h"
namespace Monero {
QVector<QString> subaddresses;
quint64 minMixinCount;
QList<Input> inputs;
- QList<Transfer> outputs;
+ QList<Output> outputs;
explicit ConstructionInfo(const Monero::TransactionConstructionInfo *pimpl);
};
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
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
--- /dev/null
+// 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
#include "ConstructionInfo.h"
-#include <QObject>
+#include <QString>
namespace Monero {
class PendingTransactionInfo;
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
#include "TransactionRow.h"
#include "WalletManager.h"
-#include "Transfer.h"
+#include "Output.h"
TransactionRow::TransactionRow()
: amount(0)
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
{
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)