1
mirror of https://github.com/monero-project/monero-gui synced 2024-11-24 11:17:15 +01:00

Fix blackball section to conform to format change

This commit is contained in:
moneromooo-monero 2018-09-30 09:12:44 +01:00
parent 3fd37b96a0
commit 59a63e7725
3 changed files with 34 additions and 18 deletions

View File

@ -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)
}
}
}

View File

@ -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<QString> list;
list.push_back(pubkey);
return blackballOutputs(list, true);
return m_walletImpl->blackballOutput(amount.toStdString(), offset.toStdString());
}
bool Wallet::blackballOutputs(const QList<QString> &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)

View File

@ -281,10 +281,10 @@ public:
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 blackballOutput(const QString &amount, const QString &offset);
Q_INVOKABLE bool blackballOutputs(const QList<QString> &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);