Skip to content

Commit ffc6a59

Browse files
committed
move firmware version utility functions to ColdcardDevice class
1 parent 98defe6 commit ffc6a59

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

hwilib/devices/ckcc/client.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,18 @@ def hash_password(self, text_password, v3=False):
333333

334334
return pbkdf2_hmac('sha256' if v3 else 'sha512', text_password, salt, PBKDF2_ITER_COUNT)[:32]
335335

336+
def firmware_version(self):
337+
return self.send_recv(CCProtocolPacker.version()).split("\n")[1]
338+
339+
def is_edge(self):
340+
# returns True if device is running EDGE firmware version
341+
if self.is_simulator:
342+
cmd = "import version; RV.write(str(int(getattr(version, 'is_edge', 0))))"
343+
rv = self.send_recv(b'EXEC' + cmd.encode('utf-8'), timeout=60000, encrypt=False)
344+
return rv == b"1"
345+
346+
return self.firmware_version()[-1] == "X"
347+
336348

337349
class UnixSimulatorPipe:
338350
# Use a UNIX pipe to the simulator instead of a real USB connection.

hwilib/devices/coldcard.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def is_edge(self):
110110
"""
111111
if self._is_edge is None:
112112
try:
113-
self._is_edge = self.is_edge_firmware()
113+
self._is_edge = self.device.is_edge()
114114
except:
115115
# silent fail, normal firmware is implied
116116
pass
@@ -408,21 +408,6 @@ def toggle_passphrase(self) -> bool:
408408
"""
409409
raise UnavailableActionError('The Coldcard does not support toggling passphrase from the host')
410410

411-
def firmware_version(self) -> str:
412-
return self.device.send_recv(CCProtocolPacker.version()).split("\n")[1]
413-
414-
def is_edge_firmware(self):
415-
"""
416-
:return: True if this device is running EDGE firmware, False otherwise
417-
"""
418-
if self.device.is_simulator:
419-
cmd = "import version; RV.write(str(int(getattr(version, 'is_edge', 0))))"
420-
rv = self.device.send_recv(b'EXEC' + cmd.encode('utf-8'), timeout=60000, encrypt=False)
421-
return rv == b"1"
422-
else:
423-
_, ver, _, _, _ = self.device.send_recv(CCProtocolPacker.version()).split("\n")
424-
return "X" == self.firmware_version()[-1]
425-
426411
def can_sign_taproot(self) -> bool:
427412
"""
428413
Only COLDCARD EDGE support taproot.

0 commit comments

Comments
 (0)