From 1f22b865c339a1a432f1d16c82807b41e2d933d5 Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Tue, 29 Nov 2022 11:28:59 +0100 Subject: [PATCH] qml: pastebutton and qr scan will only fill textarea after validation, more clear text for pubkey and seed for cosigners --- .../qml/components/wizard/WCHaveMasterKey.qml | 33 ++++++++++++++----- .../gui/qml/components/wizard/WCHaveSeed.qml | 2 +- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/electrum/gui/qml/components/wizard/WCHaveMasterKey.qml b/electrum/gui/qml/components/wizard/WCHaveMasterKey.qml index d95615c0b..1689d7e13 100644 --- a/electrum/gui/qml/components/wizard/WCHaveMasterKey.qml +++ b/electrum/gui/qml/components/wizard/WCHaveMasterKey.qml @@ -17,24 +17,30 @@ WizardComponent { property string multisigMasterPubkey: wizard_data['multisig_master_pubkey'] function apply() { + applyMasterKey(masterkey_ta.text) + } + + function applyMasterKey(key) { + key = key.trim() if (cosigner) { - wizard_data['multisig_cosigner_data'][cosigner.toString()]['master_key'] = masterkey_ta.text + wizard_data['multisig_cosigner_data'][cosigner.toString()]['master_key'] = key } else { - wizard_data['master_key'] = masterkey_ta.text + wizard_data['master_key'] = key } } function verifyMasterKey(key) { valid = false validationtext.text = '' + key = key.trim() - if (!bitcoin.verifyMasterKey(key.trim(), wizard_data['wallet_type'])) { + if (!bitcoin.verifyMasterKey(key, wizard_data['wallet_type'])) { validationtext.text = qsTr('Error: invalid master key') return false } if (cosigner) { - apply() + applyMasterKey(key) if (wiz.hasDuplicateKeys(wizard_data)) { validationtext.text = qsTr('Error: duplicate master public key') return false @@ -97,7 +103,9 @@ WizardComponent { } Label { - text: qsTr('Create keystore from a master key') + text: cosigner + ? qsTr('Enter cosigner master public key') + : qsTr('Create keystore from a master key') } RowLayout { @@ -108,7 +116,10 @@ WizardComponent { font.family: FixedFont focus: true wrapMode: TextEdit.WrapAnywhere - onTextChanged: verifyMasterKey(text) + onTextChanged: { + if (activeFocus) + verifyMasterKey(text) + } } ColumnLayout { ToolButton { @@ -116,7 +127,10 @@ WizardComponent { icon.height: constants.iconSizeMedium icon.width: constants.iconSizeMedium onClicked: { - masterkey_ta.text = AppController.clipboardToText() + if (verifyMasterKey(AppController.clipboardToText())) + masterkey_ta.text = AppController.clipboardToText() + else + masterkey_ta.text = '' } } ToolButton { @@ -127,7 +141,10 @@ WizardComponent { onClicked: { var scan = qrscan.createObject(root) scan.onFound.connect(function() { - masterkey_ta.text = scan.scanData + if (verifyMasterKey(scan.scanData)) + masterkey_ta.text = scan.scanData + else + masterkey_ta.text = '' scan.destroy() }) } diff --git a/electrum/gui/qml/components/wizard/WCHaveSeed.qml b/electrum/gui/qml/components/wizard/WCHaveSeed.qml index 1a809c194..59342242a 100644 --- a/electrum/gui/qml/components/wizard/WCHaveSeed.qml +++ b/electrum/gui/qml/components/wizard/WCHaveSeed.qml @@ -164,7 +164,7 @@ WizardComponent { Layout.columnSpan: 2 } Label { - text: qsTr('Enter your seed') + text: cosigner ? qsTr('Enter cosigner seed') : qsTr('Enter your seed') Layout.columnSpan: 2 } SeedTextArea {