mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-06-26 09:52:34 +00:00
core/sign_tx: improve type hints
This commit is contained in:
parent
ff41e5c304
commit
0209768ff2
@ -48,7 +48,7 @@ async def sign_tx(ctx: wire.Context, msg: SignTx, keychain: seed.Keychain) -> Tx
|
|||||||
except common.SigningError as e:
|
except common.SigningError as e:
|
||||||
raise wire.Error(*e.args)
|
raise wire.Error(*e.args)
|
||||||
|
|
||||||
res = None # type: Union[TxAck, bool]
|
res = None # type: Union[TxAck, bool, None]
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
req = signer.send(res)
|
req = signer.send(res)
|
||||||
|
@ -28,7 +28,7 @@ class AddressError(Exception):
|
|||||||
|
|
||||||
|
|
||||||
def get_address(
|
def get_address(
|
||||||
script_type: int,
|
script_type: EnumTypeInputScriptType,
|
||||||
coin: CoinInfo,
|
coin: CoinInfo,
|
||||||
node: bip32.HDNode,
|
node: bip32.HDNode,
|
||||||
multisig: MultisigRedeemScriptType = None,
|
multisig: MultisigRedeemScriptType = None,
|
||||||
@ -253,7 +253,9 @@ def validate_purpose(purpose: int, coin: CoinInfo) -> bool:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def validate_purpose_against_script_type(purpose: int, script_type: int) -> bool:
|
def validate_purpose_against_script_type(
|
||||||
|
purpose: int, script_type: EnumTypeInputScriptType
|
||||||
|
) -> bool:
|
||||||
"""
|
"""
|
||||||
Validates purpose against provided input's script type:
|
Validates purpose against provided input's script type:
|
||||||
- 44 for spending address (script_type == SPENDADDRESS)
|
- 44 for spending address (script_type == SPENDADDRESS)
|
||||||
|
@ -22,7 +22,9 @@ from .writers import TX_HASH_SIZE
|
|||||||
from apps.common.coininfo import CoinInfo
|
from apps.common.coininfo import CoinInfo
|
||||||
|
|
||||||
if False:
|
if False:
|
||||||
from typing import Any, Awaitable, Union
|
from typing import Any, Awaitable, Dict, Union
|
||||||
|
from trezor.messages.TxInputType import EnumTypeInputScriptType
|
||||||
|
from trezor.messages.TxOutputType import EnumTypeOutputScriptType
|
||||||
|
|
||||||
MULTISIG_INPUT_SCRIPT_TYPES = (
|
MULTISIG_INPUT_SCRIPT_TYPES = (
|
||||||
InputScriptType.SPENDMULTISIG,
|
InputScriptType.SPENDMULTISIG,
|
||||||
@ -40,7 +42,7 @@ CHANGE_OUTPUT_TO_INPUT_SCRIPT_TYPES = {
|
|||||||
OutputScriptType.PAYTOMULTISIG: InputScriptType.SPENDMULTISIG,
|
OutputScriptType.PAYTOMULTISIG: InputScriptType.SPENDMULTISIG,
|
||||||
OutputScriptType.PAYTOP2SHWITNESS: InputScriptType.SPENDP2SHWITNESS,
|
OutputScriptType.PAYTOP2SHWITNESS: InputScriptType.SPENDP2SHWITNESS,
|
||||||
OutputScriptType.PAYTOWITNESS: InputScriptType.SPENDWITNESS,
|
OutputScriptType.PAYTOWITNESS: InputScriptType.SPENDWITNESS,
|
||||||
}
|
} # type: Dict[EnumTypeOutputScriptType, EnumTypeInputScriptType]
|
||||||
INTERNAL_INPUT_SCRIPT_TYPES = tuple(CHANGE_OUTPUT_TO_INPUT_SCRIPT_TYPES.values())
|
INTERNAL_INPUT_SCRIPT_TYPES = tuple(CHANGE_OUTPUT_TO_INPUT_SCRIPT_TYPES.values())
|
||||||
CHANGE_OUTPUT_SCRIPT_TYPES = tuple(CHANGE_OUTPUT_TO_INPUT_SCRIPT_TYPES.keys())
|
CHANGE_OUTPUT_SCRIPT_TYPES = tuple(CHANGE_OUTPUT_TO_INPUT_SCRIPT_TYPES.keys())
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user