Skip to content

Commit bfd3c0e

Browse files
committed
Merge branch spesmilo/pr/10016' into 202507_pr10016_qml_wizard_passphrase
2 parents e56bc4f + 307181f commit bfd3c0e

File tree

12 files changed

+327
-144
lines changed

12 files changed

+327
-144
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import QtQuick
2+
import QtQuick.Layouts
3+
import QtQuick.Controls
4+
import QtQuick.Controls.Material
5+
6+
import org.electrum 1.0
7+
8+
import "../controls"
9+
10+
WizardComponent {
11+
id: root
12+
securePage: true
13+
14+
valid: false
15+
16+
property int cosigner: 0
17+
18+
function checkValid() {
19+
valid = false
20+
var input = customwordstext.text
21+
if (input == '') {
22+
return
23+
}
24+
25+
if (cosigner) {
26+
// multisig cosigner
27+
if (input != wizard_data['multisig_cosigner_data'][cosigner.toString()]['seed_extra_words']) {
28+
return
29+
}
30+
} else {
31+
if (input != wizard_data['seed_extra_words']) {
32+
return
33+
}
34+
}
35+
valid = true
36+
}
37+
38+
Flickable {
39+
anchors.fill: parent
40+
contentHeight: mainLayout.height
41+
clip: true
42+
interactive: height < contentHeight
43+
44+
ColumnLayout {
45+
id: mainLayout
46+
width: parent.width
47+
spacing: constants.paddingLarge
48+
49+
Label {
50+
Layout.fillWidth: true
51+
wrapMode: Text.Wrap
52+
text: qsTr('Please enter your custom word(s) a second time:')
53+
}
54+
55+
TextField {
56+
id: customwordstext
57+
Layout.fillWidth: true
58+
Layout.columnSpan: 2
59+
placeholderText: qsTr('Enter your custom word(s) here')
60+
inputMethodHints: Qt.ImhSensitiveData | Qt.ImhNoPredictiveText | Qt.ImhNoAutoUppercase
61+
onTextChanged: checkValid()
62+
}
63+
}
64+
}
65+
66+
Component.onCompleted: {
67+
if (wizard_data['wallet_type'] == 'multisig') {
68+
if ('multisig_current_cosigner' in wizard_data)
69+
cosigner = wizard_data['multisig_current_cosigner']
70+
}
71+
}
72+
}

electrum/gui/qml/components/wizard/WCConfirmSeed.qml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ WizardComponent {
1414

1515
function checkValid() {
1616
var seedvalid = wizard.wiz.isMatchingSeed(wizard_data['seed'], confirm.text)
17-
var customwordsvalid = customwordstext.text == wizard_data['seed_extra_words']
18-
valid = seedvalid && (wizard_data['seed_extend'] ? customwordsvalid : true)
17+
valid = seedvalid
1918
}
2019

2120
Flickable {
@@ -46,19 +45,6 @@ WizardComponent {
4645
placeholderText: qsTr('Enter your seed')
4746
onTextChanged: checkValid()
4847
}
49-
50-
TextField {
51-
id: customwordstext
52-
Layout.fillWidth: true
53-
placeholderText: qsTr('Enter your custom word(s)')
54-
inputMethodHints: Qt.ImhNoPredictiveText
55-
56-
onTextChanged: checkValid()
57-
}
5848
}
5949
}
60-
61-
Component.onCompleted: {
62-
customwordstext.visible = wizard_data['seed_extend']
63-
}
6450
}

