electrum

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

commit 47b6d3c52c863e9f677731920817f1237527a028
parent 3d4773b1618cb8364b5a9a36018b305552258ad7
Author: SomberNight <somber.night@protonmail.com>
Date:   Thu,  8 Nov 2018 13:01:40 +0100

wizard: make native segwit (bech32) the default for bip39/hw

Diffstat:
Melectrum/base_wizard.py | 7+++++--
Melectrum/bip32.py | 4++--
Melectrum/gui/qt/installwizard.py | 13+++++++++----
3 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/electrum/base_wizard.py b/electrum/base_wizard.py @@ -334,12 +334,14 @@ class BaseWizard(object): # There is no general standard for HD multisig. # For legacy, this is partially compatible with BIP45; assumes index=0 # For segwit, a custom path is used, as there is no standard at all. + default_choice_idx = 2 choices = [ ('standard', 'legacy multisig (p2sh)', "m/45'/0"), ('p2wsh-p2sh', 'p2sh-segwit multisig (p2wsh-p2sh)', purpose48_derivation(0, xtype='p2wsh-p2sh')), ('p2wsh', 'native segwit multisig (p2wsh)', purpose48_derivation(0, xtype='p2wsh')), ] else: + default_choice_idx = 2 choices = [ ('standard', 'legacy (p2pkh)', bip44_derivation(0, bip43_purpose=44)), ('p2wpkh-p2sh', 'p2sh-segwit (p2wpkh-p2sh)', bip44_derivation(0, bip43_purpose=49)), @@ -349,7 +351,8 @@ class BaseWizard(object): try: self.choice_and_line_dialog( run_next=f, title=_('Script type and Derivation path'), message1=message1, - message2=message2, choices=choices, test_text=is_bip32_derivation) + message2=message2, choices=choices, test_text=is_bip32_derivation, + default_choice_idx=default_choice_idx) return except ScriptTypeNotSupported as e: self.show_error(e) @@ -539,7 +542,7 @@ class BaseWizard(object): ]) choices = [ ('create_segwit_seed', _('Segwit')), - ('create_standard_seed', _('Standard')), + ('create_standard_seed', _('Legacy')), ] self.choice_dialog(title=title, message=message, choices=choices, run_next=self.run) diff --git a/electrum/bip32.py b/electrum/bip32.py @@ -189,7 +189,7 @@ def xpub_from_pubkey(xtype, cK): return serialize_xpub(xtype, b'\x00'*32, cK) -def bip32_derivation(s): +def bip32_derivation(s: str) -> int: if not s.startswith('m/'): raise ValueError('invalid bip32 derivation path: {}'.format(s)) s = s[2:] @@ -216,7 +216,7 @@ def convert_bip32_path_to_list_of_uint32(n: str) -> List[int]: path.append(abs(int(x)) | prime) return path -def is_bip32_derivation(x): +def is_bip32_derivation(x: str) -> bool: try: [ i for i in bip32_derivation(x)] return True diff --git a/electrum/gui/qt/installwizard.py b/electrum/gui/qt/installwizard.py @@ -1,9 +1,12 @@ +# Copyright (C) 2018 The Electrum developers +# Distributed under the MIT software license, see the accompanying +# file LICENCE or http://www.opensource.org/licenses/mit-license.php import os import sys import threading import traceback -from typing import Tuple +from typing import Tuple, List, Callable from PyQt5.QtCore import * from PyQt5.QtGui import * @@ -506,8 +509,9 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard): return clayout.selected_index() @wizard_dialog - def choice_and_line_dialog(self, title, message1, choices, message2, - test_text, run_next) -> Tuple[str, str]: + def choice_and_line_dialog(self, title: str, message1: str, choices: List[Tuple[str, str, str]], + message2: str, test_text: Callable[[str], int], + run_next, default_choice_idx: int=0) -> Tuple[str, str]: vbox = QVBoxLayout() c_values = [x[0] for x in choices] @@ -516,7 +520,8 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard): def on_choice_click(clayout): idx = clayout.selected_index() line.setText(c_default_text[idx]) - clayout = ChoicesLayout(message1, c_titles, on_choice_click) + clayout = ChoicesLayout(message1, c_titles, on_choice_click, + checked_index=default_choice_idx) vbox.addLayout(clayout.layout()) vbox.addSpacing(50)