Browse Source

flake8: enable more mandatory tests

master
SomberNight 3 years ago
parent
commit
01b5e3f8e0
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
  1. 5
      .cirrus.yml
  2. 4
      contrib/android/apkdiff.py
  3. 2
      electrum/coinchooser.py
  4. 1
      electrum/gui/kivy/uix/__init__.py
  5. 4
      electrum/gui/kivy/uix/drawer.py
  6. 4
      electrum/gui/qml/__init__.py
  7. 2
      electrum/gui/qml/qeaddressdetails.py
  8. 16
      electrum/gui/qml/qedaemon.py
  9. 2
      electrum/gui/qml/qeqr.py
  10. 2
      electrum/gui/qml/qetransactionlistmodel.py
  11. 2
      electrum/gui/qt/qrreader/qtmultimedia/validator.py
  12. 2
      electrum/gui/stdio.py
  13. 2
      electrum/lnaddr.py
  14. 6
      electrum/plugins/digitalbitbox/digitalbitbox.py
  15. 2
      electrum/plugins/revealer/qt.py
  16. 184
      electrum/ripemd.py
  17. 4
      electrum/rsakey.py
  18. 2
      electrum/scripts/ln_features.py
  19. 6
      electrum/transaction.py
  20. 6
      electrum/wizard.py

5
.cirrus.yml

@ -149,7 +149,10 @@ task:
matrix: matrix:
- name: Flake8 Mandatory - name: Flake8 Mandatory
env: env:
ELECTRUM_LINTERS: E9,F63,F7,F82,W191 # list of error codes:
# - https://flake8.pycqa.org/en/latest/user/error-codes.html
# - https://pycodestyle.pycqa.org/en/latest/intro.html#error-codes
ELECTRUM_LINTERS: E9,E101,E129,E273,E274,E703,E71,F63,F7,F82,W191,W29
- name: Flake8 Non-Mandatory - name: Flake8 Non-Mandatory
env: env:
ELECTRUM_LINTERS: E,F,W,C90 ELECTRUM_LINTERS: E,F,W,C90

4
contrib/android/apkdiff.py

@ -11,7 +11,7 @@ class ApkDiff:
sourceZip = ZipFile(sourceApk, 'r') sourceZip = ZipFile(sourceApk, 'r')
destinationZip = ZipFile(destinationApk, 'r') destinationZip = ZipFile(destinationApk, 'r')
if self.compareManifests(sourceZip, destinationZip) and self.compareEntries(sourceZip, destinationZip) == True: if self.compareManifests(sourceZip, destinationZip) and self.compareEntries(sourceZip, destinationZip):
print("APKs match!") print("APKs match!")
return True return True
else: else:
@ -50,7 +50,7 @@ class ApkDiff:
sourceEntry = sourceZip.open(sourceEntryInfo, 'r') sourceEntry = sourceZip.open(sourceEntryInfo, 'r')
destinationEntry = destinationZip.open(destinationEntryInfo, 'r') destinationEntry = destinationZip.open(destinationEntryInfo, 'r')
if self.compareFiles(sourceEntry, destinationEntry) != True: if not self.compareFiles(sourceEntry, destinationEntry):
print("APK entry %s does not match %s!" % (sourceEntryInfo.filename, destinationEntryInfo.filename)) print("APK entry %s does not match %s!" % (sourceEntryInfo.filename, destinationEntryInfo.filename))
return False return False

2
electrum/coinchooser.py

