mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-02 19:01:04 +00:00
core/passphrase: add button requests
This commit is contained in:
parent
4a0f727f13
commit
466dc4732d
@ -62,11 +62,12 @@ message ButtonRequest {
|
||||
ButtonRequest_PublicKey = 11;
|
||||
ButtonRequest_MnemonicWordCount = 12;
|
||||
ButtonRequest_MnemonicInput = 13;
|
||||
ButtonRequest_PassphraseType = 14;
|
||||
// ButtonRequest_PassphraseType = 14; DEPRECATED
|
||||
ButtonRequest_UnknownDerivationPath = 15;
|
||||
ButtonRequest_RecoveryHomepage = 16;
|
||||
ButtonRequest_Success = 17;
|
||||
ButtonRequest_Warning = 18;
|
||||
ButtonRequest_PassphraseEntry = 19;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,9 @@ from micropython import const
|
||||
|
||||
import storage.device
|
||||
from trezor import wire
|
||||
from trezor.messages import ButtonRequestType
|
||||
from trezor.messages.ButtonAck import ButtonAck
|
||||
from trezor.messages.ButtonRequest import ButtonRequest
|
||||
from trezor.messages.PassphraseAck import PassphraseAck
|
||||
from trezor.messages.PassphraseRequest import PassphraseRequest
|
||||
from trezor.ui.passphrase import CANCELLED, PassphraseKeyboard
|
||||
@ -42,6 +45,8 @@ async def request_from_user(ctx: wire.Context) -> str:
|
||||
|
||||
|
||||
async def request_from_user_on_device(ctx: wire.Context) -> str:
|
||||
await ctx.call(ButtonRequest(code=ButtonRequestType.PassphraseEntry), ButtonAck)
|
||||
|
||||
keyboard = PassphraseKeyboard("Enter passphrase", _MAX_PASSPHRASE_LEN)
|
||||
if __debug__:
|
||||
passphrase = await ctx.wait(keyboard, input_signal())
|
||||
|
@ -6,7 +6,7 @@ if __debug__:
|
||||
try:
|
||||
from typing import Dict, List # noqa: F401
|
||||
from typing_extensions import Literal # noqa: F401
|
||||
EnumTypeButtonRequestType = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]
|
||||
EnumTypeButtonRequestType = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 17, 18, 19]
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
@ -23,5 +23,5 @@ class ButtonRequest(p.MessageType):
|
||||
@classmethod
|
||||
def get_fields(cls) -> Dict:
|
||||
return {
|
||||
1: ('code', p.EnumType("ButtonRequestType", (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18)), 0),
|
||||
1: ('code', p.EnumType("ButtonRequestType", (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 17, 18, 19)), 0),
|
||||
}
|
||||
|
@ -16,8 +16,8 @@ Address = 10 # type: Literal[10]
|
||||
PublicKey = 11 # type: Literal[11]
|
||||
MnemonicWordCount = 12 # type: Literal[12]
|
||||
MnemonicInput = 13 # type: Literal[13]
|
||||
PassphraseType = 14 # type: Literal[14]
|
||||
UnknownDerivationPath = 15 # type: Literal[15]
|
||||
RecoveryHomepage = 16 # type: Literal[16]
|
||||
Success = 17 # type: Literal[17]
|
||||
Warning = 18 # type: Literal[18]
|
||||
PassphraseEntry = 19 # type: Literal[19]
|
||||
|
@ -6,7 +6,7 @@ if __debug__:
|
||||
try:
|
||||
from typing import Dict, List # noqa: F401
|
||||
from typing_extensions import Literal # noqa: F401
|
||||
EnumTypeButtonRequestType = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]
|
||||
EnumTypeButtonRequestType = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 17, 18, 19]
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
@ -23,5 +23,5 @@ class ButtonRequest(p.MessageType):
|
||||
@classmethod
|
||||
def get_fields(cls) -> Dict:
|
||||
return {
|
||||
1: ('code', p.EnumType("ButtonRequestType", (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18)), 0),
|
||||
1: ('code', p.EnumType("ButtonRequestType", (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 16, 17, 18, 19)), 0),
|
||||
}
|
||||
|
@ -16,8 +16,8 @@ Address = 10 # type: Literal[10]
|
||||
PublicKey = 11 # type: Literal[11]
|
||||
MnemonicWordCount = 12 # type: Literal[12]
|
||||
MnemonicInput = 13 # type: Literal[13]
|
||||
PassphraseType = 14 # type: Literal[14]
|
||||
UnknownDerivationPath = 15 # type: Literal[15]
|
||||
RecoveryHomepage = 16 # type: Literal[16]
|
||||
Success = 17 # type: Literal[17]
|
||||
Warning = 18 # type: Literal[18]
|
||||
PassphraseEntry = 19 # type: Literal[19]
|
||||
|
Loading…
Reference in New Issue
Block a user