electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit d1843a804a582c8bfa7740c8a82e3a6afd3f00ae
parent ffff09736addb4b4176d7faa9eaed175d7cef7fc
Author: ThomasV <thomasv@electrum.org>
Date:   Fri, 29 Dec 2017 16:04:53 +0100

Merge pull request #3610 from SomberNight/wizard_derivation_presets

wizard: add derivation presets for bip44/49
Diffstat:
Mgui/qt/installwizard.py | 12+++++++++++-
Mlib/base_wizard.py | 8+++++++-
2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/gui/qt/installwizard.py b/gui/qt/installwizard.py @@ -462,7 +462,8 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard): return clayout.selected_index() @wizard_dialog - def line_dialog(self, run_next, title, message, default, test, warning=''): + def line_dialog(self, run_next, title, message, default, test, warning='', + presets=()): vbox = QVBoxLayout() vbox.addWidget(WWLabel(message)) line = QLineEdit() @@ -472,6 +473,15 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard): line.textEdited.connect(f) vbox.addWidget(line) vbox.addWidget(WWLabel(warning)) + + for preset in presets: + button = QPushButton(preset[0]) + button.clicked.connect(lambda __, text=preset[1]: line.setText(text)) + button.setMaximumWidth(150) + hbox = QHBoxLayout() + hbox.addWidget(button, Qt.AlignCenter) + vbox.addLayout(hbox) + self.exec_layout(vbox, title, next_enabled=test(default)) return ' '.join(line.text().split()) diff --git a/lib/base_wizard.py b/lib/base_wizard.py @@ -236,7 +236,13 @@ class BaseWizard(object): _('Enter your wallet derivation here.'), _('If you are not sure what this is, leave this field unchanged.') ]) - self.line_dialog(run_next=f, title=_('Derivation'), message=message, default=default, test=bitcoin.is_bip32_derivation) + presets = ( + ('legacy BIP44', bip44_derivation(0, False)), + ('p2sh-segwit BIP49', bip44_derivation(0, True)), + ) + self.line_dialog(run_next=f, title=_('Derivation'), message=message, + default=default, test=bitcoin.is_bip32_derivation, + presets=presets) def on_hw_derivation(self, name, device_info, derivation): from .keystore import hardware_keystore