move TrezorClient.expand_path to bitcoin.py
and allow its input to end with a '/' slash
This commit is contained in:
@@ -4,7 +4,7 @@ from struct import pack
|
||||
from electrum.i18n import _
|
||||
from electrum.util import PrintError, UserCancelled
|
||||
from electrum.keystore import bip39_normalize_passphrase
|
||||
from electrum.bitcoin import serialize_xpub
|
||||
from electrum.bitcoin import serialize_xpub, convert_bip32_path_to_list_of_uint32
|
||||
|
||||
|
||||
class GuiMixin(object):
|
||||
@@ -141,21 +141,7 @@ class KeepKeyClientBase(GuiMixin, PrintError):
|
||||
|
||||
@staticmethod
|
||||
def expand_path(n):
|
||||
'''Convert bip32 path to list of uint32 integers with prime flags
|
||||
0/-1/1' -> [0, 0x80000001, 0x80000001]'''
|
||||
# This code is similar to code in trezorlib where it unfortunately
|
||||
# is not declared as a staticmethod. Our n has an extra element.
|
||||
PRIME_DERIVATION_FLAG = 0x80000000
|
||||
path = []
|
||||
for x in n.split('/')[1:]:
|
||||
prime = 0
|
||||
if x.endswith("'"):
|
||||
x = x.replace('\'', '')
|
||||
prime = PRIME_DERIVATION_FLAG
|
||||
if x.startswith('-'):
|
||||
prime = PRIME_DERIVATION_FLAG
|
||||
path.append(abs(int(x)) | prime)
|
||||
return path
|
||||
return convert_bip32_path_to_list_of_uint32(n)
|
||||
|
||||
def cancel(self):
|
||||
'''Provided here as in keepkeylib but not trezorlib.'''
|
||||
|
||||
Reference in New Issue
Block a user