2016-11-06 16:04:25 +00:00
|
|
|
import sys
|
2018-02-26 23:29:00 +00:00
|
|
|
|
2020-01-30 14:57:19 +00:00
|
|
|
sys.path.append("../src")
|
2016-11-06 16:04:25 +00:00
|
|
|
|
2018-02-27 02:05:15 +00:00
|
|
|
import unittest # noqa: F401
|
2023-02-03 13:39:31 +00:00
|
|
|
from typing import Any, Awaitable
|
2023-06-28 10:58:54 +00:00
|
|
|
from ubinascii import hexlify, unhexlify # noqa: F401
|
2019-08-26 16:47:49 +00:00
|
|
|
|
|
|
|
from trezor import utils # noqa: F401
|
2023-06-28 10:58:54 +00:00
|
|
|
|
2021-03-23 12:29:25 +00:00
|
|
|
from apps.common.paths import HARDENED
|
2020-08-03 15:28:20 +00:00
|
|
|
|
2023-06-28 10:46:29 +00:00
|
|
|
|
2020-08-03 15:28:20 +00:00
|
|
|
def H_(x: int) -> int:
|
2023-02-03 13:39:31 +00:00
|
|
|
"""
|
|
|
|
Shortcut function that "hardens" a number in a BIP44 path.
|
|
|
|
"""
|
2020-08-03 15:28:20 +00:00
|
|
|
return x | HARDENED
|
2020-01-30 14:57:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
def await_result(task: Awaitable) -> Any:
|
|
|
|
value = None
|
|
|
|
while True:
|
|
|
|
try:
|
|
|
|
result = task.send(value)
|
|
|
|
except StopIteration as e:
|
|
|
|
return e.value
|
|
|
|
|
|
|
|
if result:
|
|
|
|
value = await_result(result)
|
|
|
|
else:
|
|
|
|
value = None
|