bip32: fix hardened char "h" vs "'" compatibility for some hw wallets
in particular, ledger: fix sign_message for some wallets
```
156.02 | E | plugins.ledger.ledger |
Traceback (most recent call last):
File "...\electrum\electrum\plugins\ledger\ledger.py", line 1265, in sign_message
result = base64.b64decode(self.client.sign_message(message, address_path))
File "...\Python310\site-packages\ledger_bitcoin\client.py", line 230, in sign_message
sw, response = self._make_request(self.builder.sign_message(message_bytes, bip32_path), client_intepreter)
File "...\Python310\site-packages\ledger_bitcoin\command_builder.py", line 176, in sign_message
bip32_path: List[bytes] = bip32_path_from_string(bip32_path)
File "...\Python310\site-packages\ledger_bitcoin\common.py", line 68, in bip32_path_from_string
return [int(p).to_bytes(4, byteorder="big") if "'" not in p
File "...\Python310\site-packages\ledger_bitcoin\common.py", line 68, in <listcomp>
return [int(p).to_bytes(4, byteorder="big") if "'" not in p
ValueError: invalid literal for int() with base 10: '84h'
```
Regression from df2bd61de6, where the
default hardened char was changed from "'" to "h". Note that there was
no corresponding wallet db upgrade, so some files use one char and
others use the other.
This commit is contained in:
@@ -19,6 +19,7 @@ import copy
|
||||
from electrum.crypto import sha256d, EncodeAES_bytes, DecodeAES_bytes, hmac_oneshot
|
||||
from electrum.bitcoin import public_key_to_p2pkh
|
||||
from electrum.bip32 import BIP32Node, convert_bip32_intpath_to_strpath, is_all_public_derivation
|
||||
from electrum.bip32 import normalize_bip32_derivation
|
||||
from electrum import descriptor
|
||||
from electrum import ecc
|
||||
from electrum.ecc import msg_magic
|
||||
@@ -104,7 +105,8 @@ class DigitalBitbox_Client(HardwareClientBase):
|
||||
return False
|
||||
return True
|
||||
|
||||
def _get_xpub(self, bip32_path):
|
||||
def _get_xpub(self, bip32_path: str):
|
||||
bip32_path = normalize_bip32_derivation(bip32_path, hardened_char="'")
|
||||
if self.check_device_dialog():
|
||||
return self.hid_send_encrypt(('{"xpub": "%s"}' % bip32_path).encode('utf8'))
|
||||
|
||||
@@ -458,6 +460,7 @@ class DigitalBitbox_KeyStore(Hardware_KeyStore):
|
||||
try:
|
||||
message = message.encode('utf8')
|
||||
inputPath = self.get_derivation_prefix() + "/%d/%d" % sequence
|
||||
inputPath = normalize_bip32_derivation(inputPath, hardened_char="'")
|
||||
msg_hash = sha256d(msg_magic(message))
|
||||
inputHash = to_hexstr(msg_hash)
|
||||
hasharray = []
|
||||
|
||||
Reference in New Issue
Block a user