Browse Source

qml: add multisig support in WCBIP39Refine, add seed valid check for multisig in qebitcoin.py

patch-4
Sander van Grieken 2 years ago
parent
commit
f07b11f283
  1. 59
      electrum/gui/qml/components/wizard/WCBIP39Refine.qml
  2. 2
      electrum/gui/qml/components/wizard/WCHaveSeed.qml
  3. 4
      electrum/gui/qml/qebitcoin.py

59
electrum/gui/qml/components/wizard/WCBIP39Refine.qml

@ -9,6 +9,8 @@ import "../controls"
WizardComponent { WizardComponent {
valid: false valid: false
property bool isMultisig
function apply() { function apply() {
wizard_data['script_type'] = scripttypegroup.checkedButton.scripttype wizard_data['script_type'] = scripttypegroup.checkedButton.scripttype
wizard_data['derivation_path'] = derivationpathtext.text wizard_data['derivation_path'] = derivationpathtext.text
@ -22,9 +24,18 @@ WizardComponent {
} }
} }
function getMultisigScriptTypePurposeDict() {
return {
'p2sh': 45,
'p2wsh-p2sh': 48,
'p2wsh': 48
}
}
function validate() { function validate() {
valid = false valid = false
if (!scripttypegroup.checkedButton.scripttype in getScriptTypePurposeDict()) var p = isMultisig ? getMultisigScriptTypePurposeDict() : getScriptTypePurposeDict()
if (!scripttypegroup.checkedButton.scripttype in p)
return return
if (!bitcoin.verify_derivation_path(derivationpathtext.text)) if (!bitcoin.verify_derivation_path(derivationpathtext.text))
return return
@ -32,10 +43,20 @@ WizardComponent {
} }
function setDerivationPath() { function setDerivationPath() {
var p = getScriptTypePurposeDict() var p = isMultisig ? getMultisigScriptTypePurposeDict() : getScriptTypePurposeDict()
derivationpathtext.text = var scripttype = scripttypegroup.checkedButton.scripttype
"m/" + p[scripttypegroup.checkedButton.scripttype] + "'/" if (isMultisig) {
+ (Network.isTestNet ? 1 : 0) + "'/0'" if (scripttype == 'p2sh')
derivationpathtext.text = "m/" + p[scripttype] + "'/0"
else
derivationpathtext.text = "m/" + p[scripttype] + "'/"
+ (Network.isTestNet ? 1 : 0) + "'/0'/"
+ (scripttype == 'p2wsh' ? 2 : 1) + "'"
} else {
derivationpathtext.text =
"m/" + p[scripttypegroup.checkedButton.scripttype] + "'/"
+ (Network.isTestNet ? 1 : 0) + "'/0'"
}
} }
ButtonGroup { ButtonGroup {
@ -59,23 +80,46 @@ WizardComponent {
Button { Button {
text: qsTr('Detect Existing Accounts') text: qsTr('Detect Existing Accounts')
enabled: false enabled: false
visible: !isMultisig
} }
Label { text: qsTr('Choose the type of addresses in your wallet.') } Label { text: qsTr('Choose the type of addresses in your wallet.') }
RadioButton { RadioButton {
ButtonGroup.group: scripttypegroup ButtonGroup.group: scripttypegroup
property string scripttype: 'p2pkh' property string scripttype: 'p2pkh'
text: qsTr('legacy (p2pkh)') text: qsTr('legacy (p2pkh)')
visible: !isMultisig
} }
RadioButton { RadioButton {
ButtonGroup.group: scripttypegroup ButtonGroup.group: scripttypegroup
property string scripttype: 'p2wpkh-p2sh' property string scripttype: 'p2wpkh-p2sh'
text: qsTr('wrapped segwit (p2wpkh-p2sh)') text: qsTr('wrapped segwit (p2wpkh-p2sh)')
visible: !isMultisig
} }
RadioButton { RadioButton {
ButtonGroup.group: scripttypegroup ButtonGroup.group: scripttypegroup
property string scripttype: 'p2wpkh' property string scripttype: 'p2wpkh'
checked: true checked: !isMultisig
text: qsTr('native segwit (p2wpkh)') text: qsTr('native segwit (p2wpkh)')
visible: !isMultisig
}
RadioButton {
ButtonGroup.group: scripttypegroup
property string scripttype: 'p2sh'
text: qsTr('legacy multisig (p2sh)')
visible: isMultisig
}
RadioButton {
ButtonGroup.group: scripttypegroup
property string scripttype: 'p2wsh-p2sh'
text: qsTr('p2sh-segwit multisig (p2wsh-p2sh)')
visible: isMultisig
}
RadioButton {
ButtonGroup.group: scripttypegroup
property string scripttype: 'p2wsh'
checked: isMultisig
text: qsTr('native segwit multisig (p2wsh)')
visible: isMultisig
} }
InfoTextArea { InfoTextArea {
Layout.preferredWidth: parent.width Layout.preferredWidth: parent.width
@ -95,5 +139,8 @@ WizardComponent {
id: bitcoin id: bitcoin
} }
Component.onCompleted: {
isMultisig = 'multisig' in wizard_data && wizard_data['multisig'] == true
}
} }

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

@ -53,7 +53,7 @@ WizardComponent {
} }
function checkValid() { function checkValid() {
bitcoin.verify_seed(seedtext.text, seed_variant_cb.currentValue, wizard_data['wallet_type']) bitcoin.verifySeed(seedtext.text, seed_variant_cb.currentValue, wizard_data['wallet_type'])
} }
Flickable { Flickable {

4
electrum/gui/qml/qebitcoin.py

@ -70,7 +70,7 @@ class QEBitcoin(QObject):
@pyqtSlot(str,str) @pyqtSlot(str,str)
@pyqtSlot(str,str,str) @pyqtSlot(str,str,str)
def verify_seed(self, seed, seed_variant, wallet_type='standard'): def verifySeed(self, seed, seed_variant, wallet_type='standard'):
seed_type = '' seed_type = ''
seed_valid = False seed_valid = False
self.validationMessage = '' self.validationMessage = ''
@ -103,6 +103,8 @@ class QEBitcoin(QObject):
seed_valid = False seed_valid = False
elif wallet_type == 'standard' and seed_type not in ['old', 'standard', 'segwit', 'bip39']: elif wallet_type == 'standard' and seed_type not in ['old', 'standard', 'segwit', 'bip39']:
seed_valid = False seed_valid = False
elif wallet_type == 'multisig' and seed_type not in ['standard', 'segwit', 'bip39']:
seed_valid = False
self.seedType = seed_type self.seedType = seed_type
self.seedTypeChanged.emit() self.seedTypeChanged.emit()

Loading…
Cancel
Save