1
0

qt, qml: allow BIP39 seeds which fail checksum or wordlist (fixes #8720)

removes verifySeed from qebitcoin as this code was 99% duplicate of wizard.validate_seed
This commit is contained in:
Sander van Grieken
2023-12-06 16:12:57 +01:00
parent 1cc1926263
commit b87d091a6d
5 changed files with 46 additions and 79 deletions

View File

@@ -18,17 +18,20 @@ WizardComponent {
property int participants: 0
property string multisigMasterPubkey: wizard_data['multisig_master_pubkey']
property string _seedType
property string _validationMessage
function apply() {
if (cosigner) {
wizard_data['multisig_cosigner_data'][cosigner.toString()]['seed'] = seedtext.text
wizard_data['multisig_cosigner_data'][cosigner.toString()]['seed_variant'] = seed_variant_cb.currentValue
wizard_data['multisig_cosigner_data'][cosigner.toString()]['seed_type'] = bitcoin.seedType
wizard_data['multisig_cosigner_data'][cosigner.toString()]['seed_type'] = _seedType
wizard_data['multisig_cosigner_data'][cosigner.toString()]['seed_extend'] = extendcb.checked
wizard_data['multisig_cosigner_data'][cosigner.toString()]['seed_extra_words'] = extendcb.checked ? customwordstext.text : ''
} else {
wizard_data['seed'] = seedtext.text
wizard_data['seed_variant'] = seed_variant_cb.currentValue
wizard_data['seed_type'] = bitcoin.seedType
wizard_data['seed_type'] = _seedType
wizard_data['seed_extend'] = extendcb.checked
wizard_data['seed_extra_words'] = extendcb.checked ? customwordstext.text : ''
@@ -38,7 +41,7 @@ WizardComponent {
wizard_data['script_type'] = {
'standard': 'p2sh',
'segwit': 'p2wsh'
}[bitcoin.seedType]
}[_seedType]
}
}
}
@@ -66,14 +69,18 @@ WizardComponent {
function checkValid() {
valid = false
validationtext.text = ''
_validationMessage = ''
if (extendcb.checked && customwordstext.text == '')
return
var validSeed = bitcoin.verifySeed(seedtext.text, seed_variant_cb.currentValue, wizard_data['wallet_type'])
if (!cosigner || !validSeed) {
valid = validSeed
var verifyResult = wiz.verifySeed(seedtext.text, seed_variant_cb.currentValue, wizard_data['wallet_type'])
_validationMessage = verifyResult.message
_seedType = verifyResult.type
if (!cosigner || !verifyResult.valid) {
valid = verifyResult.valid
return
} else {
// bip39 validate after derivation path is known
@@ -196,21 +203,19 @@ WizardComponent {
placeholderText: cosigner ? qsTr('Enter cosigner seed') : qsTr('Enter your seed')
indicatorValid: root.valid
? root._seedType == 'bip39' && root._validationMessage
? false
: root.valid
: root.valid
indicatorText: root.valid
? root._validationMessage
? root._validationMessage
: root._seedType
: ''
onTextChanged: {
startValidationTimer()
}
}
TextArea {
id: validationtext
visible: text
Layout.fillWidth: true
readOnly: true
wrapMode: TextInput.WordWrap
background: Rectangle {
color: 'transparent'
}
}
ElCheckBox {
id: extendcb
@@ -231,14 +236,10 @@ WizardComponent {
}
}
Bitcoin {
id: bitcoin
onSeedTypeChanged: seedtext.indicatorText = bitcoin.seedType
}
function startValidationTimer() {
valid = false
seedtext.indicatorText = ''
root._seedType = ''
root._validationMessage = ''
validationTimer.restart()
}