mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-27 00:28:10 +00:00
src: fix flake8 style
This commit is contained in:
parent
8a8450d6be
commit
16bc1c6cb6
2
.flake8
2
.flake8
@ -11,6 +11,8 @@ ignore =
|
||||
# E501: line too long
|
||||
E501,
|
||||
# F403: star import used, unable to detect undefined names
|
||||
E741,
|
||||
# E741 ambiguous variable name
|
||||
F403,
|
||||
# F405: name may be undefined, or defined from star imports
|
||||
F405
|
||||
|
@ -415,7 +415,7 @@ class ConfirmContent(ui.Widget):
|
||||
name = knownapps.knownapps[app_id]
|
||||
try:
|
||||
icon = res.load('apps/fido_u2f/res/u2f_%s.toif' % name.lower().replace(' ', '_'))
|
||||
except:
|
||||
except FileNotFoundError:
|
||||
icon = res.load('apps/fido_u2f/res/u2f_generic.toif')
|
||||
else:
|
||||
name = '%s...%s' % (ubinascii.hexlify(app_id[:4]), ubinascii.hexlify(app_id[-4:]))
|
||||
|
@ -23,4 +23,5 @@ async def _show_entropy(ctx):
|
||||
await require_confirm(ctx, Text(
|
||||
'Confirm entropy', ui.ICON_RESET,
|
||||
ui.BOLD, 'Do you really want', 'to send entropy?',
|
||||
ui.NORMAL, 'Continue only if you', 'know what you are doing!'),code=ProtectCall)
|
||||
ui.NORMAL, 'Continue only if you', 'know what you are doing!'),
|
||||
code=ProtectCall)
|
||||
|
@ -131,4 +131,3 @@ def sanitize_tx_output(tx: TransactionType) -> TxOutputType:
|
||||
|
||||
def sanitize_tx_binoutput(tx: TransactionType) -> TxOutputBinType:
|
||||
return tx.bin_outputs[0]
|
||||
|
||||
|
@ -4,6 +4,7 @@ from trezor.messages import InputScriptType, FailureType
|
||||
|
||||
from apps.wallet.sign_tx.writers import *
|
||||
|
||||
|
||||
class Bip143Error(ValueError):
|
||||
pass
|
||||
|
||||
|
@ -414,10 +414,10 @@ def output_is_change(o: TxOutputType, wallet_path: list, segwit_in: int) -> bool
|
||||
# segwit inputs paid. this is to prevent user being tricked into
|
||||
# creating ANYONECANSPEND outputs before full segwit activation.
|
||||
return False
|
||||
return (address_n is not None and wallet_path is not None
|
||||
and wallet_path == address_n[:-_BIP32_WALLET_DEPTH]
|
||||
and address_n[-2] == _BIP32_CHANGE_CHAIN
|
||||
and address_n[-1] <= _BIP32_MAX_LAST_ELEMENT)
|
||||
return (address_n is not None and wallet_path is not None and
|
||||
wallet_path == address_n[:-_BIP32_WALLET_DEPTH] and
|
||||
address_n[-2] == _BIP32_CHANGE_CHAIN and
|
||||
address_n[-1] <= _BIP32_MAX_LAST_ELEMENT)
|
||||
|
||||
|
||||
# Tx Inputs
|
||||
|
@ -38,10 +38,10 @@ class TxWeightCalculator:
|
||||
def __init__(self, inputs_count: int, outputs_count: int):
|
||||
self.inputs_count = inputs_count
|
||||
self.counter = 4 * (
|
||||
_TXSIZE_HEADER
|
||||
+ _TXSIZE_FOOTER
|
||||
+ self.ser_length_size(inputs_count)
|
||||
+ self.ser_length_size(outputs_count))
|
||||
_TXSIZE_HEADER +
|
||||
_TXSIZE_FOOTER +
|
||||
self.ser_length_size(inputs_count) +
|
||||
self.ser_length_size(outputs_count))
|
||||
self.segwit = False
|
||||
|
||||
def add_witness_header(self):
|
||||
@ -54,25 +54,25 @@ class TxWeightCalculator:
|
||||
|
||||
if i.multisig:
|
||||
multisig_script_size = (
|
||||
_TXSIZE_MULTISIGSCRIPT
|
||||
+ i.multisig.pubkeys_count * (1 + _TXSIZE_PUBKEY))
|
||||
_TXSIZE_MULTISIGSCRIPT +
|
||||
i.multisig.pubkeys_count * (1 + _TXSIZE_PUBKEY))
|
||||
input_script_size = (
|
||||
1 # the OP_FALSE bug in multisig
|
||||
+ i.multisig.m * (1 + _TXSIZE_SIGNATURE)
|
||||
+ self.op_push_size(multisig_script_size)
|
||||
+ multisig_script_size)
|
||||
1 + # the OP_FALSE bug in multisig
|
||||
i.multisig.m * (1 + _TXSIZE_SIGNATURE) +
|
||||
self.op_push_size(multisig_script_size) +
|
||||
multisig_script_size)
|
||||
else:
|
||||
input_script_size = 1 + _TXSIZE_SIGNATURE + 1 + _TXSIZE_PUBKEY
|
||||
|
||||
self.counter += 4 * _TXSIZE_INPUT
|
||||
|
||||
if (i.script_type == InputScriptType.SPENDADDRESS
|
||||
or i.script_type == InputScriptType.SPENDMULTISIG):
|
||||
if (i.script_type == InputScriptType.SPENDADDRESS or
|
||||
i.script_type == InputScriptType.SPENDMULTISIG):
|
||||
input_script_size += self.ser_length_size(input_script_size)
|
||||
self.counter += 4 * input_script_size
|
||||
|
||||
elif (i.script_type == InputScriptType.SPENDWITNESS
|
||||
or i.script_type == InputScriptType.SPENDP2SHWITNESS):
|
||||
elif (i.script_type == InputScriptType.SPENDWITNESS or
|
||||
i.script_type == InputScriptType.SPENDP2SHWITNESS):
|
||||
self.add_witness_header()
|
||||
if i.script_type == InputScriptType.SPENDP2SHWITNESS:
|
||||
if i.multisig:
|
||||
|
@ -285,7 +285,7 @@ class wait(Syscall):
|
||||
def __iter__(self):
|
||||
try:
|
||||
return (yield self)
|
||||
except:
|
||||
except Exception:
|
||||
# exception was raised on the waiting task externally with
|
||||
# close() or throw(), kill the children tasks and re-raise
|
||||
self.exit()
|
||||
|
Loading…
Reference in New Issue
Block a user