Browse Source

add seed generation and verification for standard wallets

master
Sander van Grieken 4 years ago
parent
commit
b1bd4d5acb
  1. 1
      electrum/gui/qml/components/Wizard.qml
  2. 1
      electrum/gui/qml/components/WizardComponent.qml
  3. 77
      electrum/gui/qml/components/WizardComponents.qml

1
electrum/gui/qml/components/Wizard.qml

@ -36,6 +36,7 @@ Dialog {
pages.lastpage = page.last pages.lastpage = page.last
} ) } )
Object.assign(page.wizard_data, wdata) // deep copy Object.assign(page.wizard_data, wdata) // deep copy
page.ready = true // signal page it can access wizard_data
pages.pagevalid = page.valid pages.pagevalid = page.valid
pages.lastpage = page.last pages.lastpage = page.last

1
electrum/gui/qml/components/WizardComponent.qml

@ -6,6 +6,7 @@ Item {
property var wizard_data : ({}) property var wizard_data : ({})
property bool valid property bool valid
property bool last: false property bool last: false
property bool ready: false
// onValidChanged: console.log('valid change in component itself') // onValidChanged: console.log('valid change in component itself')
// onWizard_dataChanged: console.log('wizard data changed in ') // onWizard_dataChanged: console.log('wizard data changed in ')
} }

77
electrum/gui/qml/components/WizardComponents.qml

@ -1,6 +1,9 @@
import QtQuick 2.6 import QtQuick 2.6
import QtQuick.Layouts 1.0 import QtQuick.Layouts 1.0
import QtQuick.Controls 2.1 import QtQuick.Controls 2.1
import QtQuick.Controls.Material 2.0
import org.electrum 1.0
Item { Item {
property Component walletname: Component { property Component walletname: Component {
@ -114,22 +117,45 @@ Item {
onAccept: { onAccept: {
wizard_data['seed'] = seedtext.text wizard_data['seed'] = seedtext.text
wizard_data['seed_extend'] = extendcb.checked wizard_data['seed_extend'] = extendcb.checked
wizard_data['seed_extra_words'] = extendcb.checked ? customwordstext.text : ''
} }
GridLayout { GridLayout {
width: parent.width
columns: 1 columns: 1
Label { text: qsTr('Generating seed') }
Label { text: qsTr('Generated Seed') }
TextArea { TextArea {
id: seedtext id: seedtext
text: 'test this is a fake seed as you might expect'
readOnly: true readOnly: true
Layout.fillWidth: true Layout.fillWidth: true
wrapMode: TextInput.WordWrap wrapMode: TextInput.WordWrap
background: Rectangle {
color: "transparent"
border.color: Material.accentColor
}
leftInset: -5
rightInset: -5
} }
CheckBox { CheckBox {
id: extendcb id: extendcb
text: qsTr('Extend seed with custom words') text: qsTr('Extend seed with custom words')
} }
TextField {
id: customwordstext
visible: extendcb.checked
Layout.fillWidth: true
placeholderText: qsTr('Enter your custom word(s)')
echoMode: TextInput.Password
}
Component.onCompleted : {
bitcoin.generate_seed()
}
}
Bitcoin {
id: bitcoin
onGeneratedSeedChanged: seedtext.text = generated_seed
} }
} }
} }
@ -145,45 +171,84 @@ Item {
} }
GridLayout { GridLayout {
width: parent.width
columns: 1 columns: 1
Label { text: qsTr('Enter your seed') } Label { text: qsTr('Enter your seed') }
TextArea { TextArea {
id: seedtext id: seedtext
wrapMode: TextInput.WordWrap wrapMode: TextInput.WordWrap
Layout.fillWidth: true Layout.fillWidth: true
background: Rectangle {
color: "transparent"
border.color: Material.accentColor
}
leftInset: -5
rightInset: -5
} }
CheckBox { CheckBox {
id: extendcb id: extendcb
enabled: true enabled: true
text: qsTr('Extend seed with custom words') text: qsTr('Extend seed with custom words')
} }
TextField {
id: customwordstext
visible: extendcb.checked
Layout.fillWidth: true
placeholderText: qsTr('Enter your custom word(s)')
echoMode: TextInput.Password
}
CheckBox { CheckBox {
id: bip39cb id: bip39cb
enabled: true enabled: true
text: qsTr('BIP39') text: qsTr('BIP39')
} }
} }
Bitcoin {
id: bitcoin
}
} }
} }
property Component confirmseed: Component { property Component confirmseed: Component {
WizardComponent { WizardComponent {
valid: confirm.text !== '' valid: false
Layout.fillWidth: true
function checkValid() {
var seedvalid = confirm.text == wizard_data['seed']
var customwordsvalid = customwordstext.text == wizard_data['seed_extra_words']
valid = seedvalid && (wizard_data['seed_extend'] ? customwordsvalid : true)
}
GridLayout { GridLayout {
Layout.fillWidth: true width: parent.width
columns: 1 columns: 1
Label { text: qsTr('Confirm your seed (re-enter)') } Label { text: qsTr('Confirm your seed (re-enter)') }
TextArea { TextArea {
id: confirm id: confirm
wrapMode: TextInput.WordWrap wrapMode: TextInput.WordWrap
Layout.fillWidth: true Layout.fillWidth: true
onTextChanged: { onTextChanged: {
console.log("TODO: verify seed") checkValid()
}
}
TextField {
id: customwordstext
Layout.fillWidth: true
placeholderText: qsTr('Enter your custom word(s)')
echoMode: TextInput.Password
onTextChanged: {
checkValid()
} }
} }
} }
onReadyChanged: {
if (ready)
customwordstext.visible = wizard_data['seed_extend']
}
} }
} }

Loading…
Cancel
Save