electrum/gui/qml/components/wizard/WCCreateSeed.qml

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@ import "../controls"
99
WizardComponent {
1010
securePage: true
1111

12-
valid: seedtext.text != '' && extendcb.checked ? customwordstext.text != '' : true
12+
valid: seedtext.text != ''
1313

1414
function apply() {
1515
wizard_data['seed'] = seedtext.text
1616
wizard_data['seed_variant'] = 'electrum' // generated seed always electrum variant
17-
wizard_data['seed_extend'] = extendcb.checked
18-
wizard_data['seed_extra_words'] = extendcb.checked ? customwordstext.text : ''
17+
wizard_data['seed_extend'] = true // true so we get forwarded to the passphrase page
1918
}
2019

2120
function setWarningText(numwords) {
@@ -70,20 +69,6 @@ WizardComponent {
7069
}
7170
}
7271

73-
ElCheckBox {
74-
id: extendcb
75-
Layout.fillWidth: true
76-
text: qsTr('Extend seed with custom words')
77-
}
78-
79-
TextField {
80-
id: customwordstext
81-
visible: extendcb.checked
82-
Layout.fillWidth: true
83-
placeholderText: qsTr('Enter your custom word(s)')
84-
inputMethodHints: Qt.ImhNoPredictiveText
85-
}
86-
8772
Component.onCompleted : {
8873
setWarningText(12)
8974
}
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
import QtQuick
2+
import QtQuick.Layouts
3+
import QtQuick.Controls
4+
import QtQuick.Controls.Material
5+
6+
import org.electrum 1.0
7+
8+
import "../controls"
9+
10+
WizardComponent {
11+
id: root
12+
securePage: true
13+
14+
valid: true
15+
16+
property int cosigner: 0
17+
18+
function apply() {
19+
var seed_extend = extendcb.checked
20+
if (cosigner) {
21+
wizard_data['multisig_cosigner_data'][cosigner.toString()]['seed_extend'] = seed_extend
22+
wizard_data['multisig_cosigner_data'][cosigner.toString()]['seed_extra_words'] = seed_extend ? customwordstext.text : ''
23+
} else {
24+
wizard_data['seed_extend'] = seed_extend
25+
wizard_data['seed_extra_words'] = seed_extend ? customwordstext.text : ''
26+
}
27+
}
28+
29+
function checkValid() {
30+
valid = false
31+
validationtext.text = ''
32+
33+
if (extendcb.checked && customwordstext.text == '') {
34+
return
35+
} else {
36+
// passphrase is either disabled or filled with text
37+
apply()
38+
if (cosigner && wizard_data['multisig_cosigner_data'][cosigner.toString()]['seed_variant'] == 'electrum') {
39+
// check if master keys are not duplicated after entering passphrase
40+
if (wiz.hasDuplicateMasterKeys(wizard_data)) {
41+
validationtext.text = qsTr('Error: duplicate master public key')
42+
return
43+
}
44+
}
45+
}
46+
valid = true
47+
}
48+
49+
Flickable {
50+
anchors.fill: parent
51+
contentHeight: mainLayout.height
52+
clip: true
53+
interactive: height < contentHeight
54+
55+
ColumnLayout {
56+
id: mainLayout
57+
width: parent.width
58+
spacing: constants.paddingLarge
59+
60+
InfoTextArea {
61+
id: validationtext
62+
Layout.fillWidth: true
63+
Layout.columnSpan: 2
64+
visible: text
65+
iconStyle: InfoTextArea.IconStyle.Error
66+
}
67+
68+
Label {
69+
Layout.fillWidth: true
70+
wrapMode: Text.Wrap
71+
text: [
72+
qsTr('You may extend your seed with custom words.'),
73+
qsTr('Your seed extension must be saved together with your seed.'),
74+
qsTr('Note that this is NOT your encryption password.'),
75+
'<br/>',
76+
qsTr('Do not enable it unless you know what it does!'),
77+
].join(' ')
78+
}
79+
80+
ElCheckBox {
81+
id: extendcb
82+
Layout.columnSpan: 2
83+
Layout.fillWidth: true
84+
text: qsTr('Extend seed with custom words')
85+
onCheckedChanged: checkValid()
86+
}
87+
88+
TextField {
89+
id: customwordstext
90+
enabled: extendcb.checked
91+
Layout.fillWidth: true
92+
Layout.columnSpan: 2
93+
placeholderText: qsTr('Enter your custom word(s)')
94+
inputMethodHints: Qt.ImhSensitiveData | Qt.ImhNoPredictiveText | Qt.ImhNoAutoUppercase
95+
onTextChanged: startValidationTimer()
96+
}
97+
}
98+
}
99+
100+
function startValidationTimer() {
101+
valid = false
102+
validationTimer.restart()
103+
}
104+
105+
Timer {
106+
id: validationTimer
107+
interval: 250
108+
repeat: false
109+
onTriggered: checkValid()
110+
}
111+
112+
Component.onCompleted: {
113+
if (wizard_data['wallet_type'] == 'multisig') {
114+
if ('multisig_current_cosigner' in wizard_data)
115+
cosigner = wizard_data['multisig_current_cosigner']
116+
}
117+
checkValid()
118+
}
119+
}

electrum/gui/qml/components/wizard/WCHaveSeed.qml

Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,16 @@ WizardComponent {
2424
property bool _seedValid
2525

2626
function apply() {
27-
var seed_extend = extendcb.checked && _canPassphrase
2827
if (cosigner) {
2928
wizard_data['multisig_cosigner_data'][cosigner.toString()]['seed'] = seedtext.text
3029
wizard_data['multisig_cosigner_data'][cosigner.toString()]['seed_variant'] = seed_variant_cb.currentValue
3130
wizard_data['multisig_cosigner_data'][cosigner.toString()]['seed_type'] = _seedType
32-
wizard_data['multisig_cosigner_data'][cosigner.toString()]['seed_extend'] = seed_extend
33-
wizard_data['multisig_cosigner_data'][cosigner.toString()]['seed_extra_words'] = seed_extend ? customwordstext.text : ''
31+
wizard_data['multisig_cosigner_data'][cosigner.toString()]['seed_extend'] = _canPassphrase
3432
} else {
3533
wizard_data['seed'] = seedtext.text
3634
wizard_data['seed_variant'] = seed_variant_cb.currentValue
3735
wizard_data['seed_type'] = _seedType
38-
wizard_data['seed_extend'] = seed_extend
39-
wizard_data['seed_extra_words'] = seed_extend ? customwordstext.text : ''
36+
wizard_data['seed_extend'] = _canPassphrase
4037

4138
// determine script type from electrum seed type
4239
// (used to limit script type options for bip39 cosigners)
@@ -52,22 +49,20 @@ WizardComponent {
5249
function setSeedTypeHelpText() {
5350
var t = {
5451
'electrum': [
52+
// not shown as electrum is the default seed type anyways and the name is self-explanatory
5553
qsTr('Electrum seeds are the default seed type.'),
5654
qsTr('If you are restoring from a seed previously created by Electrum, choose this option')
5755
].join(' '),
5856
'bip39': [
5957
qsTr('BIP39 seeds can be imported in Electrum, so that users can access funds locked in other wallets.'),
60-
'<br/><br/>',
61-
qsTr('However, we do not generate BIP39 seeds, because they do not meet our safety standard.'),
62-
qsTr('BIP39 seeds do not include a version number, which compromises compatibility with future software.')
58+
qsTr('BIP39 seeds do not include a version number, which compromises compatibility with future software.'),
6359
].join(' '),
6460
'slip39': [
6561
qsTr('SLIP39 seeds can be imported in Electrum, so that users can access funds locked in other wallets.'),
66-
'<br/><br/>',
67-
qsTr('However, we do not generate SLIP39 seeds.')
6862
].join(' ')
6963
}
7064
infotext.text = t[seed_variant_cb.currentValue]
65+
infotext.visible = !cosigner && !is2fa && seed_variant_cb.currentValue != 'electrum'
7166
}
7267

7368
function checkValid() {
@@ -100,11 +95,6 @@ WizardComponent {
10095
}
10196
}
10297

103-
if (_canPassphrase && extendcb.checked && customwordstext.text == '') {
104-
valid = false
105-
return
106-
}
107-
10898
valid = _seedValid
10999
}
110100

@@ -196,7 +186,6 @@ WizardComponent {
196186

197187
InfoTextArea {
198188
id: infotext
199-
visible: !cosigner && !is2fa
200189
Layout.fillWidth: true
201190
Layout.columnSpan: 2
202191
Layout.bottomMargin: constants.paddingLarge
@@ -221,26 +210,6 @@ WizardComponent {
221210
startValidationTimer()
222211
}
223212
}
224-
225-
ElCheckBox {
226-
id: extendcb
227-
Layout.columnSpan: 2
228-
Layout.fillWidth: true
229-
visible: _canPassphrase
230-
text: qsTr('Extend seed with custom words')
231-
onCheckedChanged: startValidationTimer()
232-
}
233-
234-
TextField {
235-
id: customwordstext
236-
visible: extendcb.checked && extendcb.visible
237-
Layout.fillWidth: true
238-
Layout.columnSpan: 2
239-
placeholderText: qsTr('Enter your custom word(s)')
240-
inputMethodHints: Qt.ImhNoPredictiveText
241-
242-
onTextChanged: startValidationTimer()
243-
}
244213
}
245214
}
246215

electrum/gui/qml/qewizard.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,18 @@ def __init__(self, daemon: 'QEDaemon', plugins: 'Plugins', parent=None):
6868
'wallet_type': {'gui': 'WCWalletType'},
6969
'keystore_type': {'gui': 'WCKeystoreType'},
7070
'create_seed': {'gui': 'WCCreateSeed'},
71+
'create_ext': {'gui': 'WCEnterExt'},
7172
'confirm_seed': {'gui': 'WCConfirmSeed'},
73+
'confirm_ext': {'gui': 'WCConfirmExt'},
7274
'have_seed': {'gui': 'WCHaveSeed'},
75+
'have_ext': {'gui': 'WCEnterExt'},
7376
'script_and_derivation': {'gui': 'WCScriptAndDerivation'},
7477
'have_master_key': {'gui': 'WCHaveMasterKey'},
7578
'multisig': {'gui': 'WCMultisig'},
7679
'multisig_cosigner_keystore': {'gui': 'WCCosignerKeystore'},
7780
'multisig_cosigner_key': {'gui': 'WCHaveMasterKey'},
7881
'multisig_cosigner_seed': {'gui': 'WCHaveSeed'},
82+
'multisig_cosigner_have_ext': {'gui': 'WCEnterExt'},
7983
'multisig_cosigner_script_and_derivation': {'gui': 'WCScriptAndDerivation'},
8084
'imported': {'gui': 'WCImport'},
8185
'wallet_password': {'gui': 'WCWalletPassword'}

0 commit comments

Comments
 (0)