build: remove needless wallet2.h includes

This commit is contained in:
tobtoht 2024-01-05 02:21:51 +01:00
parent c247962c21
commit 06d3c864af
No known key found for this signature in database
GPG key ID: E45B10DD027D2472
14 changed files with 23 additions and 75 deletions

2
monero

@ -1 +1 @@
Subproject commit 34aacb1b49553f17b9bb7ca1ee6dfb6524aada55 Subproject commit fedd2d2238c88a221b547b9fe2738dc0c18c5195

View file

@ -2,7 +2,7 @@
// SPDX-FileCopyrightText: 2020-2024 The Monero Project // SPDX-FileCopyrightText: 2020-2024 The Monero Project
#include "AddressBook.h" #include "AddressBook.h"
#include <QDebug>
#include <wallet/wallet2.h> #include <wallet/wallet2.h>
AddressBook::AddressBook(Wallet *wallet, tools::wallet2 *wallet2, QObject *parent) AddressBook::AddressBook(Wallet *wallet, tools::wallet2 *wallet2, QObject *parent)

View file

@ -4,7 +4,6 @@
#ifndef ADDRESSBOOK_H #ifndef ADDRESSBOOK_H
#define ADDRESSBOOK_H #define ADDRESSBOOK_H
#include <wallet/api/wallet2_api.h>
#include <QMap> #include <QMap>
#include <QObject> #include <QObject>
#include <QReadWriteLock> #include <QReadWriteLock>

View file

@ -4,7 +4,6 @@
#ifndef MONERO_GUI_PASSPHRASEHELPER_H #ifndef MONERO_GUI_PASSPHRASEHELPER_H
#define MONERO_GUI_PASSPHRASEHELPER_H #define MONERO_GUI_PASSPHRASEHELPER_H
#include <QtGlobal>
#include <wallet/api/wallet2_api.h> #include <wallet/api/wallet2_api.h>
#include <QMutex> #include <QMutex>
#include <QPointer> #include <QPointer>

View file

@ -4,7 +4,6 @@
#ifndef FEATHER_PENDINGTRANSACTIONINFO_H #ifndef FEATHER_PENDINGTRANSACTIONINFO_H
#define FEATHER_PENDINGTRANSACTIONINFO_H #define FEATHER_PENDINGTRANSACTIONINFO_H
#include <wallet/api/wallet2_api.h>
#include "ConstructionInfo.h" #include "ConstructionInfo.h"
#include <QObject> #include <QObject>
#include <QSet> #include <QSet>

View file

@ -6,7 +6,6 @@
#include <functional> #include <functional>
#include <wallet/api/wallet2_api.h>
#include <QReadWriteLock> #include <QReadWriteLock>
#include <QObject> #include <QObject>
#include <QList> #include <QList>

View file