@ -482,7 +482,7 @@ COIN_CHOOSERS = {
def get_name(config): def get_name(config):
kind = config.get('coin_chooser') kind = config.get('coin_chooser')
if not kind in COIN_CHOOSERS: if kind not in COIN_CHOOSERS:
kind = 'Privacy' kind = 'Privacy'
return kind return kind

1
electrum/gui/kivy/uix/__init__.py

@ -1 +0,0 @@

4
electrum/gui/kivy/uix/drawer.py

@ -135,7 +135,7 @@ class Drawer(Factory.RelativeLayout):
return return
def on_touch_move(self, touch): def on_touch_move(self, touch):
if not touch.grab_current is self: if touch.grab_current is not self:
return return
self._touch = False self._touch = False
# skip on tablet mode # skip on tablet mode
@ -175,7 +175,7 @@ class Drawer(Factory.RelativeLayout):
return return
def on_touch_up(self, touch): def on_touch_up(self, touch):
if not touch.grab_current is self: if touch.grab_current is not self:
return return
self._triigger_gc() self._triigger_gc()

4
electrum/gui/qml/__init__.py

@ -52,9 +52,9 @@ class ElectrumGui(Logger):
if hasattr(QGuiApplication, 'setDesktopFileName'): if hasattr(QGuiApplication, 'setDesktopFileName'):
QGuiApplication.setDesktopFileName('electrum.desktop') QGuiApplication.setDesktopFileName('electrum.desktop')
if hasattr(QtCore.Qt, "AA_EnableHighDpiScaling"): if hasattr(QtCore.Qt, "AA_EnableHighDpiScaling"):
QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling); QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling)
if not "QT_QUICK_CONTROLS_STYLE" in os.environ: if "QT_QUICK_CONTROLS_STYLE" not in os.environ:
os.environ["QT_QUICK_CONTROLS_STYLE"] = "Material" os.environ["QT_QUICK_CONTROLS_STYLE"] = "Material"
self.gui_thread = threading.current_thread() self.gui_thread = threading.current_thread()

2
electrum/gui/qml/qeaddressdetails.py

@ -125,5 +125,5 @@ class QEAddressDetails(QObject):
if self._wallet.derivationPrefix: if self._wallet.derivationPrefix:
self._derivationPath = self._derivationPath.replace('m', self._wallet.derivationPrefix) self._derivationPath = self._derivationPath.replace('m', self._wallet.derivationPrefix)
self._numtx = self._wallet.wallet.adb.get_address_history_len(self._address) self._numtx = self._wallet.wallet.adb.get_address_history_len(self._address)
assert(self._numtx == self.historyModel.rowCount(0)) assert self._numtx == self.historyModel.rowCount(0)
self.detailsChanged.emit() self.detailsChanged.emit()

16
electrum/gui/qml/qedaemon.py

@ -44,25 +44,25 @@ class QEWalletListModel(QAbstractListModel):
if role_name == 'path': if role_name == 'path':
return wallet_path return wallet_path
if role_name == 'active': if role_name == 'active':
return wallet != None return wallet is not None
def add_wallet(self, wallet_path = None, wallet: Abstract_Wallet = None): def add_wallet(self, wallet_path = None, wallet: Abstract_Wallet = None):
if wallet_path == None and wallet == None: if wallet_path is None and wallet is None:
return return
# only add wallet instance if instance not yet in model # only add wallet instance if instance not yet in model
if wallet: if wallet:
for name,path,w in self.wallets: for name,path,w in self.wallets:
if w == wallet: if w == wallet:
return return
self.beginInsertRows(QModelIndex(), len(self.wallets), len(self.wallets)); self.beginInsertRows(QModelIndex(), len(self.wallets), len(self.wallets))
if wallet == None: if wallet is None:
wallet_name = os.path.basename(wallet_path) wallet_name = os.path.basename(wallet_path)
else: else:
wallet_name = wallet.basename() wallet_name = wallet.basename()
wallet_path = standardize_path(wallet_path) wallet_path = standardize_path(wallet_path)
item = (wallet_name, wallet_path, wallet) item = (wallet_name, wallet_path, wallet)
self.wallets.append(item); self.wallets.append(item)
self.endInsertRows(); self.endInsertRows()
def remove_wallet(self, path): def remove_wallet(self, path):
i = 0 i = 0
@ -148,7 +148,7 @@ class QEDaemon(AuthMixin, QObject):
@pyqtSlot(str) @pyqtSlot(str)
@pyqtSlot(str, str) @pyqtSlot(str, str)
def load_wallet(self, path=None, password=None): def load_wallet(self, path=None, password=None):
if path == None: if path is None:
self._path = self.daemon.config.get('wallet_path') # command line -w option self._path = self.daemon.config.get('wallet_path') # command line -w option
if self._path is None: if self._path is None:
self._path = self.daemon.config.get('gui_last_wallet') self._path = self.daemon.config.get('gui_last_wallet')
@ -175,7 +175,7 @@ class QEDaemon(AuthMixin, QObject):
try: try:
wallet = self.daemon.load_wallet(self._path, password) wallet = self.daemon.load_wallet(self._path, password)
if wallet != None: if wallet is not None:
self._current_wallet = QEWallet.getInstanceFor(wallet) self._current_wallet = QEWallet.getInstanceFor(wallet)
if not wallet_already_open: if not wallet_already_open:
self._loaded_wallets.add_wallet(wallet_path=self._path, wallet=wallet) self._loaded_wallets.add_wallet(wallet_path=self._path, wallet=wallet)

