diff --git a/src/apps/wallet/__init__.py b/src/apps/wallet/__init__.py index 26e7cd07c9..45a9d8062e 100644 --- a/src/apps/wallet/__init__.py +++ b/src/apps/wallet/__init__.py @@ -1,7 +1,9 @@ from trezor.wire import register, protobuf_workflow from trezor.utils import unimport from trezor.messages.wire_types import \ - GetPublicKey, GetAddress, SignTx, EstimateTxSize, \ + GetPublicKey, GetAddress, \ + GetEntropy, \ + SignTx, EstimateTxSize, \ SignMessage, VerifyMessage, \ SignIdentity, \ CipherKeyValue @@ -19,6 +21,12 @@ def dispatch_GetAddress(*args, **kwargs): return layout_get_address(*args, **kwargs) +@unimport +def dispatch_GetEntropy(*args, **kwargs): + from .get_entropy import layout_get_entropy + return layout_get_entropy(*args, **kwargs) + + @unimport def dispatch_SignTx(*args, **kwargs): from .sign_tx import sign_tx @@ -61,6 +69,7 @@ def dispatch_CipherKeyValue(*args, **kwargs): def boot(): register(GetPublicKey, protobuf_workflow, dispatch_GetPublicKey) register(GetAddress, protobuf_workflow, dispatch_GetAddress) + register(GetEntropy, protobuf_workflow, dispatch_GetEntropy) register(SignTx, protobuf_workflow, dispatch_SignTx) register(EstimateTxSize, protobuf_workflow, dispatch_EstimateTxSize) register(SignMessage, protobuf_workflow, dispatch_SignMessage) diff --git a/src/apps/wallet/get_entropy.py b/src/apps/wallet/get_entropy.py new file mode 100644 index 0000000000..f2353edc6d --- /dev/null +++ b/src/apps/wallet/get_entropy.py @@ -0,0 +1,27 @@ +from trezor import wire, ui +from trezor.utils import unimport + + +@unimport +async def layout_get_entropy(session_id, msg): + from trezor.messages.Entropy import Entropy + from trezor.crypto import random + + + l = min(msg.size, 1024) + + await _show_entropy(session_id) + + return Entropy(entropy=random.bytes(l)) + + +async def _show_entropy(session_id): + from trezor.messages.ButtonRequestType import ProtectCall + from trezor.ui.text import Text + from trezor.ui.container import Container + from ..common.confirm import require_confirm + + content = Container( + Text('Confirm entropy', ui.ICON_RESET, ui.MONO, 'Do you really want to send entropy?')) + + await require_confirm(session_id, content, code=ProtectCall) diff --git a/tests/run_tests_python_trezor.sh b/tests/run_tests_python_trezor.sh index 6599d1ccf3..774c125977 100755 --- a/tests/run_tests_python_trezor.sh +++ b/tests/run_tests_python_trezor.sh @@ -31,7 +31,6 @@ not passing: test_msg_changepin.py \ test_msg_ethereum_signtx.py test_msg_getaddress_show.py - test_msg_getentropy.py test_msg_loaddevice.py test_msg_ping.py test_msg_resetdevice.py @@ -50,6 +49,7 @@ for i in \ test_msg_estimatetxsize.py \ test_msg_ethereum_getaddress.py \ test_msg_getaddress.py \ + test_msg_getentropy.py test_msg_getpublickey.py \ test_msg_signidentity.py \ test_msg_signmessage.py \