wizard: extend derivation dialog to also let user select script type.
enable segwit multisig for bip39/hw wallets.
This commit is contained in:
@@ -600,14 +600,26 @@ def from_bip39_seed(seed, passphrase, derivation, xtype=None):
|
||||
return k
|
||||
|
||||
|
||||
def xtype_from_derivation(derivation):
|
||||
def xtype_from_derivation(derivation: str) -> str:
|
||||
"""Returns the script type to be used for this derivation."""
|
||||
if derivation.startswith("m/84'"):
|
||||
return 'p2wpkh'
|
||||
elif derivation.startswith("m/49'"):
|
||||
return 'p2wpkh-p2sh'
|
||||
else:
|
||||
elif derivation.startswith("m/44'"):
|
||||
return 'standard'
|
||||
elif derivation.startswith("m/45'"):
|
||||
return 'standard'
|
||||
|
||||
bip32_indices = list(bip32_derivation(derivation))
|
||||
if len(bip32_indices) >= 4:
|
||||
if bip32_indices[0] == 48 + BIP32_PRIME:
|
||||
# m / purpose' / coin_type' / account' / script_type' / change / address_index
|
||||
script_type_int = bip32_indices[3] - BIP32_PRIME
|
||||
script_type = PURPOSE48_SCRIPT_TYPES_INV.get(script_type_int)
|
||||
if script_type is not None:
|
||||
return script_type
|
||||
return 'standard'
|
||||
|
||||
|
||||
# extended pubkeys
|
||||
@@ -719,6 +731,18 @@ def bip44_derivation(account_id, bip43_purpose=44):
|
||||
coin = constants.net.BIP44_COIN_TYPE
|
||||
return "m/%d'/%d'/%d'" % (bip43_purpose, coin, int(account_id))
|
||||
|
||||
|
||||
def purpose48_derivation(account_id: int, xtype: str) -> str:
|
||||
# m / purpose' / coin_type' / account' / script_type' / change / address_index
|
||||
bip43_purpose = 48
|
||||
coin = constants.net.BIP44_COIN_TYPE
|
||||
account_id = int(account_id)
|
||||
script_type_int = PURPOSE48_SCRIPT_TYPES.get(xtype)
|
||||
if script_type_int is None:
|
||||
raise Exception('unknown xtype: {}'.format(xtype))
|
||||
return "m/%d'/%d'/%d'/%d'" % (bip43_purpose, coin, account_id, script_type_int)
|
||||
|
||||
|
||||
def from_seed(seed, passphrase, is_p2sh):
|
||||
t = seed_type(seed)
|
||||
if t == 'old':
|
||||
|
||||
Reference in New Issue
Block a user