2
electrum/gui/qml/qeqr.py

@ -37,7 +37,7 @@ class QEQRParser(QObject):
self._logger.warning("Already processing an image. Check 'busy' property before calling scanImage") self._logger.warning("Already processing an image. Check 'busy' property before calling scanImage")
return return
if image == None: if image is None:
self._logger.warning("No image to decode") self._logger.warning("No image to decode")
return return

2
electrum/gui/qml/qetransactionlistmodel.py

@ -59,7 +59,7 @@ class QETransactionListModel(QAbstractListModel):
item['key'] = item['txid'] if 'txid' in item else item['payment_hash'] item['key'] = item['txid'] if 'txid' in item else item['payment_hash']
if not 'lightning' in item: if 'lightning' not in item:
item['lightning'] = False item['lightning'] = False
if item['lightning']: if item['lightning']:

2
electrum/gui/qt/qrreader/qtmultimedia/validator.py

@ -79,7 +79,7 @@ class QrReaderValidatorCounting(AbstractQrReaderValidator):
for result in results: for result in results:
# Increment the detection count # Increment the detection count
if not result in self.result_counts: if result not in self.result_counts:
self.result_counts[result] = 0 self.result_counts[result] = 0
self.result_counts[result] += 1 self.result_counts[result] += 1

2
electrum/gui/stdio.py

@ -138,7 +138,7 @@ class ElectrumGui(BaseElectrumGui, EventListener):
else: else:
msg = _("Not connected") msg = _("Not connected")
return(msg) return msg
def print_contacts(self): def print_contacts(self):

2
electrum/lnaddr.py

@ -246,7 +246,7 @@ def lnencode(addr: 'LnAddr', privkey) -> str:
# both. # both.
if 'd' in tags_set and 'h' in tags_set: if 'd' in tags_set and 'h' in tags_set:
raise ValueError("Cannot include both 'd' and 'h'") raise ValueError("Cannot include both 'd' and 'h'")
if not 'd' in tags_set and not 'h' in tags_set: if 'd' not in tags_set and 'h' not in tags_set:
raise ValueError("Must include either 'd' or 'h'") raise ValueError("Must include either 'd' or 'h'")
# We actually sign the hrp, then data (padded to 8 bits with zeroes). # We actually sign the hrp, then data (padded to 8 bits with zeroes).

6
electrum/plugins/digitalbitbox/digitalbitbox.py

