forked from Public/monero-gui
Add a shared ringdb management page - rings and blackballed outputs
This commit is contained in:
@@ -733,6 +733,102 @@ QString Wallet::getWalletLogPath() const
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Wallet::blackballOutput(const QString &pubkey)
|
||||
{
|
||||
QList<QString> list;
|
||||
list.push_back(pubkey);
|
||||
return blackballOutputs(list, true);
|
||||
}
|
||||
|
||||
bool Wallet::blackballOutputs(const QList<QString> &pubkeys, bool add)
|
||||
{
|
||||
std::vector<std::string> std_pubkeys;
|
||||
foreach (const QString &pubkey, pubkeys) {
|
||||
std_pubkeys.push_back(pubkey.toStdString());
|
||||
}
|
||||
return m_walletImpl->blackballOutputs(std_pubkeys, add);
|
||||
}
|
||||
|
||||
bool Wallet::blackballOutputs(const QString &filename, bool add)
|
||||
{
|
||||
QFile file(filename);
|
||||
|
||||
try {
|
||||
if (!file.open(QIODevice::ReadOnly))
|
||||
return false;
|
||||
QList<QString> outputs;
|
||||
QTextStream in(&file);
|
||||
while (!in.atEnd()) {
|
||||
outputs.push_back(in.readLine());
|
||||
}
|
||||
file.close();
|
||||
return blackballOutputs(outputs, add);
|
||||
}
|
||||
catch (const std::exception &e) {
|
||||
file.close();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool Wallet::unblackballOutput(const QString &pubkey)
|
||||
{
|
||||
return m_walletImpl->unblackballOutput(pubkey.toStdString());
|
||||
}
|
||||
|
||||
QString Wallet::getRing(const QString &key_image)
|
||||
{
|
||||
std::vector<uint64_t> cring;
|
||||
if (!m_walletImpl->getRing(key_image.toStdString(), cring))
|
||||
return "";
|
||||
QString ring = "";
|
||||
for (uint64_t out: cring)
|
||||
{
|
||||
if (!ring.isEmpty())
|
||||
ring = ring + " ";
|
||||
QString s;
|
||||
s.setNum(out);
|
||||
ring = ring + s;
|
||||
}
|
||||
return ring;
|
||||
}
|
||||
|
||||
QString Wallet::getRings(const QString &txid)
|
||||
{
|
||||
std::vector<std::pair<std::string, std::vector<uint64_t>>> crings;
|
||||
if (!m_walletImpl->getRings(txid.toStdString(), crings))
|
||||
return "";
|
||||
QString ring = "";
|
||||
for (const auto &cring: crings)
|
||||
{
|
||||
if (!ring.isEmpty())
|
||||
ring = ring + "|";
|
||||
ring = ring + QString::fromStdString(cring.first) + " absolute";
|
||||
for (uint64_t out: cring.second)
|
||||
{
|
||||
ring = ring + " ";
|
||||
QString s;
|
||||
s.setNum(out);
|
||||
ring = ring + s;
|
||||
}
|
||||
}
|
||||
return ring;
|
||||
}
|
||||
|
||||
bool Wallet::setRing(const QString &key_image, const QString &ring, bool relative)
|
||||
{
|
||||
std::vector<uint64_t> cring;
|
||||
QStringList strOuts = ring.split(" ");
|
||||
foreach(QString str, strOuts)
|
||||
{
|
||||
uint64_t out;
|
||||
bool ok;
|
||||
out = str.toULong(&ok);
|
||||
if (ok)
|
||||
cring.push_back(out);
|
||||
}
|
||||
return m_walletImpl->setRing(key_image.toStdString(), cring, relative);
|
||||
}
|
||||
|
||||
Wallet::Wallet(Monero::Wallet *w, QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_walletImpl(w)
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <QObject>
|
||||
#include <QTime>
|
||||
#include <QMutex>
|
||||
#include <QList>
|
||||
#include <QtConcurrent/QtConcurrent>
|
||||
|
||||
#include "wallet/api/wallet2_api.h" // we need to have an access to the Monero::Wallet::Status enum here;
|
||||
@@ -276,6 +277,17 @@ public:
|
||||
QString getDaemonLogPath() const;
|
||||
QString getWalletLogPath() const;
|
||||
|
||||
// Blackalled outputs
|
||||
Q_INVOKABLE bool blackballOutput(const QString &pubkey);
|
||||
Q_INVOKABLE bool blackballOutputs(const QList<QString> &pubkeys, bool add);
|
||||
Q_INVOKABLE bool blackballOutputs(const QString &filename, bool add);
|
||||
Q_INVOKABLE bool unblackballOutput(const QString &pubkey);
|
||||
|
||||
// Rings
|
||||
Q_INVOKABLE QString getRing(const QString &key_image);
|
||||
Q_INVOKABLE QString getRings(const QString &txid);
|
||||
Q_INVOKABLE bool setRing(const QString &key_image, const QString &ring, bool relative);
|
||||
|
||||
// TODO: setListenter() when it implemented in API
|
||||
signals:
|
||||
// emitted on every event happened with wallet
|
||||
|
||||
Reference in New Issue
Block a user