From d2316ef4cbc3c9c738765a28c653d0c8de5c9380 Mon Sep 17 00:00:00 2001 From: Ferdinando Ametrano Date: Tue, 18 Aug 2020 18:16:59 +0200 Subject: [PATCH 1/4] avoided bare except --- ckcc/cli.py | 4 ++-- ckcc/client.py | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/ckcc/cli.py b/ckcc/cli.py index ca3d56c..4895f4d 100755 --- a/ckcc/cli.py +++ b/ckcc/cli.py @@ -198,7 +198,7 @@ def real_file_upload(fd, blksize=MAX_BLK_LEN, do_upgrade=False, do_reboot=True, magic = struct.unpack_from(" Date: Tue, 25 Aug 2020 18:33:41 +0200 Subject: [PATCH 2/4] extended sign_message to also sign bytes, not only string --- ckcc/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ckcc/cli.py b/ckcc/cli.py index ca3d56c..34f4c9c 100755 --- a/ckcc/cli.py +++ b/ckcc/cli.py @@ -403,7 +403,7 @@ def sign_message(message, path, verbose=True, just_sig=False, wrap=False, segwit # standard very much still in flux, see: # not enforcing policy here on msg contents, so we can define that on product - message = message.encode('ascii') + message = message.encode('ascii') if not isinstance(message, bytes) else message ok = dev.send_recv(CCProtocolPacker.sign_message(message, path, addr_fmt), timeout=None) assert ok == None From ee01da3e5cdfafb52baf11b6002768783ab18d2b Mon Sep 17 00:00:00 2001 From: Ferdinando Ametrano Date: Tue, 18 Aug 2020 19:10:25 +0200 Subject: [PATCH 3/4] silenced unused variables --- ckcc/client.py | 5 +++-- ckcc/utils.py | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ckcc/client.py b/ckcc/client.py index 6610cd4..3fc23d5 100644 --- a/ckcc/client.py +++ b/ckcc/client.py @@ -161,7 +161,7 @@ class ColdcardDevice: print("Rx [%2d]: %r" % (len(resp), b2a_hex(bytes(resp)))) return CCProtocolUnpacker.decode(resp) - except CCProtoError as e: + except CCProtoError: if expect_errors: raise raise except: @@ -260,7 +260,8 @@ class ColdcardDevice: # If Pycoin is not available, do it using ecdsa from ecdsa import BadSignatureError, SECP256k1, VerifyingKey - pubkey, chaincode = decode_xpub(expected_xpub) + # of the returned (pubkey, chaincode) tuple, chaincode is not used + pubkey, _ = decode_xpub(expected_xpub) vk = VerifyingKey.from_string(get_pubkey_string(pubkey), curve=SECP256k1) try: ok = vk.verify_digest(sig[1:], self.session_key) diff --git a/ckcc/utils.py b/ckcc/utils.py index 3f4e6e6..5389293 100644 --- a/ckcc/utils.py +++ b/ckcc/utils.py @@ -24,14 +24,14 @@ def dfu_parse(fd): assert dfu_prefix.signature == b'DfuSe', "Not a DFU file (bad magic)" - for idx in range(dfu_prefix.targets): + for _ in range(dfu_prefix.targets): prefix = consume(fd, 'Target', '<6sBI255s2I', 'signature altsetting named name size elements') #print("target%d: %r" % (idx, prefix)) - for ei in range(prefix.elements): + for _ in range(prefix.elements): # Decode target prefix # < little endian # I uint32_t element address From cf1ad47a07d76daf596039a63fc531fc5ecb768f Mon Sep 17 00:00:00 2001 From: "Ferdinando M. Ametrano" Date: Tue, 25 Aug 2020 20:06:37 +0200 Subject: [PATCH 4/4] fixed typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 04cb1ea..87ac6a1 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Coldcard is a Cheap, Ultra-secure & Opensource Hardware Wallet for #Bitcoin. Get yours at [ColdcardWallet.com](http://coldcardwallet.com) -This is the python code and command-line utilities you need to communciate with it over USB. +This is the python code and command-line utilities you need to communicate with it over USB. ## Setup For Everyday Use