Files

199 lines
6.9 KiB
QML
Raw Permalink Normal View History

2022-11-21 19:29:46 +01:00
/*
* This file is part of the Flowee project
2024-05-03 13:05:17 +02:00
* Copyright (C) 2022-2024 Tom Zander <tom@flowee.org>
2022-11-21 19:29:46 +01:00
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick
import QtQuick.Layouts
import "../Flowee" as Flowee
2022-11-22 23:11:33 +01:00
import Flowee.org.pay
2022-11-21 19:29:46 +01:00
Page {
id: root
headerText: qsTr("New Bitcoin Cash Wallet")
Flickable {
2022-12-05 20:31:00 +01:00
anchors.fill: parent
contentHeight: column.height + 20
contentWidth: width
2022-11-23 10:33:18 +01:00
Column {
id: column
2022-12-05 20:31:00 +01:00
width: parent.width
y: 10
spacing: 20
2022-11-21 19:29:46 +01:00
2024-05-03 13:05:17 +02:00
Flowee.CardTypeSelector {
title: qsTr("New HD Wallet")
2026-03-14 21:14:42 +01:00
onClicked: thePile.push(newHDWalletScreen)
2024-05-03 13:05:17 +02:00
width: parent.width * 0.75
anchors.horizontalCenter: parent.horizontalCenter
2022-12-05 20:31:00 +01:00
2024-05-03 13:05:17 +02:00
features: [
qsTr("Seed-phrase based", "Context: wallet type"),
qsTr("Easy to backup", "Context: wallet type"),
qsTr("Most compatible", "The most compatible wallet type")
]
2022-12-05 20:31:00 +01:00
}
2024-05-05 21:55:57 +02:00
Flowee.CardTypeSelector {
title: qsTr("Import Existing Wallet")
width: parent.width * 0.75
2026-03-14 21:14:42 +01:00
onClicked: thePile.push("./ImportWalletPage.qml")
2024-05-05 21:55:57 +02:00
anchors.horizontalCenter: parent.horizontalCenter
features: [
qsTr("Imports seed-phrase"),
qsTr("Imports private key")
]
}
2024-05-03 13:05:17 +02:00
Flowee.CardTypeSelector {
title: qsTr("New Basic Wallet")
width: parent.width * 0.75
2026-03-14 21:14:42 +01:00
onClicked: thePile.push(newBaseWalletScreen)
2024-05-03 13:05:17 +02:00
anchors.horizontalCenter: parent.horizontalCenter
2022-11-21 19:29:46 +01:00
2024-05-03 13:05:17 +02:00
features: [
qsTr("Private keys based", "Property of a wallet"),
qsTr("Difficult to backup", "Context: wallet type"),
qsTr("Great for brief usage", "Context: wallet type")
]
}
2022-11-21 19:29:46 +01:00
}
2022-11-23 10:33:18 +01:00
}
2022-11-21 19:29:46 +01:00
2022-11-23 10:33:18 +01:00
// ------- the next screens
2022-11-21 19:29:46 +01:00
2022-11-23 10:33:18 +01:00
Item { // dummy item to allow components to be added to the parents GridLayout
Component {
id: newBaseWalletScreen
2022-11-21 19:29:46 +01:00
2022-11-23 10:33:18 +01:00
Page {
id: newWalletPage
headerText: qsTr("New Wallet")
2022-11-21 19:29:46 +01:00
2022-12-05 20:31:00 +01:00
ColumnLayout {
width: parent.width
spacing: 10
2022-12-05 20:31:00 +01:00
Flowee.Label {
id: title
text: qsTr("This creates a new empty wallet with simple multi-address capability")
Layout.fillWidth: true
wrapMode: Text.WordWrap
}
PageTitledBox {
title: qsTr("Name")
Flowee.TextField {
id: accountName
focus: true
width: parent.width
}
2022-12-05 20:31:00 +01:00
}
Flowee.CheckBox {
2023-07-05 12:24:31 +02:00
Layout.fillWidth: true
2022-12-05 20:31:00 +01:00
id: singleAddress
2026-03-14 21:14:42 +01:00
text: qsTr("Force Single Address")
toolTipText: qsTr("When enabled, this wallet will be limited to one address.\nThis ensures only one private key will need to be backed up")
2022-12-05 20:31:00 +01:00
}
Item {
width: parent.width
height: createButton.implicitHeight
2023-07-05 12:24:31 +02:00
Flowee.Button {
id: createButton
anchors.right: parent.right
text: qsTr("Create")
onClicked: {
2026-03-14 21:14:42 +01:00
var options = Pay.createNewBasicWallet(accountName.text)
options.forceSingleAddress = singleAddress.checked
for (let a of portfolio.accounts) {
if (a.id === options.accountId) {
2026-03-14 21:14:42 +01:00
portfolio.current = a
break
}
}
2026-03-14 21:14:42 +01:00
thePile.pop()
thePile.pop()
}
}
2022-12-05 20:31:00 +01:00
}
2022-11-21 19:29:46 +01:00
}
}
}
2022-11-23 10:33:18 +01:00
Component {
id: newHDWalletScreen
Page {
headerText: qsTr("New HD-Wallet")
2022-12-05 20:31:00 +01:00
ColumnLayout {
width: parent.width
spacing: 10
2022-12-05 20:31:00 +01:00
Flowee.Label {
id: title
Layout.fillWidth: true
text: qsTr("This creates a new wallet that can be backed up with a seed-phrase")
2022-12-05 20:31:00 +01:00
wrapMode: Text.WordWrap
}
PageTitledBox {
title: qsTr("Name")
Flowee.TextField {
id: accountName
width: parent.width
focus: true
}
2022-12-05 20:31:00 +01:00
}
PageTitledBox {
title: qsTr("Derivation")
Flowee.TextField {
2026-03-14 21:14:42 +01:00
property bool derivationOk: Pay.checkDerivation(text)
id: derivationPath
width: parent.width
text: "m/44'/0'/0'" // What most BCH wallets are created with
color: derivationOk ? palette.text : "red"
}
}
Item {
width: parent.width
height: createButton.implicitHeight
2023-07-05 12:24:31 +02:00
Flowee.Button {
id: createButton
enabled: derivationPath.derivationOk
anchors.right: parent.right
text: qsTr("Create")
onClicked: {
2026-03-14 21:14:42 +01:00
var options = Pay.createNewWallet(derivationPath.text, /* password */"", accountName.text)
for (let a of portfolio.accounts) {
if (a.id === options.accountId) {
2026-03-14 21:14:42 +01:00
portfolio.current = a
break
}
}
2026-03-14 21:14:42 +01:00
thePile.pop()
thePile.pop()
}
}
2022-12-05 20:31:00 +01:00
}
2022-11-23 10:33:18 +01:00
}
}
}
}
2022-11-21 19:29:46 +01:00
}