qml: add multisig support in WCBIP39Refine, add seed valid check for multisig in qebitcoin.py
This commit is contained in:
@@ -9,6 +9,8 @@ import "../controls"
|
||||
WizardComponent {
|
||||
valid: false
|
||||
|
||||
property bool isMultisig
|
||||
|
||||
function apply() {
|
||||
wizard_data['script_type'] = scripttypegroup.checkedButton.scripttype
|
||||
wizard_data['derivation_path'] = derivationpathtext.text
|
||||
@@ -22,9 +24,18 @@ WizardComponent {
|
||||
}
|
||||
}
|
||||
|
||||
function getMultisigScriptTypePurposeDict() {
|
||||
return {
|
||||
'p2sh': 45,
|
||||
'p2wsh-p2sh': 48,
|
||||
'p2wsh': 48
|
||||
}
|
||||
}
|
||||
|
||||
function validate() {
|
||||
valid = false
|
||||
if (!scripttypegroup.checkedButton.scripttype in getScriptTypePurposeDict())
|
||||
var p = isMultisig ? getMultisigScriptTypePurposeDict() : getScriptTypePurposeDict()
|
||||
if (!scripttypegroup.checkedButton.scripttype in p)
|
||||
return
|
||||
if (!bitcoin.verify_derivation_path(derivationpathtext.text))
|
||||
return
|
||||
@@ -32,10 +43,20 @@ WizardComponent {
|
||||
}
|
||||
|
||||
function setDerivationPath() {
|
||||
var p = getScriptTypePurposeDict()
|
||||
derivationpathtext.text =
|
||||
"m/" + p[scripttypegroup.checkedButton.scripttype] + "'/"
|
||||
+ (Network.isTestNet ? 1 : 0) + "'/0'"
|
||||
var p = isMultisig ? getMultisigScriptTypePurposeDict() : getScriptTypePurposeDict()
|
||||
var scripttype = scripttypegroup.checkedButton.scripttype
|
||||
if (isMultisig) {
|
||||
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 {
|
||||
@@ -59,23 +80,46 @@ WizardComponent {
|
||||
Button {
|
||||
text: qsTr('Detect Existing Accounts')
|
||||
enabled: false
|
||||
visible: !isMultisig
|
||||
}
|
||||
Label { text: qsTr('Choose the type of addresses in your wallet.') }
|
||||
RadioButton {
|
||||
ButtonGroup.group: scripttypegroup
|
||||
property string scripttype: 'p2pkh'
|
||||
text: qsTr('legacy (p2pkh)')
|
||||
visible: !isMultisig
|
||||
}
|
||||
RadioButton {
|
||||
ButtonGroup.group: scripttypegroup
|
||||
property string scripttype: 'p2wpkh-p2sh'
|
||||
text: qsTr('wrapped segwit (p2wpkh-p2sh)')
|
||||
visible: !isMultisig
|
||||
}
|
||||
RadioButton {
|
||||
ButtonGroup.group: scripttypegroup
|
||||
property string scripttype: 'p2wpkh'
|
||||
checked: true
|
||||
checked: !isMultisig
|
||||
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 {
|
||||
Layout.preferredWidth: parent.width
|
||||
@@ -95,5 +139,8 @@ WizardComponent {
|
||||
id: bitcoin
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
isMultisig = 'multisig' in wizard_data && wizard_data['multisig'] == true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ WizardComponent {
|
||||
}
|
||||
|
||||
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 {
|
||||
|
||||
@@ -70,7 +70,7 @@ class QEBitcoin(QObject):
|
||||
|
||||
@pyqtSlot(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_valid = False
|
||||
self.validationMessage = ''
|
||||
@@ -103,6 +103,8 @@ class QEBitcoin(QObject):
|
||||
seed_valid = False
|
||||
elif wallet_type == 'standard' and seed_type not in ['old', 'standard', 'segwit', 'bip39']:
|
||||
seed_valid = False
|
||||
elif wallet_type == 'multisig' and seed_type not in ['standard', 'segwit', 'bip39']:
|
||||
seed_valid = False
|
||||
|
||||
self.seedType = seed_type
|
||||
self.seedTypeChanged.emit()
|
||||
|
||||
Reference in New Issue
Block a user