use implicit encoding in encode/decode

pull/25/head
Pavol Rusnak 6 years ago
parent 21326d3a41
commit 434f279069
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

@ -100,7 +100,7 @@ def main():
data = {'label': label, data = {'label': label,
'bip32_path': bip32_path, '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')) json.dump(data, open(passw_file, 'w'))

@ -691,7 +691,7 @@ def sign_tx(connect, coin):
) )
if txapi.bip115: if txapi.bip115:
prev_output = txapi.get_tx( prev_output = txapi.get_tx(
binascii.hexlify(prev_hash).decode("utf-8") binascii.hexlify(prev_hash).decode()
).bin_outputs[prev_index] ).bin_outputs[prev_index]
prev_blockhash = prev_output.block_hash prev_blockhash = prev_output.block_hash
prev_blockheight = prev_output.block_height prev_blockheight = prev_output.block_height

@ -79,7 +79,7 @@ except ImportError:
# skip special keys: read the scancode and repeat # skip special keys: read the scancode and repeat
msvcrt.getch() msvcrt.getch()
continue continue
return key.decode("latin1") return key.decode()
def get_buttonrequest_value(code): def get_buttonrequest_value(code):
@ -499,7 +499,7 @@ class ProtocolMixin(object):
raise RuntimeError("TX_API not defined") raise RuntimeError("TX_API not defined")
prev_tx = self.tx_api.get_tx( 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 txes[inp.prev_hash] = prev_tx

@ -161,7 +161,7 @@ def load_device_by_mnemonic(
mnemonic = Mnemonic.normalize_string(mnemonic) mnemonic = Mnemonic.normalize_string(mnemonic)
# Convert mnemonic to ASCII stream # Convert mnemonic to ASCII stream
mnemonic = mnemonic.encode("utf-8") mnemonic = mnemonic.encode()
m = Mnemonic("english") m = Mnemonic("english")

@ -135,7 +135,7 @@ def validate_firmware(filename):
header_bytes = FirmwareHeader.build(stripped_header) header_bytes = FirmwareHeader.build(stripped_header)
digest = pyblake2.blake2s(header_bytes).digest() 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( global_pk = cosi.combine_keys(
vendor.pubkeys[i] for i in range(8) if header.sigmask & (1 << i) 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: elif ftype is UnicodeType:
if not isinstance(svalue, bytes): if not isinstance(svalue, bytes):
svalue = svalue.encode("utf-8") svalue = svalue.encode()
dump_uvarint(writer, len(svalue)) dump_uvarint(writer, len(svalue))
writer.write(svalue) writer.write(svalue)
@ -388,7 +388,7 @@ def format_message(
if mostly_printable(value): if mostly_printable(value):
output = repr(value) output = repr(value)
else: else:
output = "0x" + binascii.hexlify(value).decode("ascii") output = "0x" + binascii.hexlify(value).decode()
return "{} bytes {}{}".format(length, output, suffix) return "{} bytes {}{}".format(length, output, suffix)
return repr(value) return repr(value)

@ -65,7 +65,7 @@ def address_from_public_key(pk_bytes):
# checksum # checksum
final_bytes.extend(struct.pack("<H", _crc16_checksum(final_bytes))) 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): def address_to_public_key(address_str):

@ -61,7 +61,7 @@ class TestMsgCardanoGetPublicKey(TrezorTest):
key = get_public_key(self.client, parse_path(path)) key = get_public_key(self.client, parse_path(path))
assert hexlify(key.node.public_key).decode("utf8") == public_key assert hexlify(key.node.public_key).decode() == public_key
assert hexlify(key.node.chain_code).decode("utf8") == chain_code assert hexlify(key.node.chain_code).decode() == chain_code
assert key.xpub == public_key + chain_code assert key.xpub == public_key + chain_code
assert key.root_hd_passphrase == root_hd_passphrase 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. This seems to be bitcoin-qt standard of doing things.
""" """
if isinstance(txt, bytes): if isinstance(txt, bytes):
txt = txt.decode("utf-8") txt = txt.decode()
return unicodedata.normalize("NFC", txt).encode("utf-8") return unicodedata.normalize("NFC", txt).encode()
class CallException(Exception): class CallException(Exception):

@ -1 +1 @@
Subproject commit b6f59d351a2007a9bc80a7cdef64669a87c17739 Subproject commit 22b18046c1acabe40340104ff3d8b705336bfda7
Loading…
Cancel
Save