diff --git a/pages/SharedRingDB.qml b/pages/SharedRingDB.qml index 1be138c6..2fc11f3f 100644 --- a/pages/SharedRingDB.qml +++ b/pages/SharedRingDB.qml @@ -50,6 +50,15 @@ Rectangle { return true } + function validUnsigned(s) { + if (s.length == 0) + return false + for (var i = 0; i < s.length; ++i) + if ("0123456789".indexOf(s[i]) == -1) + return false + return true + } + function validRing(str, relative) { var outs = str.split(" "); if (outs.length == 0) @@ -199,15 +208,24 @@ Rectangle { RowLayout { LineEdit { - id: blackballOutputLine + id: blackballOutputAmountLine fontSize: mainLayout.lineEditFontSize labelFontSize: 14 * scaleRatio labelText: qsTr("Or manually blackball/unblackball a single output:") + translationManager.emptyString - placeholderText: qsTr("Paste output public key") + "..." + translationManager.emptyString + placeholderText: qsTr("Paste output amount") + "..." + translationManager.emptyString readOnly: false - copyButton: true - width: mainLayout.editWidth - Layout.fillWidth: true + width: mainLayout.editWidth / 2 + validator: IntValidator { bottom: 0 } + } + LineEdit { + id: blackballOutputOffsetLine + fontSize: mainLayout.lineEditFontSize + labelFontSize: 14 * scaleRatio + labelText: " " + placeholderText: qsTr("Paste output offset") + "..." + translationManager.emptyString + readOnly: false + width: mainLayout.editWidth / 2 + validator: IntValidator { bottom: 0 } } } @@ -219,8 +237,8 @@ Rectangle { id: blackballButton text: qsTr("Blackball") + translationManager.emptyString small: true - enabled: !!appWindow.currentWallet && validHex32(blackballOutputLine.text) - onClicked: appWindow.currentWallet.blackballOutput(blackballOutputLine.text) + enabled: !!appWindow.currentWallet && validUnsigned(blackballOutputAmountLine.text) && validUnsigned(blackballOutputOffsetLine.text) + onClicked: appWindow.currentWallet.blackballOutput(blackballOutputAmountLine.text, blackballOutputOffsetLine.text) } StandardButton { @@ -228,8 +246,8 @@ Rectangle { anchors.right: parent.right text: qsTr("Unblackball") + translationManager.emptyString small: true - enabled: !!appWindow.currentWallet && validHex32(blackballOutputLine.text) - onClicked: appWindow.currentWallet.unblackballOutput(blackballOutputLine.text) + enabled: !!appWindow.currentWallet && validUnsigned(blackballOutputAmountLine.text) && validUnsigned(blackballOutputOffsetLine.text) + onClicked: appWindow.currentWallet.unblackballOutput(blackballOutputAmountLine.text, blackballOutputOffsetLine.text) } } } diff --git a/src/libwalletqt/Wallet.cpp b/src/libwalletqt/Wallet.cpp index 2c6e92c9..4aa442fa 100644 --- a/src/libwalletqt/Wallet.cpp +++ b/src/libwalletqt/Wallet.cpp @@ -738,11 +738,9 @@ QString Wallet::getDaemonLogPath() const return QString::fromStdString(m_walletImpl->getDefaultDataDir()) + "/bitmonero.log"; } -bool Wallet::blackballOutput(const QString &pubkey) +bool Wallet::blackballOutput(const QString &amount, const QString &offset) { - QList list; - list.push_back(pubkey); - return blackballOutputs(list, true); + return m_walletImpl->blackballOutput(amount.toStdString(), offset.toStdString()); } bool Wallet::blackballOutputs(const QList &pubkeys, bool add) @@ -775,9 +773,9 @@ bool Wallet::blackballOutputs(const QString &filename, bool add) } } -bool Wallet::unblackballOutput(const QString &pubkey) +bool Wallet::unblackballOutput(const QString &amount, const QString &offset) { - return m_walletImpl->unblackballOutput(pubkey.toStdString()); + return m_walletImpl->unblackballOutput(amount.toStdString(), offset.toStdString()); } QString Wallet::getRing(const QString &key_image) diff --git a/src/libwalletqt/Wallet.h b/src/libwalletqt/Wallet.h index d0f053ac..8197e567 100644 --- a/src/libwalletqt/Wallet.h +++ b/src/libwalletqt/Wallet.h @@ -281,10 +281,10 @@ public: QString getWalletLogPath() const; // Blackalled outputs - Q_INVOKABLE bool blackballOutput(const QString &pubkey); - Q_INVOKABLE bool blackballOutputs(const QList &pubkeys, bool add); + Q_INVOKABLE bool blackballOutput(const QString &amount, const QString &offset); + Q_INVOKABLE bool blackballOutputs(const QList &outputs, bool add); Q_INVOKABLE bool blackballOutputs(const QString &filename, bool add); - Q_INVOKABLE bool unblackballOutput(const QString &pubkey); + Q_INVOKABLE bool unblackballOutput(const QString &amount, const QString &offset); // Rings Q_INVOKABLE QString getRing(const QString &key_image);