diff --git a/src/apps/wallet/__init__.py b/src/apps/wallet/__init__.py index 304465e7f..bf43c9cec 100644 --- a/src/apps/wallet/__init__.py +++ b/src/apps/wallet/__init__.py @@ -22,8 +22,21 @@ def dispatch_SignTx(mtype, mbuf): return layout_sign_tx(message) +@unimport_func +def dispatch_SignMessage(mtype, mbuf): + from trezor.messages.SignMessage import SignMessage + + message = SignMessage.loads(mbuf) + + from .layout_sign_message import layout_sign_message + return layout_sign_message(message) + + def boot(): GetPublicKey = 11 register(GetPublicKey, dispatch_GetPublicKey) SignTx = 15 register(SignTx, dispatch_SignTx) + SignMessage = 38 + register(SignMessage, dispatch_SignMessage) + diff --git a/src/apps/wallet/layout_sign_message.py b/src/apps/wallet/layout_sign_message.py new file mode 100644 index 000000000..d5b7f378b --- /dev/null +++ b/src/apps/wallet/layout_sign_message.py @@ -0,0 +1,18 @@ +from trezor import wire, ui +from trezor.utils import unimport_gen +from trezor.workflows.confirm import confirm + +@unimport_gen +def layout_sign_message(message): + ui.clear() + ui.display.text(10, 30, 'Signing message', ui.BOLD, ui.LIGHT_GREEN, ui.BLACK) + ui.display.text(10, 60, message.message, ui.MONO, ui.WHITE, ui.BLACK) + confirmed = yield from confirm() + + if confirmed: + from trezor.messages.Success import Success + yield from wire.write(Success(message='Signed')) + else: + from trezor.messages.Failure import Failure + from trezor.messages.FailureType import ActionCancelled + yield from wire.write(Failure(message='Cancelled', code=ActionCancelled))