2018-01-07 05:20:45 +00:00
|
|
|
// Copyright (c) 2014-2018, The Monero Project
|
2016-02-02 21:09:45 +00:00
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
|
|
|
|
import QtQuick 2.2
|
2016-10-07 20:05:51 +00:00
|
|
|
import moneroComponents.TranslationManager 1.0
|
2016-02-02 21:09:45 +00:00
|
|
|
import QtQuick.Dialogs 1.2
|
2017-01-26 20:54:31 +00:00
|
|
|
import QtQuick.Layouts 1.2
|
2016-10-07 23:48:42 +00:00
|
|
|
import "../components"
|
2017-01-26 20:54:31 +00:00
|
|
|
import 'utils.js' as Utils
|
2016-02-02 21:09:45 +00:00
|
|
|
|
2017-01-30 09:37:14 +00:00
|
|
|
// Reusable component for mnaging wallet (account name, path, private key)
|
2017-01-26 20:54:31 +00:00
|
|
|
ColumnLayout {
|
2017-01-30 09:37:14 +00:00
|
|
|
id: page
|
|
|
|
Layout.leftMargin: wizardLeftMargin
|
|
|
|
Layout.rightMargin: wizardRightMargin
|
2016-02-02 21:09:45 +00:00
|
|
|
property alias titleText: titleText.text
|
|
|
|
property alias accountNameText: accountName.text
|
|
|
|
property alias walletPath: fileUrlInput.text
|
2016-02-06 12:49:31 +00:00
|
|
|
property alias wordsTextItem : memoTextItem
|
2016-10-07 23:48:42 +00:00
|
|
|
property alias restoreHeight : restoreHeightItem.text
|
|
|
|
property alias restoreHeightVisible: restoreHeightItem.visible
|
2017-01-04 16:25:22 +00:00
|
|
|
property alias walletName : accountName.text
|
|
|
|
property alias progressDotsModel : progressDots.model
|
2017-01-26 20:54:31 +00:00
|
|
|
property alias recoverFromKeysAddress: addressLine.text;
|
|
|
|
property alias recoverFromKeysViewKey: viewKeyLine.text;
|
|
|
|
property alias recoverFromKeysSpendKey: spendKeyLine.text;
|
|
|
|
// recover mode or create new wallet
|
|
|
|
property bool recoverMode: false
|
|
|
|
// Recover form seed or keys
|
|
|
|
property bool recoverFromSeedMode: true
|
2017-03-03 23:32:53 +00:00
|
|
|
property int rowSpacing: 10
|
2016-02-02 21:09:45 +00:00
|
|
|
|
2017-01-26 20:54:31 +00:00
|
|
|
function checkFields(){
|
2018-03-05 16:19:45 +00:00
|
|
|
var addressOK = walletManager.addressValid(addressLine.text, persistentSettings.nettype)
|
|
|
|
var viewKeyOK = walletManager.keyValid(viewKeyLine.text, addressLine.text, true, persistentSettings.nettype)
|
2017-01-26 20:54:31 +00:00
|
|
|
// Spendkey is optional
|
2018-03-05 16:19:45 +00:00
|
|
|
var spendKeyOK = (spendKeyLine.text.length > 0)? walletManager.keyValid(spendKeyLine.text, addressLine.text, false, persistentSettings.nettype) : true
|
2016-02-02 21:09:45 +00:00
|
|
|
|
2017-01-26 20:54:31 +00:00
|
|
|
addressLine.error = !addressOK && addressLine.text.length != 0
|
|
|
|
viewKeyLine.error = !viewKeyOK && viewKeyLine.text.length != 0
|
|
|
|
spendKeyLine.error = !spendKeyOK && spendKeyLine.text.length != 0
|
|
|
|
|
|
|
|
return addressOK && viewKeyOK && spendKeyOK
|
|
|
|
}
|
|
|
|
|
|
|
|
function checkNextButton(){
|
|
|
|
wizard.nextButton.enabled = false
|
|
|
|
console.log("check next", recoverFromSeed.visible)
|
|
|
|
if(recoverMode && !recoverFromSeedMode) {
|
|
|
|
console.log("checking key fields")
|
|
|
|
wizard.nextButton.enabled = checkFields();
|
|
|
|
} else if (recoverMode && recoverFromSeedMode) {
|
|
|
|
wizard.nextButton.enabled = checkSeed()
|
|
|
|
} else
|
|
|
|
wizard.nextButton.enabled = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function checkSeed() {
|
|
|
|
console.log("Checking seed")
|
|
|
|
var wordsArray = Utils.lineBreaksToSpaces(uiItem.wordsTextItem.memoText).split(" ");
|
2018-02-25 12:52:04 +00:00
|
|
|
return wordsArray.length === 25 || wordsArray.length === 24
|
2017-01-26 20:54:31 +00:00
|
|
|
}
|
|
|
|
|
2017-08-06 15:29:43 +00:00
|
|
|
function updateFromQrCode(address, payment_id, amount, tx_description, recipient_name, extra_parameters) {
|
|
|
|
// Switch to recover from keys
|
|
|
|
recoverFromSeedMode = false
|
|
|
|
spendKeyLine.text = ""
|
|
|
|
viewKeyLine.text = ""
|
|
|
|
restoreHeightItem.text = ""
|
|
|
|
|
|
|
|
|
|
|
|
if(typeof extra_parameters.secret_view_key != "undefined") {
|
|
|
|
viewKeyLine.text = extra_parameters.secret_view_key
|
|
|
|
}
|
|
|
|
if(typeof extra_parameters.secret_spend_key != "undefined") {
|
|
|
|
spendKeyLine.text = extra_parameters.secret_spend_key
|
|
|
|
}
|
|
|
|
if(typeof extra_parameters.restore_height != "undefined") {
|
|
|
|
restoreHeightItem.text = extra_parameters.restore_height
|
|
|
|
}
|
|
|
|
addressLine.text = address
|
|
|
|
|
|
|
|
cameraUi.qrcode_decoded.disconnect(updateFromQrCode)
|
|
|
|
|
|
|
|
// Check if keys are correct
|
|
|
|
checkNextButton();
|
|
|
|
}
|
|
|
|
|
2017-01-26 20:54:31 +00:00
|
|
|
RowLayout {
|
2016-02-02 21:09:45 +00:00
|
|
|
id: dotsRow
|
2017-01-26 20:54:31 +00:00
|
|
|
Layout.alignment: Qt.AlignRight
|
2016-02-02 21:09:45 +00:00
|
|
|
spacing: 6
|
|
|
|
|
|
|
|
ListModel {
|
|
|
|
id: dotsModel
|
2017-08-06 15:11:12 +00:00
|
|
|
ListElement { dotColor: "#FFE00A" }
|
|
|
|
ListElement { dotColor: "#DBDBDB" }
|
2016-02-02 21:09:45 +00:00
|
|
|
ListElement { dotColor: "#DBDBDB" }
|
|
|
|
ListElement { dotColor: "#DBDBDB" }
|
|
|
|
}
|
|
|
|
|
|
|
|
Repeater {
|
2017-01-04 16:25:22 +00:00
|
|
|
id: progressDots
|
2016-02-02 21:09:45 +00:00
|
|
|
model: dotsModel
|
|
|
|
delegate: Rectangle {
|
|
|
|
width: 12; height: 12
|
|
|
|
radius: 6
|
|
|
|
color: dotColor
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-26 20:54:31 +00:00
|
|
|
RowLayout {
|
2016-02-02 21:09:45 +00:00
|
|
|
id: headerColumn
|
2017-01-30 09:37:14 +00:00
|
|
|
Layout.fillWidth: true
|
2016-02-02 21:09:45 +00:00
|
|
|
Text {
|
2017-01-26 20:54:31 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
2016-02-02 21:09:45 +00:00
|
|
|
id: titleText
|
|
|
|
font.family: "Arial"
|
2017-08-06 15:03:16 +00:00
|
|
|
font.pixelSize: 28 * scaleRatio
|
2016-02-02 21:09:45 +00:00
|
|
|
wrapMode: Text.Wrap
|
|
|
|
color: "#3F3F3F"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-26 20:54:31 +00:00
|
|
|
ColumnLayout {
|
2017-01-30 09:37:14 +00:00
|
|
|
Layout.bottomMargin: rowSpacing
|
2016-02-02 21:09:45 +00:00
|
|
|
|
2017-01-26 20:54:31 +00:00
|
|
|
Label {
|
2017-08-06 15:03:16 +00:00
|
|
|
Layout.topMargin: 20 * scaleRatio
|
2018-03-24 17:22:38 +00:00
|
|
|
fontFamily: "Arial"
|
2018-01-21 18:14:34 +00:00
|
|
|
fontColor: "#555555"
|
2017-08-06 15:03:16 +00:00
|
|
|
fontSize: 14 * scaleRatio
|
2017-01-30 09:37:14 +00:00
|
|
|
text: qsTr("Wallet name")
|
|
|
|
+ translationManager.emptyString
|
2017-01-26 20:54:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
LineEdit {
|
2016-02-02 21:09:45 +00:00
|
|
|
id: accountName
|
2017-01-26 20:54:31 +00:00
|
|
|
Layout.fillWidth: true
|
2017-08-06 15:03:16 +00:00
|
|
|
Layout.maximumWidth: 600 * scaleRatio
|
|
|
|
Layout.minimumWidth: 200 * scaleRatio
|
2016-10-29 14:36:32 +00:00
|
|
|
text: defaultAccountName
|
2017-01-26 20:54:31 +00:00
|
|
|
onTextUpdated: checkNextButton()
|
2018-01-21 18:14:34 +00:00
|
|
|
borderColor: Qt.rgba(0, 0, 0, 0.15)
|
|
|
|
backgroundColor: "white"
|
|
|
|
fontColor: "black"
|
|
|
|
fontBold: false
|
2017-01-26 20:54:31 +00:00
|
|
|
}
|
|
|
|
}
|
2016-10-29 14:36:32 +00:00
|
|
|
|
2017-08-06 15:29:43 +00:00
|
|
|
GridLayout{
|
|
|
|
columns: (isMobile)? 2 : 4
|
2017-01-26 20:54:31 +00:00
|
|
|
visible: recoverMode
|
2017-08-06 15:29:43 +00:00
|
|
|
|
2017-01-26 20:54:31 +00:00
|
|
|
StandardButton {
|
|
|
|
id: recoverFromSeedButton
|
|
|
|
text: qsTr("Restore from seed") + translationManager.emptyString
|
|
|
|
enabled: recoverFromKeys.visible
|
|
|
|
onClicked: {
|
|
|
|
recoverFromSeedMode = true;
|
|
|
|
checkNextButton();
|
2016-10-29 14:36:32 +00:00
|
|
|
}
|
2016-02-02 21:09:45 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 20:54:31 +00:00
|
|
|
StandardButton {
|
|
|
|
id: recoverFromKeysButton
|
|
|
|
text: qsTr("Restore from keys") + translationManager.emptyString
|
|
|
|
enabled: recoverFromSeed.visible
|
|
|
|
onClicked: {
|
|
|
|
recoverFromSeedMode = false;
|
|
|
|
checkNextButton();
|
|
|
|
}
|
2016-02-02 21:09:45 +00:00
|
|
|
}
|
2017-08-06 15:29:43 +00:00
|
|
|
|
|
|
|
StandardButton {
|
|
|
|
id: qrfinderButton
|
|
|
|
text: qsTr("From QR Code") + translationManager.emptyString
|
|
|
|
visible : true //appWindow.qrScannerEnabled
|
|
|
|
enabled : visible
|
|
|
|
onClicked: {
|
|
|
|
cameraUi.state = "Capture"
|
|
|
|
cameraUi.qrcode_decoded.connect(updateFromQrCode)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-02 21:09:45 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 20:54:31 +00:00
|
|
|
// Recover from seed
|
|
|
|
RowLayout {
|
|
|
|
id: recoverFromSeed
|
|
|
|
visible: !recoverMode || ( recoverMode && recoverFromSeedMode)
|
|
|
|
WizardMemoTextInput {
|
|
|
|
id : memoTextItem
|
|
|
|
Layout.fillWidth: true
|
2017-08-06 15:03:16 +00:00
|
|
|
Layout.maximumWidth: 600 * scaleRatio
|
|
|
|
Layout.minimumWidth: 200 * scaleRatio
|
2017-01-26 20:54:31 +00:00
|
|
|
}
|
2016-02-02 21:09:45 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 20:54:31 +00:00
|
|
|
// Recover from keys
|
|
|
|
GridLayout {
|
2017-01-30 09:37:14 +00:00
|
|
|
Layout.bottomMargin: page.rowSpacing
|
|
|
|
rowSpacing: page.rowSpacing
|
2017-01-26 20:54:31 +00:00
|
|
|
id: recoverFromKeys
|
|
|
|
visible: recoverMode && !recoverFromSeedMode
|
|
|
|
columns: 1
|
|
|
|
LineEdit {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
id: addressLine
|
2017-08-06 15:03:16 +00:00
|
|
|
Layout.maximumWidth: 600 * scaleRatio
|
|
|
|
Layout.minimumWidth: 200 * scaleRatio
|
2018-03-27 19:32:39 +00:00
|
|
|
placeholderFontBold: true
|
|
|
|
placeholderFontFamily: "Arial"
|
|
|
|
placeholderColor: Style.legacy_placeholderFontColor
|
2017-03-11 05:09:09 +00:00
|
|
|
placeholderText: qsTr("Account address (public)") + translationManager.emptyString
|
2018-03-27 19:32:39 +00:00
|
|
|
placeholderOpacity: 1.0
|
2017-01-26 20:54:31 +00:00
|
|
|
onTextUpdated: checkNextButton()
|
2018-01-21 18:14:34 +00:00
|
|
|
borderColor: Qt.rgba(0, 0, 0, 0.15)
|
|
|
|
backgroundColor: "white"
|
|
|
|
fontColor: "black"
|
|
|
|
fontBold: false
|
2017-01-26 20:54:31 +00:00
|
|
|
}
|
|
|
|
LineEdit {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
id: viewKeyLine
|
2017-08-06 15:03:16 +00:00
|
|
|
Layout.maximumWidth: 600 * scaleRatio
|
|
|
|
Layout.minimumWidth: 200 * scaleRatio
|
2018-03-27 19:32:39 +00:00
|
|
|
placeholderFontBold: true
|
|
|
|
placeholderFontFamily: "Arial"
|
|
|
|
placeholderColor: Style.legacy_placeholderFontColor
|
2017-03-11 05:09:09 +00:00
|
|
|
placeholderText: qsTr("View key (private)") + translationManager.emptyString
|
2018-03-27 19:32:39 +00:00
|
|
|
placeholderOpacity: 1.0
|
2017-01-26 20:54:31 +00:00
|
|
|
onTextUpdated: checkNextButton()
|
2018-01-21 18:14:34 +00:00
|
|
|
borderColor: Qt.rgba(0, 0, 0, 0.15)
|
|
|
|
backgroundColor: "white"
|
|
|
|
fontColor: "black"
|
|
|
|
fontBold: false
|
2016-02-02 21:09:45 +00:00
|
|
|
|
2017-01-26 20:54:31 +00:00
|
|
|
}
|
|
|
|
LineEdit {
|
|
|
|
Layout.fillWidth: true
|
2017-08-06 15:03:16 +00:00
|
|
|
Layout.maximumWidth: 600 * scaleRatio
|
|
|
|
Layout.minimumWidth: 200 * scaleRatio
|
2017-01-26 20:54:31 +00:00
|
|
|
id: spendKeyLine
|
2018-03-27 19:32:39 +00:00
|
|
|
placeholderFontBold: true
|
|
|
|
placeholderFontFamily: "Arial"
|
|
|
|
placeholderColor: Style.legacy_placeholderFontColor
|
2017-03-11 05:09:09 +00:00
|
|
|
placeholderText: qsTr("Spend key (private)") + translationManager.emptyString
|
2018-03-27 19:32:39 +00:00
|
|
|
placeholderOpacity: 1.0
|
2017-01-26 20:54:31 +00:00
|
|
|
onTextUpdated: checkNextButton()
|
2018-01-21 18:14:34 +00:00
|
|
|
borderColor: Qt.rgba(0, 0, 0, 0.15)
|
|
|
|
backgroundColor: "white"
|
|
|
|
fontColor: "black"
|
|
|
|
fontBold: false
|
2016-10-07 23:48:42 +00:00
|
|
|
}
|
|
|
|
}
|
2017-01-30 09:37:14 +00:00
|
|
|
|
|
|
|
// Restore Height
|
2017-01-26 20:54:31 +00:00
|
|
|
RowLayout {
|
|
|
|
LineEdit {
|
|
|
|
id: restoreHeightItem
|
2017-03-03 18:44:04 +00:00
|
|
|
Layout.fillWidth: true
|
2017-08-06 15:03:16 +00:00
|
|
|
Layout.maximumWidth: 600 * scaleRatio
|
|
|
|
Layout.minimumWidth: 200 * scaleRatio
|
2018-03-27 19:32:39 +00:00
|
|
|
placeholderFontBold: true
|
|
|
|
placeholderFontFamily: "Arial"
|
|
|
|
placeholderColor: Style.legacy_placeholderFontColor
|
2017-03-11 05:09:09 +00:00
|
|
|
placeholderText: qsTr("Restore height (optional)") + translationManager.emptyString
|
2018-03-27 19:32:39 +00:00
|
|
|
placeholderOpacity: 1.0
|
2017-01-26 20:54:31 +00:00
|
|
|
validator: IntValidator {
|
|
|
|
bottom:0
|
2016-02-02 21:09:45 +00:00
|
|
|
}
|
2018-01-21 18:14:34 +00:00
|
|
|
borderColor: Qt.rgba(0, 0, 0, 0.15)
|
|
|
|
backgroundColor: "white"
|
|
|
|
fontColor: "black"
|
|
|
|
fontBold: false
|
2017-01-26 20:54:31 +00:00
|
|
|
}
|
|
|
|
}
|
2016-02-02 21:09:45 +00:00
|
|
|
|
2017-01-30 09:37:14 +00:00
|
|
|
// Wallet store location
|
2017-01-26 20:54:31 +00:00
|
|
|
ColumnLayout {
|
|
|
|
Label {
|
|
|
|
Layout.fillWidth: true
|
2017-08-06 15:03:16 +00:00
|
|
|
Layout.topMargin: 20 * scaleRatio
|
2017-01-26 20:54:31 +00:00
|
|
|
fontSize: 14
|
2018-03-27 19:32:39 +00:00
|
|
|
fontFamily: "Arial"
|
2018-01-21 18:14:34 +00:00
|
|
|
fontColor: "#555555"
|
2017-06-01 23:20:32 +00:00
|
|
|
text: qsTr("Your wallet is stored in") + ": " + fileUrlInput.text;
|
2017-01-26 20:54:31 +00:00
|
|
|
}
|
|
|
|
|
2017-02-05 19:22:50 +00:00
|
|
|
LineEdit {
|
2017-01-26 20:54:31 +00:00
|
|
|
Layout.fillWidth: true
|
2017-08-06 15:03:16 +00:00
|
|
|
Layout.maximumWidth: 600 * scaleRatio
|
|
|
|
Layout.minimumWidth: 200 * scaleRatio
|
2017-01-26 20:54:31 +00:00
|
|
|
id: fileUrlInput
|
|
|
|
text: moneroAccountsDir + "/"
|
2017-01-30 09:37:14 +00:00
|
|
|
|
2017-01-26 20:54:31 +00:00
|
|
|
// workaround for the bug "filechooser only opens once"
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: {
|
|
|
|
mouse.accepted = false
|
|
|
|
fileDialog.folder = walletManager.localPathToUrl(fileUrlInput.text)
|
|
|
|
fileDialog.open()
|
|
|
|
fileUrlInput.focus = true
|
2016-02-02 21:09:45 +00:00
|
|
|
}
|
|
|
|
}
|
2018-01-21 18:14:34 +00:00
|
|
|
borderColor: Qt.rgba(0, 0, 0, 0.15)
|
|
|
|
backgroundColor: "white"
|
|
|
|
fontColor: "black"
|
|
|
|
fontBold: false
|
2017-01-26 20:54:31 +00:00
|
|
|
}
|
2016-02-02 21:09:45 +00:00
|
|
|
|
2017-01-26 20:54:31 +00:00
|
|
|
FileDialog {
|
|
|
|
id: fileDialog
|
|
|
|
selectMultiple: false
|
|
|
|
selectFolder: true
|
|
|
|
title: qsTr("Please choose a directory") + translationManager.emptyString
|
|
|
|
onAccepted: {
|
|
|
|
fileUrlInput.text = walletManager.urlToLocalPath(fileDialog.folder)
|
|
|
|
fileDialog.visible = false
|
|
|
|
}
|
|
|
|
onRejected: {
|
|
|
|
fileDialog.visible = false
|
2016-02-02 21:09:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|