aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-03-07 00:01:53 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-03-26 20:57:33 +0100
commit65ea07af612751ab0989a8e01d76bad7bc3c2869 (patch)
treec3374ebcb154ebbab1e484aa65c4257fde760b3b /src
parentfdaf557b994cd206782a1e039c6455c8dcc850ab (diff)
downloadmonzero-gui-65ea07af612751ab0989a8e01d76bad7bc3c2869.tar.gz
monzero-gui-65ea07af612751ab0989a8e01d76bad7bc3c2869.tar.xz
monzero-gui-65ea07af612751ab0989a8e01d76bad7bc3c2869.zip
Add a shared ringdb management page - rings and blackballed outputs
Diffstat (limited to 'src')
-rw-r--r--src/libwalletqt/Wallet.cpp96
-rw-r--r--src/libwalletqt/Wallet.h12
2 files changed, 108 insertions, 0 deletions
diff --git a/src/libwalletqt/Wallet.cpp b/src/libwalletqt/Wallet.cpp
index 14541f65..1da4e787 100644
--- a/src/libwalletqt/Wallet.cpp
+++ b/src/libwalletqt/Wallet.cpp
@@ -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)
diff --git a/src/libwalletqt/Wallet.h b/src/libwalletqt/Wallet.h
index 82e11ec3..dbe1d0ce 100644
--- a/src/libwalletqt/Wallet.h
+++ b/src/libwalletqt/Wallet.h
@@ -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