2019-01-14 00:02:44 +00:00
|
|
|
|
// Copyright (c) 2014-2019, 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-08 01:43:18 +00:00
|
|
|
|
import QtQml 2.0
|
2019-04-11 01:17:29 +00:00
|
|
|
|
import QtQuick 2.9
|
2019-04-08 01:43:18 +00:00
|
|
|
|
import QtQuick.Controls 2.0
|
2019-01-14 00:02:44 +00:00
|
|
|
|
import QtQuick.Controls 1.4
|
2019-04-08 01:43:18 +00:00
|
|
|
|
import QtGraphicalEffects 1.0
|
2019-04-11 01:17:29 +00:00
|
|
|
|
import QtQuick.Controls.Styles 1.4
|
|
|
|
|
import QtQuick.Layouts 1.2
|
|
|
|
|
import QtQuick.Dialogs 1.2
|
2019-01-14 00:02:44 +00:00
|
|
|
|
import moneroComponents.Wallet 1.0
|
2019-04-08 01:43:18 +00:00
|
|
|
|
|
2019-01-14 00:02:44 +00:00
|
|
|
|
import "../js/Wizard.js" as Wizard
|
|
|
|
|
import "../js/Windows.js" as Windows
|
|
|
|
|
import "../js/Utils.js" as Utils
|
|
|
|
|
import "../components" as MoneroComponents
|
2019-04-11 01:17:29 +00:00
|
|
|
|
import "../components/effects/" as MoneroEffects
|
2019-01-14 00:02:44 +00:00
|
|
|
|
import "../pages"
|
|
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
|
id: wizardController
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
|
|
signal useMoneroClicked()
|
2019-03-27 08:28:42 +00:00
|
|
|
|
signal walletCreatedFromDevice(bool success)
|
2019-01-14 00:02:44 +00:00
|
|
|
|
|
|
|
|
|
function restart() {
|
2019-04-26 00:44:01 +00:00
|
|
|
|
// Clear up any state, including `m_wallet`, which
|
|
|
|
|
// is the temp. wallet object whilst creating new wallets.
|
|
|
|
|
// This function is called automatically by navigating to `wizardHome`.
|
2019-01-14 00:02:44 +00:00
|
|
|
|
wizardStateView.state = "wizardHome"
|
|
|
|
|
wizardController.walletOptionsName = defaultAccountName;
|
|
|
|
|
wizardController.walletOptionsLocation = '';
|
|
|
|
|
wizardController.walletOptionsPassword = '';
|
|
|
|
|
wizardController.walletOptionsSeed = '';
|
2020-02-11 23:34:15 +00:00
|
|
|
|
wizardController.walletOptionsSeedOffset = '';
|
2019-02-25 16:30:59 +00:00
|
|
|
|
wizardController.walletOptionsRecoverAddress = ''
|
|
|
|
|
wizardController.walletOptionsRecoverViewkey = ''
|
|
|
|
|
wizardController.walletOptionsRecoverSpendkey = ''
|
2019-01-14 00:02:44 +00:00
|
|
|
|
wizardController.walletOptionsBackup = '';
|
|
|
|
|
wizardController.walletRestoreMode = 'seed';
|
|
|
|
|
wizardController.walletOptionsRestoreHeight = 0;
|
|
|
|
|
wizardController.walletOptionsIsRecovering = false;
|
|
|
|
|
wizardController.walletOptionsIsRecoveringFromDevice = false;
|
|
|
|
|
wizardController.walletOptionsDeviceName = '';
|
2019-03-01 07:20:05 +00:00
|
|
|
|
wizardController.walletOptionsDeviceIsRestore = false;
|
2019-01-14 00:02:44 +00:00
|
|
|
|
wizardController.tmpWalletFilename = '';
|
2019-02-25 16:30:59 +00:00
|
|
|
|
wizardController.walletOptionsSubaddressLookahead = '';
|
2019-03-27 08:28:42 +00:00
|
|
|
|
disconnect();
|
2019-04-26 00:44:01 +00:00
|
|
|
|
|
|
|
|
|
if (typeof wizardController.m_wallet !== 'undefined'){
|
|
|
|
|
walletManager.closeWallet();
|
|
|
|
|
wizardController.m_wallet = undefined;
|
|
|
|
|
}
|
2019-01-14 00:02:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
property var m_wallet;
|
|
|
|
|
property alias wizardState: wizardStateView.state
|
2021-07-05 20:03:12 +00:00
|
|
|
|
property alias wizardStateView: wizardStateView
|
2019-04-15 02:59:04 +00:00
|
|
|
|
property alias wizardStackView: stackView
|
2019-04-25 19:09:23 +00:00
|
|
|
|
property int wizardSubViewWidth: 780
|
|
|
|
|
property int wizardSubViewTopMargin: persistentSettings.customDecorations ? 90 : 32
|
2019-01-14 00:02:44 +00:00
|
|
|
|
property bool skipModeSelection: false
|
|
|
|
|
|
|
|
|
|
// wallet variables
|
|
|
|
|
property string walletOptionsName: ''
|
|
|
|
|
property string walletOptionsLocation: ''
|
|
|
|
|
property string walletOptionsPassword: ''
|
|
|
|
|
property string walletOptionsSeed: ''
|
2020-02-11 23:34:15 +00:00
|
|
|
|
property string walletOptionsSeedOffset: ''
|
2019-02-23 02:26:51 +00:00
|
|
|
|
property string walletOptionsRecoverAddress: ''
|
|
|
|
|
property string walletOptionsRecoverViewkey: ''
|
|
|
|
|
property string walletOptionsRecoverSpendkey: ''
|
2019-01-14 00:02:44 +00:00
|
|
|
|
property string walletOptionsBackup: ''
|
|
|
|
|
property int walletOptionsRestoreHeight: 0
|
|
|
|
|
property string walletOptionsBootstrapAddress: persistentSettings.bootstrapNodeAddress
|
|
|
|
|
property bool walletOptionsRestoringFromDevice: false
|
|
|
|
|
property bool walletOptionsIsRecovering: false
|
|
|
|
|
property bool walletOptionsIsRecoveringFromDevice: false
|
|
|
|
|
property string walletOptionsSubaddressLookahead: ''
|
|
|
|
|
property string walletOptionsDeviceName: ''
|
2019-03-01 07:20:05 +00:00
|
|
|
|
property bool walletOptionsDeviceIsRestore: false
|
2019-01-14 00:02:44 +00:00
|
|
|
|
property string tmpWalletFilename: ''
|
|
|
|
|
|
|
|
|
|
// recovery made (restore wallet)
|
|
|
|
|
property string walletRestoreMode: 'seed' // seed, keys, qr
|
|
|
|
|
|
2019-04-08 01:43:18 +00:00
|
|
|
|
|
2019-01-14 00:02:44 +00:00
|
|
|
|
property int layoutScale: {
|
2019-09-05 22:11:12 +00:00
|
|
|
|
if(appWindow.width < 800){
|
2019-01-14 00:02:44 +00:00
|
|
|
|
return 1;
|
|
|
|
|
} else {
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
|
id: wizardStateView
|
|
|
|
|
property Item currentView
|
|
|
|
|
property Item previousView
|
|
|
|
|
property WizardLanguage wizardLanguageView: WizardLanguage { }
|
|
|
|
|
property WizardHome wizardHomeView: WizardHome { }
|
|
|
|
|
property WizardCreateWallet1 wizardCreateWallet1View: WizardCreateWallet1 { }
|
|
|
|
|
property WizardCreateWallet2 wizardCreateWallet2View: WizardCreateWallet2 { }
|
|
|
|
|
property WizardCreateWallet3 wizardCreateWallet3View: WizardCreateWallet3 { }
|
|
|
|
|
property WizardCreateWallet4 wizardCreateWallet4View: WizardCreateWallet4 { }
|
|
|
|
|
property WizardRestoreWallet1 wizardRestoreWallet1View: WizardRestoreWallet1 { }
|
|
|
|
|
property WizardRestoreWallet2 wizardRestoreWallet2View: WizardRestoreWallet2 { }
|
|
|
|
|
property WizardRestoreWallet3 wizardRestoreWallet3View: WizardRestoreWallet3 { }
|
|
|
|
|
property WizardRestoreWallet4 wizardRestoreWallet4View: WizardRestoreWallet4 { }
|
|
|
|
|
property WizardCreateDevice1 wizardCreateDevice1View: WizardCreateDevice1 { }
|
|
|
|
|
property WizardOpenWallet1 wizardOpenWallet1View: WizardOpenWallet1 { }
|
|
|
|
|
property WizardModeSelection wizardModeSelectionView: WizardModeSelection { }
|
|
|
|
|
property WizardModeRemoteNodeWarning wizardModeRemoteNodeWarningView: WizardModeRemoteNodeWarning { }
|
|
|
|
|
property WizardModeBootstrap wizardModeBootstrapView: WizardModeBootstrap {}
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
|
|
color: "transparent"
|
|
|
|
|
state: ''
|
|
|
|
|
|
|
|
|
|
onCurrentViewChanged: {
|
|
|
|
|
if (previousView) {
|
|
|
|
|
if (typeof previousView.onPageClosed === "function") {
|
|
|
|
|
previousView.onPageClosed();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-26 00:44:01 +00:00
|
|
|
|
if(previousView !== null && currentView.viewName === "wizardHome")
|
|
|
|
|
wizardController.restart();
|
|
|
|
|
|
2019-01-14 00:02:44 +00:00
|
|
|
|
if (currentView) {
|
|
|
|
|
stackView.replace(currentView)
|
|
|
|
|
// Calls when view is opened
|
|
|
|
|
if (typeof currentView.onPageCompleted === "function") {
|
|
|
|
|
currentView.onPageCompleted(previousView);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
previousView = currentView;
|
2019-04-15 02:59:04 +00:00
|
|
|
|
|
|
|
|
|
// reset push direction
|
|
|
|
|
if(wizardController.wizardState == "wizardHome")
|
|
|
|
|
wizardController.wizardStackView.backTransition = false;
|
2019-01-14 00:02:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
states: [
|
|
|
|
|
State {
|
|
|
|
|
name: "wizardLanguage"
|
|
|
|
|
PropertyChanges { target: wizardStateView; currentView: wizardStateView.wizardLanguageView }
|
2019-07-24 03:07:54 +00:00
|
|
|
|
PropertyChanges { target: wizardFlickable; contentHeight: wizardStateView.wizardLanguageView.pageHeight + 80 }
|
2019-01-14 00:02:44 +00:00
|
|
|
|
}, State {
|
|
|
|
|
name: "wizardHome"
|
|
|
|
|
PropertyChanges { target: wizardStateView; currentView: wizardStateView.wizardHomeView }
|
2019-09-08 15:06:14 +00:00
|
|
|
|
PropertyChanges { target: wizardFlickable; contentHeight: wizardStateView.wizardHomeView.pageHeight + 100 }
|
2019-01-14 00:02:44 +00:00
|
|
|
|
}, State {
|
|
|
|
|
name: "wizardCreateWallet1"
|
|
|
|
|
PropertyChanges { target: wizardStateView; currentView: wizardStateView.wizardCreateWallet1View }
|
2019-07-24 03:07:54 +00:00
|
|
|
|
PropertyChanges { target: wizardFlickable; contentHeight: wizardStateView.wizardCreateWallet1View.pageHeight + 80 }
|
2019-01-14 00:02:44 +00:00
|
|
|
|
}, State {
|
|
|
|
|
name: "wizardCreateWallet2"
|
|
|
|
|
PropertyChanges { target: wizardStateView; currentView: wizardStateView.wizardCreateWallet2View }
|
2019-07-24 03:07:54 +00:00
|
|
|
|
PropertyChanges { target: wizardFlickable; contentHeight: wizardStateView.wizardCreateWallet2View.pageHeight + 80 }
|
2019-01-14 00:02:44 +00:00
|
|
|
|
}, State {
|
|
|
|
|
name: "wizardCreateWallet3"
|
|
|
|
|
PropertyChanges { target: wizardStateView; currentView: wizardStateView.wizardCreateWallet3View }
|
2019-07-24 03:07:54 +00:00
|
|
|
|
PropertyChanges { target: wizardFlickable; contentHeight: wizardStateView.wizardCreateWallet3View.pageHeight + 80 }
|
2019-01-14 00:02:44 +00:00
|
|
|
|
}, State {
|
|
|
|
|
name: "wizardCreateWallet4"
|
|
|
|
|
PropertyChanges { target: wizardStateView; currentView: wizardStateView.wizardCreateWallet4View }
|
2019-07-24 03:07:54 +00:00
|
|
|
|
PropertyChanges { target: wizardFlickable; contentHeight: wizardStateView.wizardCreateWallet4View.pageHeight + 80 }
|
2019-01-14 00:02:44 +00:00
|
|
|
|
}, State {
|
|
|
|
|
name: "wizardRestoreWallet1"
|
|
|
|
|
PropertyChanges { target: wizardStateView; currentView: wizardStateView.wizardRestoreWallet1View }
|
2019-07-24 03:07:54 +00:00
|
|
|
|
PropertyChanges { target: wizardFlickable; contentHeight: wizardStateView.wizardRestoreWallet1View.pageHeight + 80 }
|
2019-01-14 00:02:44 +00:00
|
|
|
|
}, State {
|
|
|
|
|
name: "wizardRestoreWallet2"
|
|
|
|
|
PropertyChanges { target: wizardStateView; currentView: wizardStateView.wizardRestoreWallet2View }
|
2019-07-24 03:07:54 +00:00
|
|
|
|
PropertyChanges { target: wizardFlickable; contentHeight: wizardStateView.wizardRestoreWallet2View.pageHeight + 80 }
|
2019-01-14 00:02:44 +00:00
|
|
|
|
}, State {
|
|
|
|
|
name: "wizardRestoreWallet3"
|
|
|
|
|
PropertyChanges { target: wizardStateView; currentView: wizardStateView.wizardRestoreWallet3View }
|
2019-07-24 03:07:54 +00:00
|
|
|
|
PropertyChanges { target: wizardFlickable; contentHeight: wizardStateView.wizardRestoreWallet3View.pageHeight + 80 }
|
2019-01-14 00:02:44 +00:00
|
|
|
|
}, State {
|
|
|
|
|
name: "wizardRestoreWallet4"
|
|
|
|
|
PropertyChanges { target: wizardStateView; currentView: wizardStateView.wizardRestoreWallet4View }
|
2019-07-24 03:07:54 +00:00
|
|
|
|
PropertyChanges { target: wizardFlickable; contentHeight: wizardStateView.wizardRestoreWallet4View.pageHeight + 80 }
|
2019-01-14 00:02:44 +00:00
|
|
|
|
}, State {
|
|
|
|
|
name: "wizardCreateDevice1"
|
|
|
|
|
PropertyChanges { target: wizardStateView; currentView: wizardStateView.wizardCreateDevice1View }
|
2019-07-24 03:07:54 +00:00
|
|
|
|
PropertyChanges { target: wizardFlickable; contentHeight: wizardStateView.wizardCreateDevice1View.pageHeight + 80 }
|
2019-01-14 00:02:44 +00:00
|
|
|
|
}, State {
|
|
|
|
|
name: "wizardOpenWallet1"
|
|
|
|
|
PropertyChanges { target: wizardStateView; currentView: wizardStateView.wizardOpenWallet1View }
|
2019-07-24 03:07:54 +00:00
|
|
|
|
PropertyChanges { target: wizardFlickable; contentHeight: wizardStateView.wizardOpenWallet1View.pageHeight + 80 }
|
2019-01-14 00:02:44 +00:00
|
|
|
|
}, State {
|
|
|
|
|
name: "wizardModeSelection"
|
|
|
|
|
PropertyChanges { target: wizardStateView; currentView: wizardStateView.wizardModeSelectionView }
|
2019-07-24 03:07:54 +00:00
|
|
|
|
PropertyChanges { target: wizardFlickable; contentHeight: wizardStateView.wizardModeSelectionView.pageHeight + 80 }
|
2019-01-14 00:02:44 +00:00
|
|
|
|
}, State {
|
|
|
|
|
name: "wizardModeRemoteNodeWarning"
|
|
|
|
|
PropertyChanges { target: wizardStateView; currentView: wizardStateView.wizardModeRemoteNodeWarningView }
|
2019-07-24 03:07:54 +00:00
|
|
|
|
PropertyChanges { target: wizardFlickable; contentHeight: wizardStateView.wizardModeRemoteNodeWarningView.pageHeight + 80 }
|
2019-01-14 00:02:44 +00:00
|
|
|
|
}, State {
|
|
|
|
|
name: "wizardModeBootstrap"
|
|
|
|
|
PropertyChanges { target: wizardStateView; currentView: wizardStateView.wizardModeBootstrapView }
|
2019-07-24 03:07:54 +00:00
|
|
|
|
PropertyChanges { target: wizardFlickable; contentHeight: wizardStateView.wizardModeBootstrapView.pageHeight + 80 }
|
2019-01-14 00:02:44 +00:00
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
|
2019-04-11 01:17:29 +00:00
|
|
|
|
MoneroEffects.GradientBackground {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
fallBackColor: MoneroComponents.Style.middlePanelBackgroundColor
|
|
|
|
|
initialStartColor: MoneroComponents.Style.wizardBackgroundGradientStart
|
|
|
|
|
initialStopColor: MoneroComponents.Style.middlePanelBackgroundGradientStop
|
|
|
|
|
blackColorStart: MoneroComponents.Style._b_wizardBackgroundGradientStart
|
|
|
|
|
blackColorStop: MoneroComponents.Style._b_middlePanelBackgroundGradientStop
|
|
|
|
|
whiteColorStart: MoneroComponents.Style._w_wizardBackgroundGradientStart
|
|
|
|
|
whiteColorStop: MoneroComponents.Style._w_middlePanelBackgroundGradientStop
|
|
|
|
|
start: Qt.point(0, 0)
|
|
|
|
|
end: Qt.point(height, width)
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-08 01:43:18 +00:00
|
|
|
|
Flickable {
|
|
|
|
|
id: wizardFlickable
|
2019-01-14 00:02:44 +00:00
|
|
|
|
anchors.fill: parent
|
2019-04-08 01:43:18 +00:00
|
|
|
|
clip: true
|
2019-12-16 20:52:50 +00:00
|
|
|
|
boundsBehavior: isMac ? Flickable.DragAndOvershootBounds : Flickable.StopAtBounds
|
2019-04-08 01:43:18 +00:00
|
|
|
|
|
|
|
|
|
ScrollBar.vertical: ScrollBar {
|
2019-07-22 20:27:34 +00:00
|
|
|
|
parent: wizardController
|
2019-04-08 01:43:18 +00:00
|
|
|
|
anchors.left: parent.right
|
2019-07-22 20:27:34 +00:00
|
|
|
|
anchors.leftMargin: -14 // 10 margin + 4 scrollbar width
|
2019-04-08 01:43:18 +00:00
|
|
|
|
anchors.top: parent.top
|
2019-07-22 20:27:34 +00:00
|
|
|
|
anchors.topMargin: persistentSettings.customDecorations ? 60 : 10
|
2019-04-08 01:43:18 +00:00
|
|
|
|
anchors.bottom: parent.bottom
|
2019-07-22 20:27:34 +00:00
|
|
|
|
anchors.bottomMargin: persistentSettings.customDecorations ? 15 : 10
|
2019-12-21 15:02:06 +00:00
|
|
|
|
onActiveChanged: if (!active && !isMac) active = true
|
2019-04-08 01:43:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onFlickingChanged: {
|
|
|
|
|
releaseFocus();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StackView {
|
|
|
|
|
id: stackView
|
2019-04-29 06:43:34 +00:00
|
|
|
|
property bool backTransition: false
|
2019-04-08 01:43:18 +00:00
|
|
|
|
initialItem: wizardStateView.wizardLanguageView
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
clip: true
|
2019-01-14 00:02:44 +00:00
|
|
|
|
|
2019-04-08 01:43:18 +00:00
|
|
|
|
delegate: StackViewDelegate {
|
|
|
|
|
pushTransition: StackViewTransition {
|
|
|
|
|
PropertyAnimation {
|
|
|
|
|
target: enterItem
|
|
|
|
|
property: "x"
|
2019-04-15 02:59:04 +00:00
|
|
|
|
from: stackView.backTransition ? -target.width : target.width
|
2019-04-08 01:43:18 +00:00
|
|
|
|
to: 0
|
|
|
|
|
duration: 300
|
|
|
|
|
easing.type: Easing.OutCubic
|
|
|
|
|
}
|
|
|
|
|
PropertyAnimation {
|
|
|
|
|
target: exitItem
|
|
|
|
|
property: "x"
|
|
|
|
|
from: 0
|
2019-04-15 02:59:04 +00:00
|
|
|
|
to: stackView.backTransition ? target.width : -target.width
|
2019-04-08 01:43:18 +00:00
|
|
|
|
duration: 300
|
|
|
|
|
easing.type: Easing.OutCubic
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-01-14 00:02:44 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Open Wallet from file
|
|
|
|
|
FileDialog {
|
|
|
|
|
id: fileDialog
|
|
|
|
|
title: qsTr("Please choose a file") + translationManager.emptyString
|
2020-07-28 17:42:59 +00:00
|
|
|
|
folder: "file://" + appWindow.accountsDir
|
2019-01-14 00:02:44 +00:00
|
|
|
|
nameFilters: [ "Wallet files (*.keys)"]
|
|
|
|
|
sidebarVisible: false
|
|
|
|
|
|
|
|
|
|
onAccepted: {
|
|
|
|
|
wizardController.openWalletFile(fileDialog.fileUrl);
|
|
|
|
|
}
|
|
|
|
|
onRejected: {
|
|
|
|
|
console.log("Canceled")
|
|
|
|
|
appWindow.viewState = "wizard";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function createWallet() {
|
|
|
|
|
// Creates wallet in a temp. location
|
|
|
|
|
|
|
|
|
|
// Always delete the wallet object before creating new - we could be stepping back from recovering wallet
|
|
|
|
|
if (typeof wizardController.m_wallet !== 'undefined') {
|
|
|
|
|
walletManager.closeWallet()
|
|
|
|
|
console.log("deleting wallet")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var tmp_wallet_filename = oshelper.temporaryFilename();
|
|
|
|
|
console.log("Creating temporary wallet", tmp_wallet_filename)
|
|
|
|
|
var nettype = appWindow.persistentSettings.nettype;
|
|
|
|
|
var kdfRounds = appWindow.persistentSettings.kdfRounds;
|
2020-11-12 22:47:07 +00:00
|
|
|
|
var wallet = walletManager.createWallet(tmp_wallet_filename, "", persistentSettings.language_wallet, nettype, kdfRounds)
|
2019-01-14 00:02:44 +00:00
|
|
|
|
|
|
|
|
|
wizardController.walletOptionsSeed = wallet.seed
|
|
|
|
|
|
|
|
|
|
// saving wallet in "global" object
|
|
|
|
|
// @TODO: wallet should have a property pointing to the file where it stored or loaded from
|
|
|
|
|
wizardController.m_wallet = wallet;
|
|
|
|
|
wizardController.tmpWalletFilename = tmp_wallet_filename
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-26 02:23:51 +00:00
|
|
|
|
function writeWallet(onSuccess) {
|
2019-01-14 00:02:44 +00:00
|
|
|
|
// Save wallet files in user specified location
|
|
|
|
|
var new_wallet_filename = Wizard.createWalletPath(
|
|
|
|
|
isIOS,
|
|
|
|
|
wizardController.walletOptionsLocation,
|
|
|
|
|
wizardController.walletOptionsName);
|
|
|
|
|
|
2020-04-26 02:23:51 +00:00
|
|
|
|
const handler = function(success) {
|
|
|
|
|
if (!success) {
|
|
|
|
|
appWindow.showStatusMessage(qsTr("Failed to store the wallet"), 3);
|
2022-01-17 20:49:11 +00:00
|
|
|
|
wizardStateView.wizardRestoreWallet4View.wizardNav.btnNext.enabled = true;
|
|
|
|
|
wizardStateView.wizardCreateWallet4View.wizardNav.btnNext.enabled = true;
|
2020-04-26 02:23:51 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2019-01-14 00:02:44 +00:00
|
|
|
|
|
2020-04-26 02:23:51 +00:00
|
|
|
|
// make sure temporary wallet files are deleted
|
|
|
|
|
console.log("Removing temporary wallet: " + wizardController.tmpWalletFilename)
|
|
|
|
|
oshelper.removeTemporaryWallet(wizardController.tmpWalletFilename)
|
2019-01-14 00:02:44 +00:00
|
|
|
|
|
2020-04-26 02:23:51 +00:00
|
|
|
|
// protecting wallet with password
|
|
|
|
|
wizardController.m_wallet.setPassword(wizardController.walletOptionsPassword);
|
2019-01-14 00:02:44 +00:00
|
|
|
|
|
2020-04-26 02:23:51 +00:00
|
|
|
|
// save to persistent settings
|
|
|
|
|
persistentSettings.account_name = wizardController.walletOptionsName
|
|
|
|
|
persistentSettings.wallet_path = wizardController.m_wallet.path;
|
|
|
|
|
persistentSettings.restore_height = (isNaN(walletOptionsRestoreHeight))? 0 : walletOptionsRestoreHeight
|
2019-01-14 00:02:44 +00:00
|
|
|
|
|
2020-04-26 02:23:51 +00:00
|
|
|
|
persistentSettings.allow_background_mining = false
|
|
|
|
|
persistentSettings.is_recovering = (wizardController.walletOptionsIsRecovering === undefined) ? false : wizardController.walletOptionsIsRecovering
|
|
|
|
|
persistentSettings.is_recovering_from_device = (wizardController.walletOptionsIsRecoveringFromDevice === undefined) ? false : wizardController.walletOptionsIsRecoveringFromDevice
|
2020-02-26 17:53:35 +00:00
|
|
|
|
|
2020-04-26 02:23:51 +00:00
|
|
|
|
restart();
|
|
|
|
|
|
|
|
|
|
onSuccess();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (isIOS) {
|
2020-07-28 17:42:59 +00:00
|
|
|
|
new_wallet_filename = appWindow.accountsDir + new_wallet_filename;
|
2020-04-26 02:23:51 +00:00
|
|
|
|
}
|
|
|
|
|
console.log("saving new wallet to", new_wallet_filename);
|
|
|
|
|
wizardController.m_wallet.storeAsync(handler, new_wallet_filename);
|
2019-01-14 00:02:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-23 02:26:51 +00:00
|
|
|
|
function recoveryWallet() {
|
|
|
|
|
var nettype = persistentSettings.nettype;
|
|
|
|
|
var kdfRounds = persistentSettings.kdfRounds;
|
|
|
|
|
var restoreHeight = wizardController.walletOptionsRestoreHeight;
|
|
|
|
|
var tmp_wallet_filename = oshelper.temporaryFilename()
|
|
|
|
|
console.log("Creating temporary wallet", tmp_wallet_filename)
|
|
|
|
|
|
|
|
|
|
// delete the temporary wallet object before creating new
|
|
|
|
|
if (typeof wizardController.m_wallet !== 'undefined') {
|
|
|
|
|
walletManager.closeWallet()
|
|
|
|
|
console.log("deleting temporary wallet")
|
|
|
|
|
}
|
|
|
|
|
var wallet = ''
|
|
|
|
|
// From seed or keys
|
|
|
|
|
if(wizardController.walletRestoreMode === 'seed')
|
2020-02-11 23:34:15 +00:00
|
|
|
|
wallet = walletManager.recoveryWallet(tmp_wallet_filename, wizardController.walletOptionsSeed, wizardController.walletOptionsSeedOffset, nettype, restoreHeight, kdfRounds);
|
2019-02-23 02:26:51 +00:00
|
|
|
|
else
|
2020-11-12 22:47:07 +00:00
|
|
|
|
wallet = walletManager.createWalletFromKeys(tmp_wallet_filename, persistentSettings.language_wallet, nettype,
|
2019-02-23 02:26:51 +00:00
|
|
|
|
wizardController.walletOptionsRecoverAddress, wizardController.walletOptionsRecoverViewkey,
|
|
|
|
|
wizardController.walletOptionsRecoverSpendkey, restoreHeight, kdfRounds)
|
|
|
|
|
|
|
|
|
|
var success = wallet.status === Wallet.Status_Ok;
|
|
|
|
|
if (success) {
|
|
|
|
|
wizardController.m_wallet = wallet;
|
|
|
|
|
wizardController.walletOptionsIsRecovering = true;
|
|
|
|
|
wizardController.tmpWalletFilename = tmp_wallet_filename
|
|
|
|
|
} else {
|
|
|
|
|
console.log(wallet.errorString)
|
|
|
|
|
appWindow.showStatusMessage(qsTr(wallet.errorString), 5);
|
|
|
|
|
walletManager.closeWallet();
|
|
|
|
|
}
|
|
|
|
|
return success;
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-27 08:28:42 +00:00
|
|
|
|
function disconnect(){
|
|
|
|
|
walletManager.walletCreated.disconnect(onWalletCreated);
|
|
|
|
|
walletManager.walletPassphraseNeeded.disconnect(onWalletPassphraseNeeded);
|
|
|
|
|
walletManager.deviceButtonRequest.disconnect(onDeviceButtonRequest);
|
|
|
|
|
walletManager.deviceButtonPressed.disconnect(onDeviceButtonPressed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function connect(){
|
|
|
|
|
walletManager.walletCreated.connect(onWalletCreated);
|
|
|
|
|
walletManager.walletPassphraseNeeded.connect(onWalletPassphraseNeeded);
|
|
|
|
|
walletManager.deviceButtonRequest.connect(onDeviceButtonRequest);
|
|
|
|
|
walletManager.deviceButtonPressed.connect(onDeviceButtonPressed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function deviceAttentionSplash(){
|
|
|
|
|
appWindow.showProcessingSplash(qsTr("Please proceed to the device..."));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function creatingWalletDeviceSplash(){
|
2019-08-16 19:19:58 +00:00
|
|
|
|
var splashMsg = qsTr("Creating wallet from device...");
|
|
|
|
|
splashMsg += wizardController.walletOptionsDeviceName === "Ledger" ? qsTr("\n\nPlease check your hardware wallet –\nyour input may be required.") : "";
|
|
|
|
|
appWindow.showProcessingSplash(splashMsg);
|
2019-03-27 08:28:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-01-14 00:02:44 +00:00
|
|
|
|
function createWalletFromDevice() {
|
|
|
|
|
// TODO: create wallet in temporary filename and a) move it to the path specified by user after the final
|
|
|
|
|
// page submitted or b) delete it when program closed before reaching final page
|
|
|
|
|
|
|
|
|
|
// Always delete the wallet object before creating new - we could be stepping back from recovering wallet
|
|
|
|
|
if (typeof wizardController.m_wallet !== 'undefined') {
|
|
|
|
|
walletManager.closeWallet()
|
|
|
|
|
console.log("deleting wallet")
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-27 08:28:42 +00:00
|
|
|
|
tmpWalletFilename = oshelper.temporaryFilename();
|
|
|
|
|
console.log("Creating temporary wallet", tmpWalletFilename)
|
2019-01-14 00:02:44 +00:00
|
|
|
|
var nettype = persistentSettings.nettype;
|
2021-04-20 19:44:23 +00:00
|
|
|
|
var kdfRounds = persistentSettings.kdfRounds;
|
2019-01-14 00:02:44 +00:00
|
|
|
|
var restoreHeight = wizardController.walletOptionsRestoreHeight;
|
|
|
|
|
var subaddressLookahead = wizardController.walletOptionsSubaddressLookahead;
|
|
|
|
|
var deviceName = wizardController.walletOptionsDeviceName;
|
|
|
|
|
|
2019-03-27 08:28:42 +00:00
|
|
|
|
connect();
|
2021-04-20 19:44:23 +00:00
|
|
|
|
walletManager.createWalletFromDeviceAsync(tmpWalletFilename, "", nettype, deviceName, restoreHeight, subaddressLookahead, kdfRounds);
|
2019-03-27 08:28:42 +00:00
|
|
|
|
creatingWalletDeviceSplash();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onWalletCreated(wallet) {
|
|
|
|
|
splash.close()
|
2019-01-14 00:02:44 +00:00
|
|
|
|
|
|
|
|
|
var success = wallet.status === Wallet.Status_Ok;
|
|
|
|
|
if (success) {
|
|
|
|
|
wizardController.m_wallet = wallet;
|
|
|
|
|
wizardController.walletOptionsIsRecoveringFromDevice = true;
|
2019-03-01 07:20:05 +00:00
|
|
|
|
if (!wizardController.walletOptionsDeviceIsRestore) {
|
|
|
|
|
// User creates a hardware wallet for the first time. Use a recent block height from API.
|
|
|
|
|
wizardController.walletOptionsRestoreHeight = wizardController.m_wallet.walletCreationHeight;
|
|
|
|
|
}
|
2019-01-14 00:02:44 +00:00
|
|
|
|
} else {
|
|
|
|
|
console.log(wallet.errorString)
|
2019-03-27 08:28:42 +00:00
|
|
|
|
wizardController.tmpWalletFilename = '';
|
2019-01-14 00:02:44 +00:00
|
|
|
|
appWindow.showStatusMessage(qsTr(wallet.errorString), 5);
|
|
|
|
|
walletManager.closeWallet();
|
|
|
|
|
}
|
2019-03-27 08:28:42 +00:00
|
|
|
|
|
|
|
|
|
disconnect();
|
|
|
|
|
walletCreatedFromDevice(success);
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-11 10:43:21 +00:00
|
|
|
|
function onWalletPassphraseNeeded(on_device){
|
2019-03-27 08:28:42 +00:00
|
|
|
|
splash.close()
|
|
|
|
|
|
|
|
|
|
console.log(">>> wallet passphrase needed: ");
|
2020-04-11 10:43:21 +00:00
|
|
|
|
devicePassphraseDialog.onAcceptedCallback = function(passphrase) {
|
|
|
|
|
walletManager.onPassphraseEntered(passphrase, false, false);
|
2019-03-27 08:28:42 +00:00
|
|
|
|
creatingWalletDeviceSplash();
|
|
|
|
|
}
|
2020-04-11 10:43:21 +00:00
|
|
|
|
devicePassphraseDialog.onWalletEntryCallback = function() {
|
|
|
|
|
walletManager.onPassphraseEntered("", true, false);
|
2019-03-27 08:28:42 +00:00
|
|
|
|
creatingWalletDeviceSplash();
|
|
|
|
|
}
|
2020-04-11 10:43:21 +00:00
|
|
|
|
devicePassphraseDialog.onRejectedCallback = function() {
|
|
|
|
|
walletManager.onPassphraseEntered("", false, true);
|
|
|
|
|
creatingWalletDeviceSplash();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
devicePassphraseDialog.open(on_device)
|
2019-03-27 08:28:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onDeviceButtonRequest(code){
|
|
|
|
|
deviceAttentionSplash();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onDeviceButtonPressed(){
|
|
|
|
|
creatingWalletDeviceSplash();
|
2019-01-14 00:02:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function openWallet(){
|
|
|
|
|
if (typeof wizardController.m_wallet !== 'undefined' && wizardController.m_wallet != null) {
|
|
|
|
|
walletManager.closeWallet()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fileDialog.open();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function openWalletFile(fn) {
|
|
|
|
|
persistentSettings.restore_height = 0;
|
|
|
|
|
persistentSettings.is_recovering = false;
|
2019-04-20 05:38:55 +00:00
|
|
|
|
persistentSettings.is_recovering_from_device = false;
|
2019-01-14 00:02:44 +00:00
|
|
|
|
|
|
|
|
|
appWindow.restoreHeight = 0;
|
|
|
|
|
appWindow.walletPassword = "";
|
|
|
|
|
|
|
|
|
|
if(typeof fn == 'object')
|
|
|
|
|
persistentSettings.wallet_path = walletManager.urlToLocalPath(fn);
|
|
|
|
|
else
|
|
|
|
|
persistentSettings.wallet_path = fn;
|
|
|
|
|
|
|
|
|
|
if(isIOS)
|
2020-07-28 17:42:59 +00:00
|
|
|
|
persistentSettings.wallet_path = persistentSettings.wallet_path.replace(appWindow.accountsDir, "");
|
2019-01-14 00:02:44 +00:00
|
|
|
|
|
2019-12-13 14:30:25 +00:00
|
|
|
|
appWindow.openWallet();
|
2019-01-14 00:02:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
|
//
|
|
|
|
|
}
|
|
|
|
|
}
|