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 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) { function validRing(str, relative) {
var outs = str.split(" "); var outs = str.split(" ");
if (outs.length == 0) if (outs.length == 0)
@ -199,15 +208,24 @@ Rectangle {
RowLayout { RowLayout {
LineEdit { LineEdit {
id: blackballOutputLine id: blackballOutputAmountLine
fontSize: mainLayout.lineEditFontSize fontSize: mainLayout.lineEditFontSize
labelFontSize: 14 * scaleRatio labelFontSize: 14 * scaleRatio
labelText: qsTr("Or manually blackball/unblackball a single output:") + translationManager.emptyString 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 readOnly: false
copyButton: true width: mainLayout.editWidth / 2
width: mainLayout.editWidth validator: IntValidator { bottom: 0 }
Layout.fillWidth: true }
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 id: blackballButton
text: qsTr("Blackball") + translationManager.emptyString text: qsTr("Blackball") + translationManager.emptyString
small: true small: true
enabled: !!appWindow.currentWallet && validHex32(blackballOutputLine.text) enabled: !!appWindow.currentWallet && validUnsigned(blackballOutputAmountLine.text) && validUnsigned(blackballOutputOffsetLine.text)
onClicked: appWindow.currentWallet.blackballOutput(blackballOutputLine.text) onClicked: appWindow.currentWallet.blackballOutput(blackballOutputAmountLine.text, blackballOutputOffsetLine.text)
} }
StandardButton { StandardButton {
@ -228,8 +246,8 @@ Rectangle {
anchors.right: parent.right anchors.right: parent.right
text: qsTr("Unblackball") + translationManager.emptyString text: qsTr("Unblackball") + translationManager.emptyString
small: true small: true
enabled: !!appWindow.currentWallet && validHex32(blackballOutputLine.text) enabled: !!appWindow.currentWallet && validUnsigned(blackballOutputAmountLine.text) && validUnsigned(blackballOutputOffsetLine.text)
onClicked: appWindow.currentWallet.unblackballOutput(blackballOutputLine.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"; 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; return m_walletImpl->blackballOutput(amount.toStdString(), offset.toStdString());
list.push_back(pubkey);
return blackballOutputs(list, true);
} }
bool Wallet::blackballOutputs(const QList<QString> &pubkeys, bool add) 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) QString Wallet::getRing(const QString &key_image)

View File

@ -281,10 +281,10 @@ public:
QString getWalletLogPath() const; QString getWalletLogPath() const;
// Blackalled outputs // Blackalled outputs
Q_INVOKABLE bool blackballOutput(const QString &pubkey); Q_INVOKABLE bool blackballOutput(const QString &amount, const QString &offset);
Q_INVOKABLE bool blackballOutputs(const QList<QString> &pubkeys, bool add); Q_INVOKABLE bool blackballOutputs(const QList<QString> &outputs, bool add);
Q_INVOKABLE bool blackballOutputs(const QString &filename, 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 // Rings
Q_INVOKABLE QString getRing(const QString &key_image); Q_INVOKABLE QString getRing(const QString &key_image);