monero-gui/pages/SharedRingDB.qml

294 lines
12 KiB
QML
Raw Normal View History

2024-01-27 20:12:09 +01:00
// Copyright (c) 2018-2024, The Monero Project
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other
// materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be
// used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2019-04-11 03:17:29 +02:00
import QtQuick 2.9
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import QtQuick.Layouts 1.1
import QtQuick.Dialogs 1.2
2019-02-01 22:20:38 +01:00
import "../components" as MoneroComponents
import moneroComponents.Clipboard 1.0
Rectangle {
2018-04-22 20:07:31 +02:00
property alias panelHeight: mainLayout.height
2018-03-28 21:12:00 +02:00
color: "transparent"
Clipboard { id: clipboard }
function validHex32(s) {
if (s.length != 64)
return false
for (var i = 0; i < s.length; ++i)
if ("0123456789abcdefABCDEF".indexOf(s[i]) == -1)
return false
return true
}
function validRing(str, relative) {
var outs = str.split(" ");
if (outs.length == 0)
return false
for (var i = 1; i < outs.length; ++i) {
if (relative) {
if (outs[i] <= 0)
return false
}
else {
if (outs[i] <= outs[i-1])
return false
}
}
return true
}
/* main layout */
ColumnLayout {
id: mainLayout
2019-02-01 22:20:38 +01:00
Layout.fillWidth: true
2019-09-06 00:11:12 +02:00
anchors.margins: 20
anchors.topMargin: 0
anchors.left: parent.left
anchors.top: parent.top
anchors.right: parent.right
2019-04-25 21:09:23 +02:00
spacing: 20
MessageDialog {
id: sharedRingDBDialog
standardButtons: StandardButton.Ok
}
2019-02-01 22:20:38 +01:00
MoneroComponents.Label {
2018-04-22 20:07:31 +02:00
id: signTitleLabel
2019-04-25 21:09:23 +02:00
fontSize: 24
2018-04-22 20:07:31 +02:00
text: qsTr("Shared RingDB") + translationManager.emptyString
}
2019-04-11 03:17:29 +02:00
MoneroComponents.TextPlain {
2018-04-22 20:07:31 +02:00
text: qsTr("This page allows you to interact with the shared ring database. " +
"This database is meant for use by Monero wallets as well as wallets from Monero clones which reuse the Monero keys.") + translationManager.emptyString
wrapMode: Text.Wrap
2018-04-22 20:07:31 +02:00
Layout.fillWidth: true
2019-02-01 22:20:38 +01:00
font.family: MoneroComponents.Style.fontRegular.name
2019-04-25 21:09:23 +02:00
font.pixelSize: 14
2019-02-01 22:20:38 +01:00
color: MoneroComponents.Style.defaultFontColor
}
2019-02-01 22:20:38 +01:00
MoneroComponents.LabelSubheader {
2018-04-22 20:07:31 +02:00
Layout.fillWidth: true
2019-04-25 21:09:23 +02:00
Layout.topMargin: 24
textFormat: Text.RichText
2021-11-19 16:34:34 +01:00
text: qsTr("Rings") + translationManager.emptyString
tooltip: qsTr(
"In order to avoid nullifying the protection afforded by Monero's ring signatures, an output should not " +
"be spent with different rings on different blockchains. While this is normally not a concern, it can become one " +
"when a key-reusing Monero clone allows you to spend existing outputs. In this case, you need to ensure this " +
"existing outputs uses the same ring on both chains.<br>" +
"This will be done automatically by Monero and any key-reusing software which is not trying to actively strip " +
"you of your privacy.<br>" +
"If you are using a key-reusing Monero clone too, and this clone does not include this protection, you can still " +
"ensure your transactions are protected by spending on the clone first, then manually adding the ring on this page, " +
"which allows you to then spend your Monero safely.<br>" +
"If you do not use a key-reusing Monero clone without these safety features, then you do not need to do anything " +
"as it is all automated.<br>"
) + translationManager.emptyString
2018-04-22 20:07:31 +02:00
}
2019-04-11 03:17:29 +02:00
MoneroComponents.TextPlain {
2018-04-22 20:07:31 +02:00
textFormat: Text.RichText
2019-02-01 22:20:38 +01:00
font.family: MoneroComponents.Style.fontRegular.name
2019-04-25 21:09:23 +02:00
font.pixelSize: 14
2018-04-22 20:07:31 +02:00
text: qsTr("This records rings used by outputs spent on Monero on a key reusing chain, so that the same ring may be reused to avoid privacy issues.") + translationManager.emptyString
wrapMode: Text.Wrap
Layout.fillWidth: true;
2019-02-01 22:20:38 +01:00
color: MoneroComponents.Style.defaultFontColor
}
2019-02-01 22:20:38 +01:00
MoneroComponents.LineEdit {
id: keyImageLine
Layout.fillWidth: true
2019-04-25 21:09:23 +02:00
fontSize: 16
labelFontSize: 14
2019-02-01 22:20:38 +01:00
labelText: qsTr("Key image") + ":" + translationManager.emptyString
2019-04-25 21:09:23 +02:00
placeholderFontSize: 16
2019-02-01 22:20:38 +01:00
placeholderText: qsTr("Paste key image") + "..." + translationManager.emptyString
readOnly: false
copyButton: true
2018-04-22 20:07:31 +02:00
}
2018-04-22 20:07:31 +02:00
GridLayout{
2019-04-25 21:09:23 +02:00
Layout.topMargin: 12
2019-09-06 00:11:12 +02:00
columns: 2
2019-04-25 21:09:23 +02:00
columnSpacing: 32
2018-04-22 20:07:31 +02:00
ColumnLayout {
RowLayout {
2019-02-01 22:20:38 +01:00
MoneroComponents.LineEdit {
2018-04-22 20:07:31 +02:00
id: getRingLine
Layout.fillWidth: true
2019-04-25 21:09:23 +02:00
fontSize: 16
labelFontSize: 14
2018-04-22 20:07:31 +02:00
labelText: qsTr("Get ring") + ":" + translationManager.emptyString
readOnly: true
copyButton: true
}
}
RowLayout {
Layout.fillWidth: true
Layout.topMargin: 18
2019-02-01 22:20:38 +01:00
MoneroComponents.StandardButton {
2018-04-22 20:07:31 +02:00
id: getRingButton
text: qsTr("Get Ring") + translationManager.emptyString
small: true
enabled: !!appWindow.currentWallet && validHex32(keyImageLine.text)
onClicked: {
var ring = appWindow.currentWallet.getRing(keyImageLine.text)
if (ring === "") {
getRingLine.text = qsTr("No ring found") + translationManager.emptyString;
2018-04-22 20:07:31 +02:00
}
else {
getRingLine.text = ring;
}
}
}
}
}
2018-04-22 20:07:31 +02:00
ColumnLayout {
RowLayout {
2019-02-01 22:20:38 +01:00
MoneroComponents.LineEdit {
2018-04-22 20:07:31 +02:00
id: setRingLine
Layout.fillWidth: true
2019-04-25 21:09:23 +02:00
fontSize: 16
labelFontSize: 14
placeholderFontSize: 16
2018-04-22 20:07:31 +02:00
labelText: qsTr("Set ring") + ":" + translationManager.emptyString
readOnly: false
copyButton: true
}
}
2018-04-22 20:07:31 +02:00
RowLayout {
Layout.fillWidth: true
Layout.topMargin: 18
2019-02-01 22:20:38 +01:00
MoneroComponents.StandardButton {
2018-04-22 20:07:31 +02:00
id: setRingButton
text: qsTr("Set Ring") + translationManager.emptyString
small: true
enabled: !!appWindow.currentWallet && validHex32(keyImageLine.text) && validRing(setRingLine.text.trim(), setRingRelative.checked)
onClicked: {
var outs = setRingLine.text.trim()
appWindow.currentWallet.setRing(keyImageLine.text, outs, setRingRelative.checked)
}
}
}
}
}
2018-04-22 20:07:31 +02:00
GridLayout {
2019-04-25 21:09:23 +02:00
columnSpacing: 20
2019-09-06 00:11:12 +02:00
columns: 2
2018-04-22 20:07:31 +02:00
2019-02-01 22:20:38 +01:00
MoneroComponents.CheckBox {
2018-04-22 20:07:31 +02:00
id: segregatePreForkOutputs
checked: persistentSettings.segregatePreForkOutputs
text: qsTr("I intend to spend on key-reusing fork(s)") + translationManager.emptyString
onClicked: {
persistentSettings.segregatePreForkOutputs = segregatePreForkOutputs.checked
if (appWindow.currentWallet) {
appWindow.currentWallet.segregatePreForkOutputs(segregatePreForkOutputs.checked)
}
}
}
2018-04-22 20:07:31 +02:00
2019-02-01 22:20:38 +01:00
MoneroComponents.CheckBox {
2018-04-22 20:07:31 +02:00
id: keyReuseMitigation2
checked: persistentSettings.keyReuseMitigation2
text: qsTr("I might want to spend on key-reusing fork(s)") + translationManager.emptyString
onClicked: {
2018-04-22 20:07:31 +02:00
persistentSettings.keyReuseMitigation2 = keyReuseMitigation2.checked
if (appWindow.currentWallet) {
appWindow.currentWallet.keyReuseMitigation2(keyReuseMitigation2.checked)
}
}
}
2019-02-01 22:20:38 +01:00
MoneroComponents.CheckBox {
2018-04-22 20:07:31 +02:00
id: setRingRelative
checked: true
text: qsTr("Relative") + translationManager.emptyString
}
}
2018-04-22 20:07:31 +02:00
2019-04-11 03:17:29 +02:00
GridLayout {
id: segregationHeightRow
2019-01-07 16:59:14 +01:00
Layout.fillWidth: true
2019-04-25 21:09:23 +02:00
Layout.topMargin: 17
2019-09-06 00:11:12 +02:00
columns: 2
2019-04-25 21:09:23 +02:00
columnSpacing: 32
2019-02-01 22:20:38 +01:00
MoneroComponents.LineEdit {
id: segregationHeightLine
2019-04-11 03:17:29 +02:00
property bool edited: false
2019-02-01 22:20:38 +01:00
Layout.fillWidth: true
2019-04-25 21:09:23 +02:00
placeholderFontSize: 16
labelFontSize: 14
2019-04-11 03:17:29 +02:00
labelText: qsTr("Set segregation height:") + translationManager.emptyString
validator: IntValidator { bottom: 0 }
2019-02-01 22:20:38 +01:00
readOnly: false
onEditingFinished: {
persistentSettings.segregationHeight = segregationHeightLine.text
if (appWindow.currentWallet) {
appWindow.currentWallet.segregationHeight(segregationHeightLine.text)
}
2019-04-11 03:17:29 +02:00
// @TODO: LineEdit should visually be able show that an action
// has been completed due to modification of the text
}
}
2019-04-11 03:17:29 +02:00
Item {
Layout.fillWidth: true
}
}
}
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)
}
}