mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-23 06:48:16 +00:00
use implicit encoding in encode/decode
This commit is contained in:
parent
21326d3a41
commit
434f279069
@ -100,7 +100,7 @@ def main():
|
||||
|
||||
data = {'label': label,
|
||||
'bip32_path': bip32_path,
|
||||
'password_encrypted_hex': binascii.hexlify(passw_encrypted).decode('ascii')}
|
||||
'password_encrypted_hex': binascii.hexlify(passw_encrypted).decode()}
|
||||
|
||||
json.dump(data, open(passw_file, 'w'))
|
||||
|
||||
|
@ -691,7 +691,7 @@ def sign_tx(connect, coin):
|
||||
)
|
||||
if txapi.bip115:
|
||||
prev_output = txapi.get_tx(
|
||||
binascii.hexlify(prev_hash).decode("utf-8")
|
||||
binascii.hexlify(prev_hash).decode()
|
||||
).bin_outputs[prev_index]
|
||||
prev_blockhash = prev_output.block_hash
|
||||
prev_blockheight = prev_output.block_height
|
||||
|
@ -79,7 +79,7 @@ except ImportError:
|
||||
# skip special keys: read the scancode and repeat
|
||||
msvcrt.getch()
|
||||
continue
|
||||
return key.decode("latin1")
|
||||
return key.decode()
|
||||
|
||||
|
||||
def get_buttonrequest_value(code):
|
||||
@ -499,7 +499,7 @@ class ProtocolMixin(object):
|
||||
raise RuntimeError("TX_API not defined")
|
||||
|
||||
prev_tx = self.tx_api.get_tx(
|
||||
binascii.hexlify(inp.prev_hash).decode("utf-8")
|
||||
binascii.hexlify(inp.prev_hash).decode()
|
||||
)
|
||||
txes[inp.prev_hash] = prev_tx
|
||||
|
||||
|
@ -161,7 +161,7 @@ def load_device_by_mnemonic(
|
||||
mnemonic = Mnemonic.normalize_string(mnemonic)
|
||||
|
||||
# Convert mnemonic to ASCII stream
|
||||
mnemonic = mnemonic.encode("utf-8")
|
||||
mnemonic = mnemonic.encode()
|
||||
|
||||
m = Mnemonic("english")
|
||||
|
||||
|
@ -135,7 +135,7 @@ def validate_firmware(filename):
|
||||
header_bytes = FirmwareHeader.build(stripped_header)
|
||||
digest = pyblake2.blake2s(header_bytes).digest()
|
||||
|
||||
print("Fingerprint: {}".format(binascii.hexlify(digest).decode("ascii")))
|
||||
print("Fingerprint: {}".format(binascii.hexlify(digest).decode()))
|
||||
|
||||
global_pk = cosi.combine_keys(
|
||||
vendor.pubkeys[i] for i in range(8) if header.sigmask & (1 << i)
|
||||
|
@ -329,7 +329,7 @@ def dump_message(writer, msg):
|
||||
|
||||
elif ftype is UnicodeType:
|
||||
if not isinstance(svalue, bytes):
|
||||
svalue = svalue.encode("utf-8")
|
||||
svalue = svalue.encode()
|
||||
|
||||
dump_uvarint(writer, len(svalue))
|
||||
writer.write(svalue)
|
||||
@ -388,7 +388,7 @@ def format_message(
|
||||
if mostly_printable(value):
|
||||
output = repr(value)
|
||||
else:
|
||||
output = "0x" + binascii.hexlify(value).decode("ascii")
|
||||
output = "0x" + binascii.hexlify(value).decode()
|
||||
return "{} bytes {}{}".format(length, output, suffix)
|
||||
|
||||
return repr(value)
|
||||
|
@ -65,7 +65,7 @@ def address_from_public_key(pk_bytes):
|
||||
# checksum
|
||||
final_bytes.extend(struct.pack("<H", _crc16_checksum(final_bytes)))
|
||||
|
||||
return str(base64.b32encode(final_bytes), "utf-8")
|
||||
return base64.b32encode(final_bytes).decode()
|
||||
|
||||
|
||||
def address_to_public_key(address_str):
|
||||
|
@ -61,7 +61,7 @@ class TestMsgCardanoGetPublicKey(TrezorTest):
|
||||
|
||||
key = get_public_key(self.client, parse_path(path))
|
||||
|
||||
assert hexlify(key.node.public_key).decode("utf8") == public_key
|
||||
assert hexlify(key.node.chain_code).decode("utf8") == chain_code
|
||||
assert hexlify(key.node.public_key).decode() == public_key
|
||||
assert hexlify(key.node.chain_code).decode() == chain_code
|
||||
assert key.xpub == public_key + chain_code
|
||||
assert key.root_hd_passphrase == root_hd_passphrase
|
||||
|
@ -170,8 +170,8 @@ def normalize_nfc(txt):
|
||||
This seems to be bitcoin-qt standard of doing things.
|
||||
"""
|
||||
if isinstance(txt, bytes):
|
||||
txt = txt.decode("utf-8")
|
||||
return unicodedata.normalize("NFC", txt).encode("utf-8")
|
||||
txt = txt.decode()
|
||||
return unicodedata.normalize("NFC", txt).encode()
|
||||
|
||||
|
||||
class CallException(Exception):
|
||||
|
2
vendor/trezor-common
vendored
2
vendor/trezor-common
vendored
@ -1 +1 @@
|
||||
Subproject commit b6f59d351a2007a9bc80a7cdef64669a87c17739
|
||||
Subproject commit 22b18046c1acabe40340104ff3d8b705336bfda7
|
Loading…
Reference in New Issue
Block a user