mirror of
https://github.com/feather-wallet/feather.git
synced 2025-04-16 18:01:54 +00:00
Ring/Transfer: cleanup
This commit is contained in:
parent
f7d11e8ffe
commit
1219bfc3a7
11 changed files with 51 additions and 83 deletions
|
@ -943,7 +943,7 @@ void MainWindow::onTransactionCreated(PendingTransaction *tx, const QVector<QStr
|
|||
tx->refresh();
|
||||
QSet<QString> outputAddresses;
|
||||
for (const auto &output : tx->transaction(0)->outputs()) {
|
||||
outputAddresses.insert(WalletManager::baseAddressFromIntegratedAddress(output->address(), constants::networkType));
|
||||
outputAddresses.insert(WalletManager::baseAddressFromIntegratedAddress(output.address, constants::networkType));
|
||||
}
|
||||
QSet<QString> destAddresses;
|
||||
for (const auto &addr : address) {
|
||||
|
|
|
@ -151,10 +151,10 @@ void TxConfAdvDialog::setupConstructionData(ConstructionInfo *ci) {
|
|||
|
||||
for (const auto &out: ci->outputs()) {
|
||||
auto *item = new QTreeWidgetItem(ui->treeOutputs);
|
||||
item->setText(0, out->address());
|
||||
item->setText(1, WalletManager::displayAmount(out->amount()));
|
||||
item->setText(0, out.address);
|
||||
item->setText(1, WalletManager::displayAmount(out.amount));
|
||||
item->setFont(0, Utils::getMonospaceFont());
|
||||
auto index = m_wallet->subaddressIndex(out->address());
|
||||
auto index = m_wallet->subaddressIndex(out.address);
|
||||
QBrush brush;
|
||||
if (index.isChange()) {
|
||||
brush = QBrush(ColorScheme::YELLOW.asColor(true));
|
||||
|
@ -165,7 +165,7 @@ void TxConfAdvDialog::setupConstructionData(ConstructionInfo *ci) {
|
|||
brush = QBrush(ColorScheme::GREEN.asColor(true));
|
||||
item->setToolTip(0, "Wallet receive address");
|
||||
}
|
||||
else if (out->amount() == 0) {
|
||||
else if (out.amount == 0) {
|
||||
brush = QBrush(ColorScheme::GRAY.asColor(true));
|
||||
item->setToolTip(0, "Dummy output (Min. 2 outs consensus rule)");
|
||||
}
|
||||
|
|
|
@ -79,14 +79,14 @@ TxInfoDialog::TxInfoDialog(Wallet *wallet, TransactionRow *txInfo, QWidget *pare
|
|||
bool hasIntegrated = false;
|
||||
|
||||
for (const auto& transfer : transfers) {
|
||||
auto address = transfer->address();
|
||||
auto amount = WalletManager::displayAmount(transfer->amount());
|
||||
auto address = transfer.address;
|
||||
auto amount = WalletManager::displayAmount(transfer.amount);
|
||||
auto index = m_wallet->subaddressIndex(address);
|
||||
cursor.insertText(address, Utils::addressTextFormat(index, transfer->amount()));
|
||||
cursor.insertText(address, Utils::addressTextFormat(index, transfer.amount));
|
||||
cursor.insertText(QString(" %1").arg(amount), QTextCharFormat());
|
||||
cursor.insertBlock();
|
||||
|
||||
if (WalletManager::baseAddressFromIntegratedAddress(transfer->address(), constants::networkType) != transfer->address()) {
|
||||
if (WalletManager::baseAddressFromIntegratedAddress(transfer.address, constants::networkType) != transfer.address) {
|
||||
hasIntegrated = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ TxProofDialog::TxProofDialog(QWidget *parent, Wallet *wallet, TransactionRow *tx
|
|||
m_direction = txInfo->direction();
|
||||
|
||||
for (auto const &t: txInfo->transfers()) {
|
||||
m_OutDestinations.push_back(t->address());
|
||||
m_OutDestinations.push_back(t.address);
|
||||
}
|
||||
|
||||
for (auto const &s: txInfo->subaddrIndex()) {
|
||||
|
|
|
@ -27,7 +27,7 @@ QList<Input *> ConstructionInfo::inputs() const {
|
|||
return m_inputs;
|
||||
}
|
||||
|
||||
QList<Transfer *> ConstructionInfo::outputs() const {
|
||||
QList<Transfer> ConstructionInfo::outputs() const {
|
||||
return m_outputs;
|
||||
}
|
||||
|
||||
|
@ -44,8 +44,7 @@ ConstructionInfo::ConstructionInfo(const Monero::TransactionConstructionInfo *pi
|
|||
|
||||
for (auto const &o : pimpl->outputs())
|
||||
{
|
||||
Transfer *output = new Transfer(o.amount, QString::fromStdString(o.address), this);
|
||||
m_outputs.append(output);
|
||||
m_outputs.emplace_back(o.amount, QString::fromStdString(o.address));
|
||||
}
|
||||
for (uint32_t i : pimpl->subaddressIndices())
|
||||
{
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
|
||||
#include <QObject>
|
||||
#include <QSet>
|
||||
#include "Transfer.h"
|
||||
|
||||
class Input;
|
||||
class Transfer;
|
||||
|
||||
namespace Monero {
|
||||
class TransactionConstructionInfo;
|
||||
|
@ -24,7 +24,7 @@ public:
|
|||
QVector<QString> subaddresses() const;
|
||||
quint64 minMixinCount() const;
|
||||
QList<Input*> inputs() const;
|
||||
QList<Transfer*> outputs() const;
|
||||
QList<Transfer> outputs() const;
|
||||
|
||||
private:
|
||||
explicit ConstructionInfo(const Monero::TransactionConstructionInfo *pimpl, QObject *parent = nullptr);
|
||||
|
@ -36,7 +36,7 @@ private:
|
|||
QVector<QString> m_subaddresses;
|
||||
quint64 m_minMixinCount;
|
||||
mutable QList<Input*> m_inputs;
|
||||
mutable QList<Transfer*> m_outputs;
|
||||
mutable QList<Transfer> m_outputs;
|
||||
};
|
||||
|
||||
#endif //FEATHER_CONSTRUCTIONINFO_H
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
// SPDX-FileCopyrightText: The Monero Project
|
||||
|
||||
#ifndef FEATHER_RINGS_H
|
||||
#define FEATHER_RINGS_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class Ring : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Ring(QString _keyImage, std::vector<uint64_t> _ringMembers, QObject *parent = nullptr): QObject(parent), m_keyImage(std::move(_keyImage)), m_ringMembers(std::move(_ringMembers)) {};
|
||||
|
||||
private:
|
||||
friend class TransactionInfo;
|
||||
QString m_keyImage;
|
||||
std::vector<uint64_t> m_ringMembers;
|
||||
|
||||
public:
|
||||
QString keyImage() const { return m_keyImage; }
|
||||
std::vector<uint64_t> ringMembers() const { return m_ringMembers; }
|
||||
};
|
||||
|
||||
#endif //FEATHER_RINGS_H
|
|
@ -8,7 +8,6 @@
|
|||
#include "constants.h"
|
||||
#include "WalletManager.h"
|
||||
#include "Transfer.h"
|
||||
#include "Ring.h"
|
||||
#include "wallet/wallet2.h"
|
||||
|
||||
QString description(tools::wallet2 *wallet2, const tools::wallet2::payment_details &pd)
|
||||
|
@ -178,13 +177,15 @@ void TransactionHistory::refresh()
|
|||
// single output transaction might contain multiple transfers
|
||||
for (auto const &d: pd.m_dests)
|
||||
{
|
||||
Transfer *transfer = new Transfer(d.amount, QString::fromStdString(d.address(m_wallet2->nettype(), pd.m_payment_id, !hasFakePaymentId)), this);
|
||||
t->m_transfers.append(transfer);
|
||||
t->m_transfers.emplace_back(
|
||||
d.amount,
|
||||
QString::fromStdString(d.address(m_wallet2->nettype(), pd.m_payment_id, !hasFakePaymentId)));
|
||||
}
|
||||
for (auto const &r: pd.m_rings)
|
||||
{
|
||||
Ring *ring = new Ring(QString::fromStdString(epee::string_tools::pod_to_hex(r.first)), cryptonote::relative_output_offsets_to_absolute(r.second), this);
|
||||
t->m_rings.append(ring);
|
||||
t->m_rings.emplace_back(
|
||||
QString::fromStdString(epee::string_tools::pod_to_hex(r.first)),
|
||||
cryptonote::relative_output_offsets_to_absolute(r.second));
|
||||
}
|
||||
|
||||
m_rows.append(t);
|
||||
|
@ -231,13 +232,15 @@ void TransactionHistory::refresh()
|
|||
|
||||
for (auto const &d: pd.m_dests)
|
||||
{
|
||||
Transfer *transfer = new Transfer(d.amount, QString::fromStdString(d.address(m_wallet2->nettype(), pd.m_payment_id, !hasFakePaymentId)), this);
|
||||
t->m_transfers.append(transfer);
|
||||
t->m_transfers.emplace_back(
|
||||
d.amount,
|
||||
QString::fromStdString(d.address(m_wallet2->nettype(), pd.m_payment_id, !hasFakePaymentId)));
|
||||
}
|
||||
for (auto const &r: pd.m_rings)
|
||||
{
|
||||
Ring *ring = new Ring(QString::fromStdString(epee::string_tools::pod_to_hex(r.first)), cryptonote::relative_output_offsets_to_absolute(r.second), this);
|
||||
t->m_rings.append(ring);
|
||||
t->m_rings.emplace_back(
|
||||
QString::fromStdString(epee::string_tools::pod_to_hex(r.first)),
|
||||
cryptonote::relative_output_offsets_to_absolute(r.second));
|
||||
}
|
||||
|
||||
m_rows.append(t);
|
||||
|
|
|
@ -4,27 +4,14 @@
|
|||
#ifndef TRANSFER_H
|
||||
#define TRANSFER_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class Transfer : public QObject
|
||||
struct Transfer
|
||||
{
|
||||
Q_OBJECT
|
||||
QString address;
|
||||
quint64 amount;
|
||||
|
||||
public:
|
||||
explicit Transfer(uint64_t amount, QString address, QObject *parent = nullptr)
|
||||
: QObject(parent)
|
||||
, m_amount(amount)
|
||||
, m_address(std::move(address)) {};
|
||||
|
||||
quint64 amount() const { return m_amount; }
|
||||
QString address() const { return m_address; }
|
||||
|
||||
private:
|
||||
friend class TransactionInfo;
|
||||
friend class ConstructionInfo;
|
||||
|
||||
quint64 m_amount;
|
||||
QString m_address;
|
||||
explicit Transfer(uint64_t amount_, QString address_)
|
||||
: address(std::move(address_))
|
||||
, amount(amount_) {}
|
||||
};
|
||||
|
||||
#endif // TRANSFER_H
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include "TransactionRow.h"
|
||||
#include "WalletManager.h"
|
||||
#include "Transfer.h"
|
||||
#include "Ring.h"
|
||||
|
||||
TransactionRow::TransactionRow(QObject *parent)
|
||||
: QObject(parent)
|
||||
|
@ -145,12 +144,12 @@ QList<QString> TransactionRow::destinations() const
|
|||
{
|
||||
QList<QString> dests;
|
||||
for (auto const& t: m_transfers) {
|
||||
dests.append(t->address());
|
||||
dests.append(t.address);
|
||||
}
|
||||
return dests;
|
||||
}
|
||||
|
||||
QList<Transfer*> TransactionRow::transfers() const {
|
||||
QList<Transfer> TransactionRow::transfers() const {
|
||||
return m_transfers;
|
||||
}
|
||||
|
||||
|
@ -158,8 +157,8 @@ QString TransactionRow::rings_formatted() const
|
|||
{
|
||||
QString rings;
|
||||
for (auto const& r: m_rings) {
|
||||
rings += r->keyImage() + ": \n";
|
||||
for (uint64_t m : r->ringMembers()){
|
||||
rings += r.keyImage + ": \n";
|
||||
for (uint64_t m : r.ringMembers){
|
||||
rings += QString::number(m) + " ";
|
||||
}
|
||||
rings += "\n\n";
|
||||
|
@ -173,6 +172,4 @@ bool TransactionRow::hasPaymentId() const {
|
|||
|
||||
TransactionRow::~TransactionRow()
|
||||
{
|
||||
qDeleteAll(m_transfers);
|
||||
qDeleteAll(m_rings);
|
||||
}
|
||||
|
|
|
@ -4,13 +4,21 @@
|
|||
#ifndef FEATHER_TRANSACTIONROW_H
|
||||
#define FEATHER_TRANSACTIONROW_H
|
||||
|
||||
class Transfer;
|
||||
class Ring;
|
||||
|
||||
#include <QObject>
|
||||
#include <QSet>
|
||||
#include <QDateTime>
|
||||
|
||||
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)) {}
|
||||
};
|
||||
struct Transfer;
|
||||
|
||||
class TransactionRow : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -50,7 +58,7 @@ public:
|
|||
QString time() const;
|
||||
QString paymentId() const;
|
||||
QList<QString> destinations() const;
|
||||
QList<Transfer*> transfers() const;
|
||||
QList<Transfer> transfers() const;
|
||||
QString rings_formatted() const;
|
||||
bool hasPaymentId() const;
|
||||
|
||||
|
@ -59,8 +67,8 @@ private:
|
|||
|
||||
private:
|
||||
friend class TransactionHistory;
|
||||
QList<Transfer*> m_transfers;
|
||||
QList<Ring*> m_rings;
|
||||
QList<Transfer> m_transfers;
|
||||
QList<Ring> m_rings;
|
||||
qint64 m_amount; // Amount that was sent (to destinations) or received, excludes tx fee
|
||||
qint64 m_balanceDelta; // How much the total balance was mutated as a result of this tx (includes tx fee)
|
||||
quint64 m_blockHeight;
|
||||
|
|
Loading…
Reference in a new issue