mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-01 17:55:20 +00:00
ecc.ECPubkey: also accept bytearray in __init__
regression since #5947 Traceback (most recent call last): File "...\electrum\electrum\base_wizard.py", line 339, in on_device self.plugin.setup_device(device_info, self, purpose) File "...\electrum\electrum\plugins\ledger\ledger.py", line 598, in setup_device client.get_xpub("m/44'/0'", 'standard') # TODO replace by direct derivation once Nano S > 1.1 File "...\electrum\electrum\plugins\ledger\ledger.py", line 55, in catch_exception return func(self, *args, **kwargs) File "...\electrum\electrum\plugins\ledger\ledger.py", line 124, in get_xpub eckey=ecc.ECPubkey(publicKey), File "...\electrum\electrum\ecc.py", line 145, in __init__ self._x, self._y = _x_and_y_from_pubkey_bytes(b) File "...\electrum\electrum\ecc.py", line 119, in _x_and_y_from_pubkey_bytes ret = _libsecp256k1.secp256k1_ec_pubkey_parse( ctypes.ArgumentError: argument 3: <class 'TypeError'>: wrong type
This commit is contained in:
parent
0845300150
commit
9c5e49f432
2 changed files with 5 additions and 2 deletions
|
@ -115,6 +115,7 @@ def sig_string_from_r_and_s(r: int, s: int) -> bytes:
|
|||
|
||||
|
||||
def _x_and_y_from_pubkey_bytes(pubkey: bytes) -> Tuple[int, int]:
|
||||
assert isinstance(pubkey, bytes), f'pubkey must be bytes, not {type(pubkey)}'
|
||||
pubkey_ptr = create_string_buffer(64)
|
||||
ret = _libsecp256k1.secp256k1_ec_pubkey_parse(
|
||||
_libsecp256k1.ctx, pubkey_ptr, pubkey, len(pubkey))
|
||||
|
@ -141,7 +142,9 @@ class ECPubkey(object):
|
|||
|
||||
def __init__(self, b: Optional[bytes]):
|
||||
if b is not None:
|
||||
assert_bytes(b)
|
||||
assert isinstance(b, (bytes, bytearray)), f'pubkey must be bytes-like, not {type(b)}'
|
||||
if isinstance(b, bytearray):
|
||||
b = bytes(b)
|
||||
self._x, self._y = _x_and_y_from_pubkey_bytes(b)
|
||||
else:
|
||||
self._x, self._y = None, None
|
||||
|
|
|
@ -121,7 +121,7 @@ class Ledger_Client(HardwareClientBase):
|
|||
publicKey = compress_public_key(nodeData['publicKey'])
|
||||
depth = len(bip32_intpath)
|
||||
return BIP32Node(xtype=xtype,
|
||||
eckey=ecc.ECPubkey(publicKey),
|
||||
eckey=ecc.ECPubkey(bytes(publicKey)),
|
||||
chaincode=nodeData['chainCode'],
|
||||
depth=depth,
|
||||
fingerprint=fingerprint_bytes,
|
||||
|
|
Loading…
Add table
Reference in a new issue