@ -350,8 +350,8 @@ class DigitalBitbox_Client(HardwareClientBase):
HWW_CID = 0xFF000000 HWW_CID = 0xFF000000
HWW_CMD = 0x80 + 0x40 + 0x01 HWW_CMD = 0x80 + 0x40 + 0x01
data_len = len(data) data_len = len(data)
seq = 0; seq = 0
idx = 0; idx = 0
write = [] write = []
while idx < data_len: while idx < data_len:
if idx == 0: if idx == 0:
@ -373,7 +373,7 @@ class DigitalBitbox_Client(HardwareClientBase):
cmd = read[4] cmd = read[4]
data_len = read[5] * 256 + read[6] data_len = read[5] * 256 + read[6]
data = read[7:] data = read[7:]
idx = len(read) - 7; idx = len(read) - 7
while idx < data_len: while idx < data_len:
# CONT response # CONT response
read = bytearray(self.dbb_hid.read(self.usbReportSize)) read = bytearray(self.dbb_hid.read(self.usbReportSize))

2
electrum/plugins/revealer/qt.py

@ -330,7 +330,7 @@ class Plugin(RevealerPlugin):
painter.end() painter.end()
img = bitmap.toImage() img = bitmap.toImage()
if (self.rawnoise == False): if not self.rawnoise:
self.make_rawnoise() self.make_rawnoise()
self.make_cypherseed(img, self.rawnoise, False, is_seed) self.make_cypherseed(img, self.rawnoise, False, is_seed)

184
electrum/ripemd.py

