diff --git a/trezorctl b/trezorctl index a224ed419a..d461749c3f 100755 --- a/trezorctl +++ b/trezorctl @@ -677,7 +677,7 @@ def sign_tx(connect, coin): sequence = click.prompt( "Sequence Number to use (RBF opt-in enabled by default)", type=int, - default=0xfffffffd, + default=0xFFFFFFFD, ) script_type = click.prompt( "Input type", diff --git a/trezorlib/client.py b/trezorlib/client.py index 82fd820b34..6e8f12fe7e 100644 --- a/trezorlib/client.py +++ b/trezorlib/client.py @@ -74,7 +74,7 @@ except ImportError: def getch(): while True: key = msvcrt.getch() - if key in (0x00, 0xe0): + if key in (0x00, 0xE0): # skip special keys: read the scancode and repeat msvcrt.getch() continue diff --git a/trezorlib/firmware.py b/trezorlib/firmware.py index 41c666f8f1..acdbbeab75 100644 --- a/trezorlib/firmware.py +++ b/trezorlib/firmware.py @@ -1,4 +1,3 @@ - import construct as c import pyblake2 @@ -6,7 +5,7 @@ from . import cosi, messages as proto, tools def bytes_not(data): - return bytes(~b & 0xff for b in data) + return bytes(~b & 0xFF for b in data) # fmt: off diff --git a/trezorlib/lisk.py b/trezorlib/lisk.py index fe571c6062..a86f1af961 100644 --- a/trezorlib/lisk.py +++ b/trezorlib/lisk.py @@ -1,4 +1,3 @@ - from . import messages as proto from .protobuf import dict_to_proto from .tools import CallException, dict_from_camelcase, expect, normalize_nfc diff --git a/trezorlib/protobuf.py b/trezorlib/protobuf.py index 2a346f8bae..c94362c8c8 100644 --- a/trezorlib/protobuf.py +++ b/trezorlib/protobuf.py @@ -356,7 +356,7 @@ def format_message( def mostly_printable(bytes): if not bytes: return True - printable = sum(1 for byte in bytes if 0x20 <= byte <= 0x7e) + printable = sum(1 for byte in bytes if 0x20 <= byte <= 0x7E) return printable / len(bytes) > 0.8 def pformat_value(value: Any, indent: int) -> str: diff --git a/trezorlib/stellar.py b/trezorlib/stellar.py index fac24f49cb..2471704be0 100644 --- a/trezorlib/stellar.py +++ b/trezorlib/stellar.py @@ -336,7 +336,7 @@ def _crc16_checksum(bytes): if c15 ^ bit: crc ^= polynomial - return crc & 0xffff + return crc & 0xFFFF # ====== Client functions ====== # diff --git a/trezorlib/tests/device_tests/test_bip32_speed.py b/trezorlib/tests/device_tests/test_bip32_speed.py index b1aeeeaae6..91072b238a 100644 --- a/trezorlib/tests/device_tests/test_bip32_speed.py +++ b/trezorlib/tests/device_tests/test_bip32_speed.py @@ -70,4 +70,4 @@ class TestBip32Speed(TrezorTest): print("CACHED TIME", cache_time) # Cached time expected to be at least 2x faster - assert cache_time <= nocache_time / 2. + assert cache_time <= nocache_time / 2.0 diff --git a/trezorlib/tests/device_tests/test_msg_ethereum_signtx.py b/trezorlib/tests/device_tests/test_msg_ethereum_signtx.py index 33805139a6..d6d5ab793e 100644 --- a/trezorlib/tests/device_tests/test_msg_ethereum_signtx.py +++ b/trezorlib/tests/device_tests/test_msg_ethereum_signtx.py @@ -366,8 +366,8 @@ class TestMsgEthereumSigntx(TrezorTest): self.client, n=[0, 0], nonce=123456, - gas_price=0xffffffffffffffffffffffffffffffff, - gas_limit=0xffffffffffffffffffffffffffffff, + gas_price=0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, + gas_limit=0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, to=TO_ADDR, value=12345678901234567890, ) diff --git a/trezorlib/tests/device_tests/test_msg_ontology_sign_ont_id_add_attributes.py b/trezorlib/tests/device_tests/test_msg_ontology_sign_ont_id_add_attributes.py index 1d1343ab3b..0a336d7bc8 100644 --- a/trezorlib/tests/device_tests/test_msg_ontology_sign_ont_id_add_attributes.py +++ b/trezorlib/tests/device_tests/test_msg_ontology_sign_ont_id_add_attributes.py @@ -33,8 +33,8 @@ class TestMsgOntologySignOntIdAddAttributes(TrezorTest): transaction = messages.OntologyTransaction( version=0x00, - nonce=0x7f7f1ceb, - type=0xd1, + nonce=0x7F7F1CEB, + type=0xD1, gas_price=500, gas_limit=30000, payer="AGn8JFPGM5S4jkWhTC89Xtz1Y76sPz29Rc", diff --git a/trezorlib/tests/device_tests/test_msg_ontology_sign_ont_id_register.py b/trezorlib/tests/device_tests/test_msg_ontology_sign_ont_id_register.py index bc3bc6cf67..ac6b7cb644 100644 --- a/trezorlib/tests/device_tests/test_msg_ontology_sign_ont_id_register.py +++ b/trezorlib/tests/device_tests/test_msg_ontology_sign_ont_id_register.py @@ -33,8 +33,8 @@ class TestMsgOntologySignOntIdRegister(TrezorTest): transaction = messages.OntologyTransaction( version=0x00, - nonce=0x7f7f1ceb, - type=0xd1, + nonce=0x7F7F1CEB, + type=0xD1, gas_price=500, gas_limit=30000, payer="AGn8JFPGM5S4jkWhTC89Xtz1Y76sPz29Rc", diff --git a/trezorlib/tests/device_tests/test_msg_ontology_sign_tx.py b/trezorlib/tests/device_tests/test_msg_ontology_sign_tx.py index fe8b37549c..be0f9fe203 100644 --- a/trezorlib/tests/device_tests/test_msg_ontology_sign_tx.py +++ b/trezorlib/tests/device_tests/test_msg_ontology_sign_tx.py @@ -31,8 +31,8 @@ class TestMsgOntologySigntx(TrezorTest): transaction = messages.OntologyTransaction( version=0x00, - nonce=0x7f7f1ceb, - type=0xd1, + nonce=0x7F7F1CEB, + type=0xD1, gas_price=500, gas_limit=30000, payer="AGn8JFPGM5S4jkWhTC89Xtz1Y76sPz29Rc", @@ -63,8 +63,8 @@ class TestMsgOntologySigntx(TrezorTest): transaction = messages.OntologyTransaction( version=0x00, - nonce=0x7f7f1ceb, - type=0xd1, + nonce=0x7F7F1CEB, + type=0xD1, gas_price=500, gas_limit=30000, payer="AGn8JFPGM5S4jkWhTC89Xtz1Y76sPz29Rc", diff --git a/trezorlib/tests/device_tests/test_msg_ontology_sign_withdraw_ong.py b/trezorlib/tests/device_tests/test_msg_ontology_sign_withdraw_ong.py index e66d473db5..6bcfa442d4 100644 --- a/trezorlib/tests/device_tests/test_msg_ontology_sign_withdraw_ong.py +++ b/trezorlib/tests/device_tests/test_msg_ontology_sign_withdraw_ong.py @@ -31,8 +31,8 @@ class TestMsgOntologySignWithdraw(TrezorTest): transaction = messages.OntologyTransaction( version=0x00, - nonce=0x7f7f1ceb, - type=0xd1, + nonce=0x7F7F1CEB, + type=0xD1, gas_price=500, gas_limit=30000, payer="AGn8JFPGM5S4jkWhTC89Xtz1Y76sPz29Rc", diff --git a/trezorlib/tests/device_tests/test_msg_stellar_sign_transaction.py b/trezorlib/tests/device_tests/test_msg_stellar_sign_transaction.py index 42c175e50e..87538c4919 100644 --- a/trezorlib/tests/device_tests/test_msg_stellar_sign_transaction.py +++ b/trezorlib/tests/device_tests/test_msg_stellar_sign_transaction.py @@ -68,7 +68,7 @@ class TestMsgStellarSignTransaction(TrezorTest): self.setup_mnemonic_nopin_nopassphrase() op = proto.StellarBumpSequenceOp() - op.bump_to = 0x7fffffffffffffff + op.bump_to = 0x7FFFFFFFFFFFFFFF tx = self._create_msg() response = stellar.sign_tx( diff --git a/trezorlib/tests/unit_tests/test_protobuf.py b/trezorlib/tests/unit_tests/test_protobuf.py index 0ea04ea094..cdc2a8aa69 100644 --- a/trezorlib/tests/unit_tests/test_protobuf.py +++ b/trezorlib/tests/unit_tests/test_protobuf.py @@ -47,7 +47,7 @@ def dump_uvarint(value): def test_dump_uvarint(): assert dump_uvarint(0) == b"\x00" assert dump_uvarint(1) == b"\x01" - assert dump_uvarint(0xff) == b"\xff\x01" + assert dump_uvarint(0xFF) == b"\xff\x01" assert dump_uvarint(123456) == b"\xc0\xc4\x07" with pytest.raises(ValueError): @@ -57,7 +57,7 @@ def test_dump_uvarint(): def test_load_uvarint(): assert load_uvarint(b"\x00") == 0 assert load_uvarint(b"\x01") == 1 - assert load_uvarint(b"\xff\x01") == 0xff + assert load_uvarint(b"\xff\x01") == 0xFF assert load_uvarint(b"\xc0\xc4\x07") == 123456 diff --git a/trezorlib/transport/hid.py b/trezorlib/transport/hid.py index 4c7bf33545..e226bb172c 100644 --- a/trezorlib/transport/hid.py +++ b/trezorlib/transport/hid.py @@ -23,9 +23,9 @@ from . import Transport, TransportException from ..protocol_v1 import ProtocolV1 from ..protocol_v2 import ProtocolV2 -DEV_TREZOR1 = (0x534c, 0x0001) -DEV_TREZOR2 = (0x1209, 0x53c1) -DEV_TREZOR2_BL = (0x1209, 0x53c0) +DEV_TREZOR1 = (0x534C, 0x0001) +DEV_TREZOR2 = (0x1209, 0x53C1) +DEV_TREZOR2_BL = (0x1209, 0x53C0) class HidHandle: diff --git a/trezorlib/transport/webusb.py b/trezorlib/transport/webusb.py index b2efd98d82..6098a24300 100644 --- a/trezorlib/transport/webusb.py +++ b/trezorlib/transport/webusb.py @@ -24,9 +24,9 @@ from . import Transport, TransportException from ..protocol_v1 import ProtocolV1 from ..protocol_v2 import ProtocolV2 -DEV_TREZOR1 = (0x534c, 0x0001) -DEV_TREZOR2 = (0x1209, 0x53c1) -DEV_TREZOR2_BL = (0x1209, 0x53c0) +DEV_TREZOR1 = (0x534C, 0x0001) +DEV_TREZOR2 = (0x1209, 0x53C1) +DEV_TREZOR2_BL = (0x1209, 0x53C0) INTERFACE = 0 ENDPOINT = 1 diff --git a/trezorlib/tx_api.py b/trezorlib/tx_api.py index 7f3d2a56d2..750d172d15 100644 --- a/trezorlib/tx_api.py +++ b/trezorlib/tx_api.py @@ -97,7 +97,7 @@ class TxApiInsight(TxApi): i = t._add_inputs() if "coinbase" in vin.keys(): i.prev_hash = b"\0" * 32 - i.prev_index = 0xffffffff # signed int -1 + i.prev_index = 0xFFFFFFFF # signed int -1 i.script_sig = bytes.fromhex(vin["coinbase"]) i.sequence = vin["sequence"] @@ -111,7 +111,7 @@ class TxApiInsight(TxApi): o = t._add_bin_outputs() o.amount = int(Decimal(vout["value"]) * 100000000) o.script_pubkey = bytes.fromhex(vout["scriptPubKey"]["hex"]) - if self.bip115 and o.script_pubkey[-1] == 0xb4: + if self.bip115 and o.script_pubkey[-1] == 0xB4: # Verify if coin implements replay protection bip115 and script includes checkblockatheight opcode. 0xb4 - is op_code (OP_CHECKBLOCKATHEIGHT) # <32-byte block hash> <3-byte block height> tail = o.script_pubkey[-38:]