wizard: make native segwit (bech32) the default for bip39/hw
This commit is contained in:
parent
3d4773b161
commit
47b6d3c52c
@ -334,12 +334,14 @@ class BaseWizard(object):
|
|||||||
# There is no general standard for HD multisig.
|
# There is no general standard for HD multisig.
|
||||||
# For legacy, this is partially compatible with BIP45; assumes index=0
|
# 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.
|
# For segwit, a custom path is used, as there is no standard at all.
|
||||||
|
default_choice_idx = 2
|
||||||
choices = [
|
choices = [
|
||||||
('standard', 'legacy multisig (p2sh)', "m/45'/0"),
|
('standard', 'legacy multisig (p2sh)', "m/45'/0"),
|
||||||
('p2wsh-p2sh', 'p2sh-segwit multisig (p2wsh-p2sh)', purpose48_derivation(0, xtype='p2wsh-p2sh')),
|
('p2wsh-p2sh', 'p2sh-segwit multisig (p2wsh-p2sh)', purpose48_derivation(0, xtype='p2wsh-p2sh')),
|
||||||
('p2wsh', 'native segwit multisig (p2wsh)', purpose48_derivation(0, xtype='p2wsh')),
|
('p2wsh', 'native segwit multisig (p2wsh)', purpose48_derivation(0, xtype='p2wsh')),
|
||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
|
default_choice_idx = 2
|
||||||
choices = [
|
choices = [
|
||||||
('standard', 'legacy (p2pkh)', bip44_derivation(0, bip43_purpose=44)),
|
('standard', 'legacy (p2pkh)', bip44_derivation(0, bip43_purpose=44)),
|
||||||
('p2wpkh-p2sh', 'p2sh-segwit (p2wpkh-p2sh)', bip44_derivation(0, bip43_purpose=49)),
|
('p2wpkh-p2sh', 'p2sh-segwit (p2wpkh-p2sh)', bip44_derivation(0, bip43_purpose=49)),
|
||||||
@ -349,7 +351,8 @@ class BaseWizard(object):
|
|||||||
try:
|
try:
|
||||||
self.choice_and_line_dialog(
|
self.choice_and_line_dialog(
|
||||||
run_next=f, title=_('Script type and Derivation path'), message1=message1,
|
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
|
return
|
||||||
except ScriptTypeNotSupported as e:
|
except ScriptTypeNotSupported as e:
|
||||||
self.show_error(e)
|
self.show_error(e)
|
||||||
@ -539,7 +542,7 @@ class BaseWizard(object):
|
|||||||
])
|
])
|
||||||
choices = [
|
choices = [
|
||||||
('create_segwit_seed', _('Segwit')),
|
('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)
|
self.choice_dialog(title=title, message=message, choices=choices, run_next=self.run)
|
||||||
|
|
||||||
|
|||||||
@ -189,7 +189,7 @@ def xpub_from_pubkey(xtype, cK):
|
|||||||
return serialize_xpub(xtype, b'\x00'*32, cK)
|
return serialize_xpub(xtype, b'\x00'*32, cK)
|
||||||
|
|
||||||
|
|
||||||
def bip32_derivation(s):
|
def bip32_derivation(s: str) -> int:
|
||||||
if not s.startswith('m/'):
|
if not s.startswith('m/'):
|
||||||
raise ValueError('invalid bip32 derivation path: {}'.format(s))
|
raise ValueError('invalid bip32 derivation path: {}'.format(s))
|
||||||
s = s[2:]
|
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)
|
path.append(abs(int(x)) | prime)
|
||||||
return path
|
return path
|
||||||
|
|
||||||
def is_bip32_derivation(x):
|
def is_bip32_derivation(x: str) -> bool:
|
||||||
try:
|
try:
|
||||||
[ i for i in bip32_derivation(x)]
|
[ i for i in bip32_derivation(x)]
|
||||||
return True
|
return True
|
||||||
|
|||||||
@ -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 os
|
||||||
import sys
|
import sys
|
||||||
import threading
|
import threading
|
||||||
import traceback
|
import traceback
|
||||||
from typing import Tuple
|
from typing import Tuple, List, Callable
|
||||||
|
|
||||||
from PyQt5.QtCore import *
|
from PyQt5.QtCore import *
|
||||||
from PyQt5.QtGui import *
|
from PyQt5.QtGui import *
|
||||||
@ -506,8 +509,9 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
|
|||||||
return clayout.selected_index()
|
return clayout.selected_index()
|
||||||
|
|
||||||
@wizard_dialog
|
@wizard_dialog
|
||||||
def choice_and_line_dialog(self, title, message1, choices, message2,
|
def choice_and_line_dialog(self, title: str, message1: str, choices: List[Tuple[str, str, str]],
|
||||||
test_text, run_next) -> Tuple[str, str]:
|
message2: str, test_text: Callable[[str], int],
|
||||||
|
run_next, default_choice_idx: int=0) -> Tuple[str, str]:
|
||||||
vbox = QVBoxLayout()
|
vbox = QVBoxLayout()
|
||||||
|
|
||||||
c_values = [x[0] for x in choices]
|
c_values = [x[0] for x in choices]
|
||||||
@ -516,7 +520,8 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
|
|||||||
def on_choice_click(clayout):
|
def on_choice_click(clayout):
|
||||||
idx = clayout.selected_index()
|
idx = clayout.selected_index()
|
||||||
line.setText(c_default_text[idx])
|
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.addLayout(clayout.layout())
|
||||||
|
|
||||||
vbox.addSpacing(50)
|
vbox.addSpacing(50)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user