@ -159,96 +159,96 @@ def RMD160Transform(state, block): #uint32 state[5], uchar block[64]
e = state[4] e = state[4]
#/* Round 1 */ #/* Round 1 */
a, c = R(a, b, c, d, e, F0, K0, 11, 0, x); a, c = R(a, b, c, d, e, F0, K0, 11, 0, x)
e, b = R(e, a, b, c, d, F0, K0, 14, 1, x); e, b = R(e, a, b, c, d, F0, K0, 14, 1, x)
d, a = R(d, e, a, b, c, F0, K0, 15, 2, x); d, a = R(d, e, a, b, c, F0, K0, 15, 2, x)
c, e = R(c, d, e, a, b, F0, K0, 12, 3, x); c, e = R(c, d, e, a, b, F0, K0, 12, 3, x)
b, d = R(b, c, d, e, a, F0, K0, 5, 4, x); b, d = R(b, c, d, e, a, F0, K0, 5, 4, x)
a, c = R(a, b, c, d, e, F0, K0, 8, 5, x); a, c = R(a, b, c, d, e, F0, K0, 8, 5, x)
e, b = R(e, a, b, c, d, F0, K0, 7, 6, x); e, b = R(e, a, b, c, d, F0, K0, 7, 6, x)
d, a = R(d, e, a, b, c, F0, K0, 9, 7, x); d, a = R(d, e, a, b, c, F0, K0, 9, 7, x)
c, e = R(c, d, e, a, b, F0, K0, 11, 8, x); c, e = R(c, d, e, a, b, F0, K0, 11, 8, x)
b, d = R(b, c, d, e, a, F0, K0, 13, 9, x); b, d = R(b, c, d, e, a, F0, K0, 13, 9, x)
a, c = R(a, b, c, d, e, F0, K0, 14, 10, x); a, c = R(a, b, c, d, e, F0, K0, 14, 10, x)
e, b = R(e, a, b, c, d, F0, K0, 15, 11, x); e, b = R(e, a, b, c, d, F0, K0, 15, 11, x)
d, a = R(d, e, a, b, c, F0, K0, 6, 12, x); d, a = R(d, e, a, b, c, F0, K0, 6, 12, x)
c, e = R(c, d, e, a, b, F0, K0, 7, 13, x); c, e = R(c, d, e, a, b, F0, K0, 7, 13, x)
b, d = R(b, c, d, e, a, F0, K0, 9, 14, x); b, d = R(b, c, d, e, a, F0, K0, 9, 14, x)
a, c = R(a, b, c, d, e, F0, K0, 8, 15, x); #/* #15 */ a, c = R(a, b, c, d, e, F0, K0, 8, 15, x) #/* #15 */
#/* Round 2 */ #/* Round 2 */
e, b = R(e, a, b, c, d, F1, K1, 7, 7, x); e, b = R(e, a, b, c, d, F1, K1, 7, 7, x)
d, a = R(d, e, a, b, c, F1, K1, 6, 4, x); d, a = R(d, e, a, b, c, F1, K1, 6, 4, x)
c, e = R(c, d, e, a, b, F1, K1, 8, 13, x); c, e = R(c, d, e, a, b, F1, K1, 8, 13, x)
b, d = R(b, c, d, e, a, F1, K1, 13, 1, x); b, d = R(b, c, d, e, a, F1, K1, 13, 1, x)
a, c = R(a, b, c, d, e, F1, K1, 11, 10, x); a, c = R(a, b, c, d, e, F1, K1, 11, 10, x)
e, b = R(e, a, b, c, d, F1, K1, 9, 6, x); e, b = R(e, a, b, c, d, F1, K1, 9, 6, x)
d, a = R(d, e, a, b, c, F1, K1, 7, 15, x); d, a = R(d, e, a, b, c, F1, K1, 7, 15, x)
c, e = R(c, d, e, a, b, F1, K1, 15, 3, x); c, e = R(c, d, e, a, b, F1, K1, 15, 3, x)
b, d = R(b, c, d, e, a, F1, K1, 7, 12, x); b, d = R(b, c, d, e, a, F1, K1, 7, 12, x)
a, c = R(a, b, c, d, e, F1, K1, 12, 0, x); a, c = R(a, b, c, d, e, F1, K1, 12, 0, x)
e, b = R(e, a, b, c, d, F1, K1, 15, 9, x); e, b = R(e, a, b, c, d, F1, K1, 15, 9, x)
d, a = R(d, e, a, b, c, F1, K1, 9, 5, x); d, a = R(d, e, a, b, c, F1, K1, 9, 5, x)
c, e = R(c, d, e, a, b, F1, K1, 11, 2, x); c, e = R(c, d, e, a, b, F1, K1, 11, 2, x)
b, d = R(b, c, d, e, a, F1, K1, 7, 14, x); b, d = R(b, c, d, e, a, F1, K1, 7, 14, x)
a, c = R(a, b, c, d, e, F1, K1, 13, 11, x); a, c = R(a, b, c, d, e, F1, K1, 13, 11, x)
e, b = R(e, a, b, c, d, F1, K1, 12, 8, x); #/* #31 */ e, b = R(e, a, b, c, d, F1, K1, 12, 8, x) #/* #31 */
#/* Round 3 */ #/* Round 3 */
d, a = R(d, e, a, b, c, F2, K2, 11, 3, x); d, a = R(d, e, a, b, c, F2, K2, 11, 3, x)
c, e = R(c, d, e, a, b, F2, K2, 13, 10, x); c, e = R(c, d, e, a, b, F2, K2, 13, 10, x)
b, d = R(b, c, d, e, a, F2, K2, 6, 14, x); b, d = R(b, c, d, e, a, F2, K2, 6, 14, x)
a, c = R(a, b, c, d, e, F2, K2, 7, 4, x); a, c = R(a, b, c, d, e, F2, K2, 7, 4, x)
e, b = R(e, a, b, c, d, F2, K2, 14, 9, x); e, b = R(e, a, b, c, d, F2, K2, 14, 9, x)
d, a = R(d, e, a, b, c, F2, K2, 9, 15, x); d, a = R(d, e, a, b, c, F2, K2, 9, 15, x)
c, e = R(c, d, e, a, b, F2, K2, 13, 8, x); c, e = R(c, d, e, a, b, F2, K2, 13, 8, x)
b, d = R(b, c, d, e, a, F2, K2, 15, 1, x); b, d = R(b, c, d, e, a, F2, K2, 15, 1, x)
a, c = R(a, b, c, d, e, F2, K2, 14, 2, x); a, c = R(a, b, c, d, e, F2, K2, 14, 2, x)
e, b = R(e, a, b, c, d, F2, K2, 8, 7, x); e, b = R(e, a, b, c, d, F2, K2, 8, 7, x)
d, a = R(d, e, a, b, c, F2, K2, 13, 0, x); d, a = R(d, e, a, b, c, F2, K2, 13, 0, x)
c, e = R(c, d, e, a, b, F2, K2, 6, 6, x); c, e = R(c, d, e, a, b, F2, K2, 6, 6, x)
b, d = R(b, c, d, e, a, F2, K2, 5, 13, x); b, d = R(b, c, d, e, a, F2, K2, 5, 13, x)
a, c = R(a, b, c, d, e, F2, K2, 12, 11, x); a, c = R(a, b, c, d, e, F2, K2, 12, 11, x)
e, b = R(e, a, b, c, d, F2, K2, 7, 5, x); e, b = R(e, a, b, c, d, F2, K2, 7, 5, x)
d, a = R(d, e, a, b, c, F2, K2, 5, 12, x); #/* #47 */ d, a = R(d, e, a, b, c, F2, K2, 5, 12, x) #/* #47 */
#/* Round 4 */ #/* Round 4 */
c, e = R(c, d, e, a, b, F3, K3, 11, 1, x); c, e = R(c, d, e, a, b, F3, K3, 11, 1, x)
b, d = R(b, c, d, e, a, F3, K3, 12, 9, x); b, d = R(b, c, d, e, a, F3, K3, 12, 9, x)
a, c = R(a, b, c, d, e, F3, K3, 14, 11, x); a, c = R(a, b, c, d, e, F3, K3, 14, 11, x)
e, b = R(e, a, b, c, d, F3, K3, 15, 10, x); e, b = R(e, a, b, c, d, F3, K3, 15, 10, x)
d, a = R(d, e, a, b, c, F3, K3, 14, 0, x); d, a = R(d, e, a, b, c, F3, K3, 14, 0, x)
c, e = R(c, d, e, a, b, F3, K3, 15, 8, x); c, e = R(c, d, e, a, b, F3, K3, 15, 8, x)
b, d = R(b, c, d, e, a, F3, K3, 9, 12, x); b, d = R(b, c, d, e, a, F3, K3, 9, 12, x)
a, c = R(a, b, c, d, e, F3, K3, 8, 4, x); a, c = R(a, b, c, d, e, F3, K3, 8, 4, x)
e, b = R(e, a, b, c, d, F3, K3, 9, 13, x); e, b = R(e, a, b, c, d, F3, K3, 9, 13, x)
d, a = R(d, e, a, b, c, F3, K3, 14, 3, x); d, a = R(d, e, a, b, c, F3, K3, 14, 3, x)
c, e = R(c, d, e, a, b, F3, K3, 5, 7, x); c, e = R(c, d, e, a, b, F3, K3, 5, 7, x)
b, d = R(b, c, d, e, a, F3, K3, 6, 15, x); b, d = R(b, c, d, e, a, F3, K3, 6, 15, x)
a, c = R(a, b, c, d, e, F3, K3, 8, 14, x); a, c = R(a, b, c, d, e, F3, K3, 8, 14, x)
e, b = R(e, a, b, c, d, F3, K3, 6, 5, x); e, b = R(e, a, b, c, d, F3, K3, 6, 5, x)
d, a = R(d, e, a, b, c, F3, K3, 5, 6, x); d, a = R(d, e, a, b, c, F3, K3, 5, 6, x)
c, e = R(c, d, e, a, b, F3, K3, 12, 2, x); #/* #63 */ c, e = R(c, d, e, a, b, F3, K3, 12, 2, x) #/* #63 */
#/* Round 5 */ #/* Round 5 */
b, d = R(b, c, d, e, a, F4, K4, 9, 4, x); b, d = R(b, c, d, e, a, F4, K4, 9, 4, x)
a, c = R(a, b, c, d, e, F4, K4, 15, 0, x); a, c = R(a, b, c, d, e, F4, K4, 15, 0, x)
e, b = R(e, a, b, c, d, F4, K4, 5, 5, x); e, b = R(e, a, b, c, d, F4, K4, 5, 5, x)
d, a = R(d, e, a, b, c, F4, K4, 11, 9, x); d, a = R(d, e, a, b, c, F4, K4, 11, 9, x)
c, e = R(c, d, e, a, b, F4, K4, 6, 7, x); c, e = R(c, d, e, a, b, F4, K4, 6, 7, x)
b, d = R(b, c, d, e, a, F4, K4, 8, 12, x); b, d = R(b, c, d, e, a, F4, K4, 8, 12, x)
a, c = R(a, b, c, d, e, F4, K4, 13, 2, x); a, c = R(a, b, c, d, e, F4, K4, 13, 2, x)
e, b = R(e, a, b, c, d, F4, K4, 12, 10, x); e, b = R(e, a, b, c, d, F4, K4, 12, 10, x)
d, a = R(d, e, a, b, c, F4, K4, 5, 14, x); d, a = R(d, e, a, b, c, F4, K4, 5, 14, x)
c, e = R(c, d, e, a, b, F4, K4, 12, 1, x); c, e = R(c, d, e, a, b, F4, K4, 12, 1, x)
b, d = R(b, c, d, e, a, F4, K4, 13, 3, x); b, d = R(b, c, d, e, a, F4, K4, 13, 3, x)
a, c = R(a, b, c, d, e, F4, K4, 14, 8, x); a, c = R(a, b, c, d, e, F4, K4, 14, 8, x)
e, b = R(e, a, b, c, d, F4, K4, 11, 11, x); e, b = R(e, a, b, c, d, F4, K4, 11, 11, x)
d, a = R(d, e, a, b, c, F4, K4, 8, 6, x); d, a = R(d, e, a, b, c, F4, K4, 8, 6, x)
c, e = R(c, d, e, a, b, F4, K4, 5, 15, x); c, e = R(c, d, e, a, b, F4, K4, 5, 15, x)
b, d = R(b, c, d, e, a, F4, K4, 6, 13, x); #/* #79 */ b, d = R(b, c, d, e, a, F4, K4, 6, 13, x) #/* #79 */
aa = a; aa = a
bb = b; bb = b
cc = c; cc = c
dd = d; dd = d
ee = e; ee = e
a = state[0] a = state[0]
b = state[1] b = state[1]
@ -342,12 +342,12 @@ def RMD160Transform(state, block): #uint32 state[5], uchar block[64]
c, e = R(c, d, e, a, b, F0, KK4, 11, 9, x) c, e = R(c, d, e, a, b, F0, KK4, 11, 9, x)
b, d = R(b, c, d, e, a, F0, KK4, 11, 11, x) #/* #79 */ b, d = R(b, c, d, e, a, F0, KK4, 11, 11, x) #/* #79 */
t = (state[1] + cc + d) % 0x100000000; t = (state[1] + cc + d) % 0x100000000
state[1] = (state[2] + dd + e) % 0x100000000; state[1] = (state[2] + dd + e) % 0x100000000
state[2] = (state[3] + ee + a) % 0x100000000; state[2] = (state[3] + ee + a) % 0x100000000
state[3] = (state[4] + aa + b) % 0x100000000; state[3] = (state[4] + aa + b) % 0x100000000
state[4] = (state[0] + bb + c) % 0x100000000; state[4] = (state[0] + bb + c) % 0x100000000
state[0] = t % 0x100000000; state[0] = t % 0x100000000
pass pass