@ -11,6 +11,23 @@
#include "Ring.h" #include "Ring.h"
#include "wallet/wallet2.h" #include "wallet/wallet2.h"
QString description(tools::wallet2 *wallet2, const tools::wallet2::payment_details &pd)
{
QString description = QString::fromStdString(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(wallet2->get_subaddress_label(pd.m_subaddr_index));
}
}
return description;
}
bool TransactionHistory::transaction(int index, std::function<void (TransactionRow &)> callback) bool TransactionHistory::transaction(int index, std::function<void (TransactionRow &)> callback)
{ {
QReadLocker locker(&m_lock); QReadLocker locker(&m_lock);
@ -103,7 +120,7 @@ void TransactionHistory::refresh()
t->m_timestamp = QDateTime::fromSecsSinceEpoch(pd.m_timestamp); 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_confirmations = (wallet_height > pd.m_block_height) ? wallet_height - pd.m_block_height : 0;
t->m_unlockTime = pd.m_unlock_time; t->m_unlockTime = pd.m_unlock_time;
t->m_description = description(pd); t->m_description = description(m_wallet2, pd);
m_rows.append(t); m_rows.append(t);
} }
@ -250,7 +267,7 @@ void TransactionHistory::refresh()
t->m_label = QString::fromStdString(m_wallet2->get_subaddress_label(pd.m_subaddr_index)); t->m_label = QString::fromStdString(m_wallet2->get_subaddress_label(pd.m_subaddr_index));
t->m_timestamp = QDateTime::fromSecsSinceEpoch(pd.m_timestamp); t->m_timestamp = QDateTime::fromSecsSinceEpoch(pd.m_timestamp);
t->m_confirmations = 0; t->m_confirmations = 0;
t->m_description = description(pd); t->m_description = description(m_wallet2, pd);
m_rows.append(t); m_rows.append(t);
@ -385,20 +402,3 @@ bool TransactionHistory::writeCSV(const QString &path) {
data = QString("blockHeight,timestamp,date,accountIndex,direction,balanceDelta,amount,fee,txid,description,paymentId,fiatAmount,fiatCurrency%1").arg(data); data = QString("blockHeight,timestamp,date,accountIndex,direction,balanceDelta,amount,fee,txid,description,paymentId,fiatAmount,fiatCurrency%1").arg(data);
return Utils::fileWrite(path, 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,7 +51,6 @@ signals:
private: private:
explicit TransactionHistory(Wallet *wallet, tools::wallet2 *wallet2, QObject *parent = nullptr); explicit TransactionHistory(Wallet *wallet, tools::wallet2 *wallet2, QObject *parent = nullptr);
QString description(const tools::wallet2::payment_details &pd);
private: private:
friend class Wallet; friend class Wallet;

View file

@ -6,7 +6,6 @@
#include <QObject> #include <QObject>
#include <wallet/api/wallet2_api.h>
#include "libwalletqt/PendingTransactionInfo.h" #include "libwalletqt/PendingTransactionInfo.h"
class UnsignedTransaction : public QObject class UnsignedTransaction : public QObject

View file

@ -25,6 +25,8 @@
#include "utils/ScopeGuard.h" #include "utils/ScopeGuard.h"
#include "wallet/wallet2.h"
namespace { namespace {
constexpr char ATTRIBUTE_SUBADDRESS_ACCOUNT[] = "feather.subaddress_account"; constexpr char ATTRIBUTE_SUBADDRESS_ACCOUNT[] = "feather.subaddress_account";
} }

View file

@ -10,7 +10,6 @@
#include <QList> #include <QList>
#include <QtConcurrent/QtConcurrent> #include <QtConcurrent/QtConcurrent>
#include "wallet/api/wallet2_api.h"
#include "utils/scheduler.h" #include "utils/scheduler.h"
#include "PendingTransaction.h" #include "PendingTransaction.h"
#include "UnsignedTransaction.h" #include "UnsignedTransaction.h"

View file

@ -5,7 +5,6 @@
#include "Wallet.h" #include "Wallet.h"
#include "utils/ScopeGuard.h" #include "utils/ScopeGuard.h"
#include "serialization/binary_utils.h"
class WalletPassphraseListenerImpl : public Monero::WalletListener, public PassphraseReceiver class WalletPassphraseListenerImpl : public Monero::WalletListener, public PassphraseReceiver
{ {
@ -329,45 +328,3 @@ void WalletManager::onPassphraseEntered(const QString &passphrase, bool enter_on
m_passphraseReceiver->onPassphraseEntered(passphrase, enter_on_device, entry_abort); m_passphraseReceiver->onPassphraseEntered(passphrase, enter_on_device, entry_abort);
} }
} }
std::string WalletManager::encryptWithPassword(const QString &q_plain, const QString &q_password) {
std::string plain = q_plain.toStdString();
std::string password = q_password.toStdString();
crypto::chacha_key key;
crypto::generate_chacha_key(password.data(), password.size(), key, 1);
std::string cipher;
cipher.resize(plain.size());
// Repurposing this struct
tools::wallet2::keys_file_data s_data = {};
s_data.iv = crypto::rand<crypto::chacha_iv>();
crypto::chacha20(plain.data(), plain.size(), key, s_data.iv, &cipher[0]);
s_data.account_data = cipher;
std::string buf;
::serialization::dump_binary(s_data, buf);
return buf;
}
QString WalletManager::decryptWithPassword(const std::string &cipher, const QString &q_password) {
std::string password = q_password.toStdString();
tools::wallet2::keys_file_data s_data;
bool r = ::serialization::parse_binary(cipher, s_data);
if (!r) {
return {};
}
crypto::chacha_key key;
crypto::generate_chacha_key(password.data(), password.size(), key, 1);
std::string plaintext;
plaintext.resize(s_data.account_data.size());
crypto::chacha20(s_data.account_data.data(), s_data.account_data.size(), key, s_data.iv, &plaintext[0]);
return QString::fromStdString(plaintext);
}

View file

@ -117,9 +117,6 @@ public:
void onPassphraseEntered(const QString &passphrase, bool enter_on_device, bool entry_abort=false); void onPassphraseEntered(const QString &passphrase, bool enter_on_device, bool entry_abort=false);
virtual void onWalletPassphraseNeeded(bool on_device) override; virtual void onWalletPassphraseNeeded(bool on_device) override;
static std::string encryptWithPassword(const QString &plain, const QString &password);
static QString decryptWithPassword(const std::string &cipher, const QString &password);
signals: signals:
void walletOpened(Wallet *wallet); void walletOpened(Wallet *wallet);
void walletCreated(Wallet *wallet); void walletCreated(Wallet *wallet);

View file

@ -4,7 +4,6 @@
#ifndef FEATHER_COINSINFO_H #ifndef FEATHER_COINSINFO_H
#define FEATHER_COINSINFO_H #define FEATHER_COINSINFO_H
#include <wallet/api/wallet2_api.h>
#include <QObject> #include <QObject>
#include <QDateTime> #include <QDateTime>
#include <QSet> #include <QSet>