From 65ea07af612751ab0989a8e01d76bad7bc3c2869 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Wed, 7 Mar 2018 00:01:53 +0000 Subject: Add a shared ringdb management page - rings and blackballed outputs --- src/libwalletqt/Wallet.cpp | 96 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) (limited to 'src/libwalletqt/Wallet.cpp') 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 list; + list.push_back(pubkey); + return blackballOutputs(list, true); +} + +bool Wallet::blackballOutputs(const QList &pubkeys, bool add) +{ + std::vector 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 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 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>> 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 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) -- cgit v1.2.3 From 22a111450128dcd105452d4d570a11779f1c1e9f Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Fri, 16 Mar 2018 11:55:56 +0000 Subject: Add segregation key reuse mitigation options --- main.qml | 3 +++ pages/SharedRingDB.qml | 56 ++++++++++++++++++++++++++++++++++++++++++++++ src/libwalletqt/Wallet.cpp | 15 +++++++++++++ src/libwalletqt/Wallet.h | 5 +++++ 4 files changed, 79 insertions(+) (limited to 'src/libwalletqt/Wallet.cpp') diff --git a/main.qml b/main.qml index 6da2c914..f8c6af06 100644 --- a/main.qml +++ b/main.qml @@ -1003,6 +1003,9 @@ ApplicationWindow { property bool useRemoteNode: false property string remoteNodeAddress: "" property string bootstrapNodeAddress: "" + property bool segregatePreForkOutputs: true + property bool keyReuseMitigation2: true + property int segregationHeight: 0 } // Information dialog diff --git a/pages/SharedRingDB.qml b/pages/SharedRingDB.qml index c40c549a..53ea34e1 100644 --- a/pages/SharedRingDB.qml +++ b/pages/SharedRingDB.qml @@ -355,10 +355,66 @@ Rectangle { } } } + + CheckBox { + id: segregatePreForkOutputs + checked: persistentSettings.segregatePreForkOutputs + text: qsTr("I intend to spend on key-reusing fork(s)") + translationManager.emptyString + checkedIcon: "../images/checkedVioletIcon.png" + uncheckedIcon: "../images/uncheckedIcon.png" + onClicked: { + persistentSettings.segregatePreForkOutputs = segregatePreForkOutputs.checked + if (appWindow.currentWallet) { + appWindow.currentWallet.segregatePreForkOutputs(segregatePreForkOutputs.checked) + } + } + } + CheckBox { + id: keyReuseMitigation2 + checked: persistentSettings.keyReuseMitigation2 + text: qsTr("I might want to spend on key-reusing fork(s)") + translationManager.emptyString + checkedIcon: "../images/checkedVioletIcon.png" + uncheckedIcon: "../images/uncheckedIcon.png" + onClicked: { + persistentSettings.keyReuseMitigation2 = keyReuseMitigation2.checked + if (appWindow.currentWallet) { + appWindow.currentWallet.keyReuseMitigation2(keyReuseMitigation2.checked) + } + } + } + RowLayout { + id: segregationHeightRow + anchors.topMargin: 17 + anchors.left: parent.left + anchors.right: parent.right + + Label { + id: segregationHeightLabel + fontSize: 14 + text: qsTr("Segregation height:") + translationManager.emptyString + } + LineEdit { + id: segregationHeightLine + readOnly: false + Layout.fillWidth: true + validator: IntValidator { bottom: 0 } + onEditingFinished: { + persistentSettings.segregationHeight = segregationHeightLine.text + if (appWindow.currentWallet) { + appWindow.currentWallet.segregationHeight(segregationHeightLine.text) + } + } + } + } + } function onPageCompleted() { console.log("RingDB page loaded"); + appWindow.currentWallet.segregatePreForkOutputs(persistentSettings.segregatePreForkOutputs) + appWindow.currentWallet.segregationHeight(persistentSettings.segregationHeight) + segregationHeightLine.text = persistentSettings.segregationHeight + appWindow.currentWallet.keyReuseMitigation2(persistentSettings.keyReuseMitigation2) } } diff --git a/src/libwalletqt/Wallet.cpp b/src/libwalletqt/Wallet.cpp index 1da4e787..74649ce7 100644 --- a/src/libwalletqt/Wallet.cpp +++ b/src/libwalletqt/Wallet.cpp @@ -829,6 +829,21 @@ bool Wallet::setRing(const QString &key_image, const QString &ring, bool relativ 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 dbe1d0ce..c4b1dceb 100644 --- a/src/libwalletqt/Wallet.h +++ b/src/libwalletqt/Wallet.h @@ -288,6 +288,11 @@ public: 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 -- cgit v1.2.3