4
electrum/rsakey.py

@ -49,11 +49,11 @@ def SHA1(x):
# Check that os.urandom works # Check that os.urandom works
import zlib import zlib
length = len(zlib.compress(os.urandom(1000))) length = len(zlib.compress(os.urandom(1000)))
assert(length > 900) assert length > 900
def getRandomBytes(howMany): def getRandomBytes(howMany):
b = bytearray(os.urandom(howMany)) b = bytearray(os.urandom(howMany))
assert(len(b) == howMany) assert len(b) == howMany
return b return b
prngName = "os.urandom" prngName = "os.urandom"

2
electrum/scripts/ln_features.py

@ -69,7 +69,7 @@ async def worker(work_queue: asyncio.Queue, results_queue: asyncio.Queue, flag):
# only check non-onion addresses # only check non-onion addresses
addr = None addr = None
for a in work['addrs']: for a in work['addrs']:
if not "onion" in a[0]: if "onion" not in a[0]:
addr = a addr = a
if not addr: if not addr:
await results_queue.put(None) await results_queue.put(None)

6
electrum/transaction.py

@ -1935,13 +1935,13 @@ class PartialTransaction(Transaction):
hashPrevouts = bip143_shared_txdigest_fields.hashPrevouts hashPrevouts = bip143_shared_txdigest_fields.hashPrevouts
else: else:
hashPrevouts = '00' * 32 hashPrevouts = '00' * 32
if (not(sighash & Sighash.ANYONECANPAY) and (sighash & 0x1f) != Sighash.SINGLE and (sighash & 0x1f) != Sighash.NONE): if not (sighash & Sighash.ANYONECANPAY) and (sighash & 0x1f) != Sighash.SINGLE and (sighash & 0x1f) != Sighash.NONE:
hashSequence = bip143_shared_txdigest_fields.hashSequence hashSequence = bip143_shared_txdigest_fields.hashSequence
else: else:
hashSequence = '00' * 32 hashSequence = '00' * 32
if ((sighash & 0x1f) != Sighash.SINGLE and (sighash & 0x1f) != Sighash.NONE): if (sighash & 0x1f) != Sighash.SINGLE and (sighash & 0x1f) != Sighash.NONE:
hashOutputs = bip143_shared_txdigest_fields.hashOutputs hashOutputs = bip143_shared_txdigest_fields.hashOutputs
elif ((sighash & 0x1f) == Sighash.SINGLE and txin_index < len(outputs)): elif (sighash & 0x1f) == Sighash.SINGLE and txin_index < len(outputs):
hashOutputs = bh2u(sha256d(outputs[txin_index].serialize_to_network())) hashOutputs = bh2u(sha256d(outputs[txin_index].serialize_to_network()))
else: else:
hashOutputs = '00' * 32 hashOutputs = '00' * 32

6
electrum/wizard.py

@ -61,7 +61,7 @@ class AbstractWizard:
else: else:
self._logger.error(f'accept handler for view {view} not callable') self._logger.error(f'accept handler for view {view} not callable')
if not 'next' in nav: if 'next' not in nav:
# finished # finished
self.finished(wizard_data) self.finished(wizard_data)
return (None, wizard_data, {}) return (None, wizard_data, {})
@ -107,7 +107,7 @@ class AbstractWizard:
nav = self.navmap[view] nav = self.navmap[view]
if not 'last' in nav: if 'last' not in nav:
return False return False
lastnav = nav['last'] lastnav = nav['last']
@ -219,7 +219,7 @@ class NewWalletWizard(AbstractWizard):
storage = WalletStorage(path) storage = WalletStorage(path)
k = None k = None
if not 'keystore_type' in data: if 'keystore_type' not in data:
assert data['wallet_type'] == 'imported' assert data['wallet_type'] == 'imported'
addresses = {} addresses = {}
if 'private_key_list' in data: if 'private_key_list' in data:

Loading…
Cancel
Save