diff options
| author | luigi1111 <luigi1111w@gmail.com> | 2018-03-27 11:49:36 -0500 |
|---|---|---|
| committer | luigi1111 <luigi1111w@gmail.com> | 2018-03-27 11:49:36 -0500 |
| commit | 00e34f78464d8720b3aaf61e4cdaba7daddbe26d (patch) | |
| tree | 7405cb0540cc8488a197eee802c0ecb445f125cb /src/libwalletqt | |
| parent | fdaf557b994cd206782a1e039c6455c8dcc850ab (diff) | |
| parent | 22a111450128dcd105452d4d570a11779f1c1e9f (diff) | |
| download | monzero-gui-00e34f78464d8720b3aaf61e4cdaba7daddbe26d.tar.gz monzero-gui-00e34f78464d8720b3aaf61e4cdaba7daddbe26d.tar.xz monzero-gui-00e34f78464d8720b3aaf61e4cdaba7daddbe26d.zip | |
Merge pull request #1172
65ea07a Add a shared ringdb management page - rings and blackballed outputs
22a1114 Add segregation key reuse mitigation options
Diffstat (limited to 'src/libwalletqt')
| -rw-r--r-- | src/libwalletqt/Wallet.cpp | 111 | ||||
| -rw-r--r-- | src/libwalletqt/Wallet.h | 17 |
2 files changed, 128 insertions, 0 deletions
diff --git a/src/libwalletqt/Wallet.cpp b/src/libwalletqt/Wallet.cpp index 14541f65..74649ce7 100644 --- a/src/libwalletqt/Wallet.cpp +++ b/src/libwalletqt/Wallet.cpp @@ -733,6 +733,117 @@ 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); +} + +void Wallet::segregatePreForkOutputs(bool segregate) +{ + m_walletImpl->segregatePreForkOutputs(segregate); +} + +void Wallet::segregationHeight(quint64 height) +{ + m_walletImpl->segregationHeight(height); +} + +void Wallet::keyReuseMitigation2(bool mitigation) +{ + m_walletImpl->keyReuseMitigation2(mitigation); +} + 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..c4b1dceb 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,22 @@ 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); + + // key reuse mitigation options + Q_INVOKABLE void segregatePreForkOutputs(bool segregate); + Q_INVOKABLE void segregationHeight(quint64 height); + Q_INVOKABLE void keyReuseMitigation2(bool mitigation); + // TODO: setListenter() when it implemented in API signals: // emitted on every event happened with wallet |
