Merge branch 'master' of https://github.com/Coldcard/ckcc-protocol
This commit is contained in:
commit
c53213299f
@ -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
|
||||
|
||||
|
||||
@ -205,7 +205,7 @@ def real_file_upload(fd, blksize=MAX_BLK_LEN, do_upgrade=False, do_reboot=True,
|
||||
|
||||
magic = struct.unpack_from("<I", hdr)[0]
|
||||
#print("hdr @ 0x%x: %s" % (FW_HEADER_OFFSET, b2a_hex(hdr)))
|
||||
except:
|
||||
except Exception:
|
||||
magic = None
|
||||
|
||||
if magic != FW_HEADER_MAGIC:
|
||||
@ -309,7 +309,7 @@ def get_pubkey(subpath):
|
||||
|
||||
try:
|
||||
from pycoin.key.BIP32Node import BIP32Node
|
||||
except:
|
||||
except Exception:
|
||||
raise click.Abort("pycoin must be installed, not found.")
|
||||
|
||||
dev = get_device()
|
||||
@ -410,7 +410,7 @@ def sign_message(message, path, verbose=True, just_sig=False, wrap=False, segwit
|
||||
# standard very much still in flux, see: <https://github.com/bitcoin/bitcoin/issues/10542>
|
||||
|
||||
# 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
|
||||
|
||||
@ -161,10 +161,10 @@ 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:
|
||||
except Exception:
|
||||
#print("Corrupt response: %r" % resp)
|
||||
raise
|
||||
|
||||
@ -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)
|
||||
@ -346,7 +347,7 @@ class UnixSimulatorPipe:
|
||||
self.pipe = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
|
||||
try:
|
||||
self.pipe.connect(path)
|
||||
except:
|
||||
except Exception:
|
||||
self.close()
|
||||
raise RuntimeError("Cannot connect to simulator. Is it running?")
|
||||
|
||||
@ -388,7 +389,8 @@ class UnixSimulatorPipe:
|
||||
self.pipe.close()
|
||||
try:
|
||||
os.unlink(self.pipe_name)
|
||||
except: pass
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def get_serial_number_string(self):
|
||||
return 'simulator'
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user