Browse Source

qml: pastebutton and qr scan will only fill textarea after validation,

more clear text for pubkey and seed for cosigners
master
Sander van Grieken 3 years ago
parent
commit
1f22b865c3
  1. 33
      electrum/gui/qml/components/wizard/WCHaveMasterKey.qml
  2. 2
      electrum/gui/qml/components/wizard/WCHaveSeed.qml

33
electrum/gui/qml/components/wizard/WCHaveMasterKey.qml

@ -17,24 +17,30 @@ WizardComponent {
property string multisigMasterPubkey: wizard_data['multisig_master_pubkey'] property string multisigMasterPubkey: wizard_data['multisig_master_pubkey']
function apply() { function apply() {
applyMasterKey(masterkey_ta.text)
}
function applyMasterKey(key) {
key = key.trim()
if (cosigner) { 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 { } else {
wizard_data['master_key'] = masterkey_ta.text wizard_data['master_key'] = key
} }
} }
function verifyMasterKey(key) { function verifyMasterKey(key) {
valid = false valid = false
validationtext.text = '' 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') validationtext.text = qsTr('Error: invalid master key')
return false return false
} }
if (cosigner) { if (cosigner) {
apply() applyMasterKey(key)
if (wiz.hasDuplicateKeys(wizard_data)) { if (wiz.hasDuplicateKeys(wizard_data)) {
validationtext.text = qsTr('Error: duplicate master public key') validationtext.text = qsTr('Error: duplicate master public key')
return false return false
@ -97,7 +103,9 @@ WizardComponent {
} }
Label { 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 { RowLayout {
@ -108,7 +116,10 @@ WizardComponent {
font.family: FixedFont font.family: FixedFont
focus: true focus: true
wrapMode: TextEdit.WrapAnywhere wrapMode: TextEdit.WrapAnywhere
onTextChanged: verifyMasterKey(text) onTextChanged: {
if (activeFocus)
verifyMasterKey(text)
}
} }
ColumnLayout { ColumnLayout {
ToolButton { ToolButton {
@ -116,7 +127,10 @@ WizardComponent {
icon.height: constants.iconSizeMedium icon.height: constants.iconSizeMedium
icon.width: constants.iconSizeMedium icon.width: constants.iconSizeMedium
onClicked: { onClicked: {
masterkey_ta.text = AppController.clipboardToText() if (verifyMasterKey(AppController.clipboardToText()))
masterkey_ta.text = AppController.clipboardToText()
else
masterkey_ta.text = ''
} }
} }
ToolButton { ToolButton {
@ -127,7 +141,10 @@ WizardComponent {
onClicked: { onClicked: {
var scan = qrscan.createObject(root) var scan = qrscan.createObject(root)
scan.onFound.connect(function() { scan.onFound.connect(function() {
masterkey_ta.text = scan.scanData if (verifyMasterKey(scan.scanData))
masterkey_ta.text = scan.scanData
else
masterkey_ta.text = ''
scan.destroy() scan.destroy()
}) })
} }

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

@ -164,7 +164,7 @@ WizardComponent {
Layout.columnSpan: 2 Layout.columnSpan: 2
} }
Label { Label {
text: qsTr('Enter your seed') text: cosigner ? qsTr('Enter cosigner seed') : qsTr('Enter your seed')
Layout.columnSpan: 2 Layout.columnSpan: 2
} }
SeedTextArea { SeedTextArea {

Loading…
Cancel
Save