mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-28 09:08:07 +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: line too long
|
||||||
E501,
|
E501,
|
||||||
# F403: star import used, unable to detect undefined names
|
# F403: star import used, unable to detect undefined names
|
||||||
|
E741,
|
||||||
|
# E741 ambiguous variable name
|
||||||
F403,
|
F403,
|
||||||
# F405: name may be undefined, or defined from star imports
|
# F405: name may be undefined, or defined from star imports
|
||||||
F405
|
F405
|
||||||
|
@ -415,7 +415,7 @@ class ConfirmContent(ui.Widget):
|
|||||||
name = knownapps.knownapps[app_id]
|
name = knownapps.knownapps[app_id]
|
||||||
try:
|
try:
|
||||||
icon = res.load('apps/fido_u2f/res/u2f_%s.toif' % name.lower().replace(' ', '_'))
|
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')
|
icon = res.load('apps/fido_u2f/res/u2f_generic.toif')
|
||||||
else:
|
else:
|
||||||
name = '%s...%s' % (ubinascii.hexlify(app_id[:4]), ubinascii.hexlify(app_id[-4:]))
|
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(
|
await require_confirm(ctx, Text(
|
||||||
'Confirm entropy', ui.ICON_RESET,
|
'Confirm entropy', ui.ICON_RESET,
|
||||||
ui.BOLD, 'Do you really want', 'to send entropy?',
|
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:
|
def sanitize_tx_binoutput(tx: TransactionType) -> TxOutputBinType:
|
||||||
return tx.bin_outputs[0]
|
return tx.bin_outputs[0]
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ from trezor.messages import InputScriptType, FailureType
|
|||||||
|
|
||||||
from apps.wallet.sign_tx.writers import *
|
from apps.wallet.sign_tx.writers import *
|
||||||
|
|
||||||
|
|
||||||
class Bip143Error(ValueError):
|
class Bip143Error(ValueError):
|
||||||
pass
|
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
|
# segwit inputs paid. this is to prevent user being tricked into
|
||||||
# creating ANYONECANSPEND outputs before full segwit activation.
|
# creating ANYONECANSPEND outputs before full segwit activation.
|
||||||
return False
|
return False
|
||||||
return (address_n is not None and wallet_path is not None
|
return (address_n is not None and wallet_path is not None and
|
||||||
and wallet_path == address_n[:-_BIP32_WALLET_DEPTH]
|
wallet_path == address_n[:-_BIP32_WALLET_DEPTH] and
|
||||||
and address_n[-2] == _BIP32_CHANGE_CHAIN
|
address_n[-2] == _BIP32_CHANGE_CHAIN and
|
||||||
and address_n[-1] <= _BIP32_MAX_LAST_ELEMENT)
|
address_n[-1] <= _BIP32_MAX_LAST_ELEMENT)
|
||||||
|
|
||||||
|
|
||||||
# Tx Inputs
|
# Tx Inputs
|
||||||
|
@ -38,10 +38,10 @@ class TxWeightCalculator:
|
|||||||
def __init__(self, inputs_count: int, outputs_count: int):
|
def __init__(self, inputs_count: int, outputs_count: int):
|
||||||
self.inputs_count = inputs_count
|
self.inputs_count = inputs_count
|
||||||
self.counter = 4 * (
|
self.counter = 4 * (
|
||||||
_TXSIZE_HEADER
|
_TXSIZE_HEADER +
|
||||||
+ _TXSIZE_FOOTER
|
_TXSIZE_FOOTER +
|
||||||
+ self.ser_length_size(inputs_count)
|
self.ser_length_size(inputs_count) +
|
||||||
+ self.ser_length_size(outputs_count))
|
self.ser_length_size(outputs_count))
|
||||||
self.segwit = False
|
self.segwit = False
|
||||||
|
|
||||||
def add_witness_header(self):
|
def add_witness_header(self):
|
||||||
@ -54,25 +54,25 @@ class TxWeightCalculator:
|
|||||||
|
|
||||||
if i.multisig:
|
if i.multisig:
|
||||||
multisig_script_size = (
|
multisig_script_size = (
|
||||||
_TXSIZE_MULTISIGSCRIPT
|
_TXSIZE_MULTISIGSCRIPT +
|
||||||
+ i.multisig.pubkeys_count * (1 + _TXSIZE_PUBKEY))
|
i.multisig.pubkeys_count * (1 + _TXSIZE_PUBKEY))
|
||||||
input_script_size = (
|
input_script_size = (
|
||||||
1 # the OP_FALSE bug in multisig
|
1 + # the OP_FALSE bug in multisig
|
||||||
+ i.multisig.m * (1 + _TXSIZE_SIGNATURE)
|
i.multisig.m * (1 + _TXSIZE_SIGNATURE) +
|
||||||
+ self.op_push_size(multisig_script_size)
|
self.op_push_size(multisig_script_size) +
|
||||||
+ multisig_script_size)
|
multisig_script_size)
|
||||||
else:
|
else:
|
||||||
input_script_size = 1 + _TXSIZE_SIGNATURE + 1 + _TXSIZE_PUBKEY
|
input_script_size = 1 + _TXSIZE_SIGNATURE + 1 + _TXSIZE_PUBKEY
|
||||||
|
|
||||||
self.counter += 4 * _TXSIZE_INPUT
|
self.counter += 4 * _TXSIZE_INPUT
|
||||||
|
|
||||||
if (i.script_type == InputScriptType.SPENDADDRESS
|
if (i.script_type == InputScriptType.SPENDADDRESS or
|
||||||
or i.script_type == InputScriptType.SPENDMULTISIG):
|
i.script_type == InputScriptType.SPENDMULTISIG):
|
||||||
input_script_size += self.ser_length_size(input_script_size)
|
input_script_size += self.ser_length_size(input_script_size)
|
||||||
self.counter += 4 * input_script_size
|
self.counter += 4 * input_script_size
|
||||||
|
|
||||||
elif (i.script_type == InputScriptType.SPENDWITNESS
|
elif (i.script_type == InputScriptType.SPENDWITNESS or
|
||||||
or i.script_type == InputScriptType.SPENDP2SHWITNESS):
|
i.script_type == InputScriptType.SPENDP2SHWITNESS):
|
||||||
self.add_witness_header()
|
self.add_witness_header()
|
||||||
if i.script_type == InputScriptType.SPENDP2SHWITNESS:
|
if i.script_type == InputScriptType.SPENDP2SHWITNESS:
|
||||||
if i.multisig:
|
if i.multisig:
|
||||||
|
@ -68,10 +68,10 @@ def bech32_decode(bech):
|
|||||||
pos = bech.rfind('1')
|
pos = bech.rfind('1')
|
||||||
if pos < 1 or pos + 7 > len(bech) or len(bech) > 90:
|
if pos < 1 or pos + 7 > len(bech) or len(bech) > 90:
|
||||||
return (None, None)
|
return (None, None)
|
||||||
if not all(x in CHARSET for x in bech[pos+1:]):
|
if not all(x in CHARSET for x in bech[pos + 1:]):
|
||||||
return (None, None)
|
return (None, None)
|
||||||
hrp = bech[:pos]
|
hrp = bech[:pos]
|
||||||
data = [CHARSET.find(x) for x in bech[pos+1:]]
|
data = [CHARSET.find(x) for x in bech[pos + 1:]]
|
||||||
if not bech32_verify_checksum(hrp, data):
|
if not bech32_verify_checksum(hrp, data):
|
||||||
return (None, None)
|
return (None, None)
|
||||||
return (hrp, data[:-6])
|
return (hrp, data[:-6])
|
||||||
|
@ -285,7 +285,7 @@ class wait(Syscall):
|
|||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
try:
|
try:
|
||||||
return (yield self)
|
return (yield self)
|
||||||
except:
|
except Exception:
|
||||||
# exception was raised on the waiting task externally with
|
# exception was raised on the waiting task externally with
|
||||||
# close() or throw(), kill the children tasks and re-raise
|
# close() or throw(), kill the children tasks and re-raise
|
||||||
self.exit()
|
self.exit()
|
||||||
|
Loading…
Reference in New Issue
Block a user