flake8: enable more mandatory tests
This commit is contained in:
@@ -241,7 +241,7 @@ class CKCCClient(HardwareClientBase):
|
||||
# get a file
|
||||
return self.dev.download_file(length, checksum, file_number=file_number)
|
||||
|
||||
|
||||
|
||||
|
||||
class Coldcard_KeyStore(Hardware_KeyStore):
|
||||
hw_type = 'coldcard'
|
||||
@@ -311,7 +311,7 @@ class Coldcard_KeyStore(Hardware_KeyStore):
|
||||
except (UnicodeError, AssertionError):
|
||||
# there are other restrictions on message content,
|
||||
# but let the device enforce and report those
|
||||
self.handler.show_error('Only short (%d max) ASCII messages can be signed.'
|
||||
self.handler.show_error('Only short (%d max) ASCII messages can be signed.'
|
||||
% MSG_SIGNING_MAX_LENGTH)
|
||||
return b''
|
||||
|
||||
@@ -382,7 +382,7 @@ class Coldcard_KeyStore(Hardware_KeyStore):
|
||||
break
|
||||
|
||||
rlen, rsha = resp
|
||||
|
||||
|
||||
# download the resulting txn.
|
||||
raw_resp = client.download_file(rlen, rsha)
|
||||
|
||||
|
||||
@@ -233,7 +233,7 @@ class CKCCSettingsDialog(WindowModalDialog):
|
||||
self.window.show_error("Does not appear to be a Coldcard firmware file.\n\n%s" % exc)
|
||||
return
|
||||
|
||||
# TODO:
|
||||
# TODO:
|
||||
# - detect if they are trying to downgrade; aint gonna work
|
||||
# - warn them about the reboot?
|
||||
# - length checks
|
||||
|
||||
@@ -350,8 +350,8 @@ class DigitalBitbox_Client(HardwareClientBase):
|
||||
HWW_CID = 0xFF000000
|
||||
HWW_CMD = 0x80 + 0x40 + 0x01
|
||||
data_len = len(data)
|
||||
seq = 0;
|
||||
idx = 0;
|
||||
seq = 0
|
||||
idx = 0
|
||||
write = []
|
||||
while idx < data_len:
|
||||
if idx == 0:
|
||||
@@ -373,7 +373,7 @@ class DigitalBitbox_Client(HardwareClientBase):
|
||||
cmd = read[4]
|
||||
data_len = read[5] * 256 + read[6]
|
||||
data = read[7:]
|
||||
idx = len(read) - 7;
|
||||
idx = len(read) - 7
|
||||
while idx < data_len:
|
||||
# CONT response
|
||||
read = bytearray(self.dbb_hid.read(self.usbReportSize))
|
||||
|
||||
@@ -44,14 +44,14 @@ class LedgerAuthDialog(QDialog):
|
||||
self.cfg = copy.deepcopy(self.handler.win.wallet.get_keystore().cfg)
|
||||
self.dongle = client.dongleObject.dongle
|
||||
self.pin = ''
|
||||
|
||||
|
||||
self.devmode = self.getDevice2FAMode()
|
||||
if self.devmode == 0x11 or self.txdata['confirmationType'] == 1:
|
||||
self.cfg['mode'] = 0
|
||||
|
||||
|
||||
vbox = QVBoxLayout()
|
||||
self.setLayout(vbox)
|
||||
|
||||
|
||||
def on_change_mode(idx):
|
||||
self.cfg['mode'] = 0 if self.devmode == 0x11 else idx if idx > 0 else 1
|
||||
if self.cfg['mode'] > 0:
|
||||
@@ -59,11 +59,11 @@ class LedgerAuthDialog(QDialog):
|
||||
self.handler.win.wallet.save_keystore()
|
||||
self.update_dlg()
|
||||
def return_pin():
|
||||
self.pin = self.pintxt.text() if self.txdata['confirmationType'] == 1 else self.cardtxt.text()
|
||||
self.pin = self.pintxt.text() if self.txdata['confirmationType'] == 1 else self.cardtxt.text()
|
||||
if self.cfg['mode'] == 1:
|
||||
self.pin = ''.join(chr(int(str(i),16)) for i in self.pin)
|
||||
self.accept()
|
||||
|
||||
|
||||
self.modebox = QWidget()
|
||||
modelayout = QHBoxLayout()
|
||||
self.modebox.setLayout(modelayout)
|
||||
@@ -73,7 +73,7 @@ class LedgerAuthDialog(QDialog):
|
||||
modelayout.addStretch(1)
|
||||
self.modebox.setMaximumHeight(50)
|
||||
vbox.addWidget(self.modebox)
|
||||
|
||||
|
||||
self.populate_modes()
|
||||
self.modes.currentIndexChanged.connect(on_change_mode)
|
||||
|
||||
@@ -81,7 +81,7 @@ class LedgerAuthDialog(QDialog):
|
||||
self.helpmsg.setStyleSheet("QTextEdit { color:black; background-color: lightgray; }")
|
||||
self.helpmsg.setReadOnly(True)
|
||||
vbox.addWidget(self.helpmsg)
|
||||
|
||||
|
||||
self.pinbox = QWidget()
|
||||
pinlayout = QHBoxLayout()
|
||||
self.pinbox.setLayout(pinlayout)
|
||||
@@ -94,7 +94,7 @@ class LedgerAuthDialog(QDialog):
|
||||
pinlayout.addStretch(1)
|
||||
self.pinbox.setVisible(self.cfg['mode'] == 0)
|
||||
vbox.addWidget(self.pinbox)
|
||||
|
||||
|
||||
self.cardbox = QWidget()
|
||||
card = QVBoxLayout()
|
||||
self.cardbox.setLayout(card)
|
||||
@@ -107,7 +107,7 @@ class LedgerAuthDialog(QDialog):
|
||||
self.addrtext.setReadOnly(True)
|
||||
self.addrtext.setMaximumHeight(130)
|
||||
card.addWidget(self.addrtext)
|
||||
|
||||
|
||||
def pin_changed(s):
|
||||
if len(s) < len(self.idxs):
|
||||
i = self.idxs[len(s)]
|
||||
@@ -122,8 +122,8 @@ class LedgerAuthDialog(QDialog):
|
||||
self.addrtext.setHtml(str(text))
|
||||
else:
|
||||
self.addrtext.setHtml(_("Press Enter"))
|
||||
|
||||
pin_changed('')
|
||||
|
||||
pin_changed('')
|
||||
cardpin = QHBoxLayout()
|
||||
cardpin.addWidget(QLabel(_("Enter PIN:")))
|
||||
self.cardtxt = PasswordLineEdit()
|
||||
@@ -136,7 +136,7 @@ class LedgerAuthDialog(QDialog):
|
||||
card.addLayout(cardpin)
|
||||
self.cardbox.setVisible(self.cfg['mode'] == 1)
|
||||
vbox.addWidget(self.cardbox)
|
||||
|
||||
|
||||
self.update_dlg()
|
||||
|
||||
def populate_modes(self):
|
||||
@@ -146,7 +146,7 @@ class LedgerAuthDialog(QDialog):
|
||||
if self.txdata['confirmationType'] > 1:
|
||||
self.modes.addItem(_("Security Card Challenge"))
|
||||
self.modes.blockSignals(False)
|
||||
|
||||
|
||||
def update_dlg(self):
|
||||
self.modes.setCurrentIndex(self.cfg['mode'])
|
||||
self.modebox.setVisible(True)
|
||||
|
||||
@@ -333,7 +333,7 @@ class Ledger_KeyStore(Hardware_KeyStore):
|
||||
# Pad r and s points with 0x00 bytes when the point is small to get valid signature.
|
||||
r_padded = bytes([0x00]) * (32 - len(r)) + r
|
||||
s_padded = bytes([0x00]) * (32 - len(s)) + s
|
||||
|
||||
|
||||
return bytes([27 + 4 + (signature[0] & 0x01)]) + r_padded + s_padded
|
||||
|
||||
@runs_in_hwd_thread
|
||||
|
||||
@@ -330,7 +330,7 @@ class Plugin(RevealerPlugin):
|
||||
|
||||
painter.end()
|
||||
img = bitmap.toImage()
|
||||
if (self.rawnoise == False):
|
||||
if not self.rawnoise:
|
||||
self.make_rawnoise()
|
||||
|
||||
self.make_cypherseed(img, self.rawnoise, False, is_seed)
|
||||
|
||||
Reference in New Issue
Block a user