2016-12-08 15:18:12 +00:00
|
|
|
from trezor.wire import register, protobuf_workflow
|
2016-09-21 12:21:18 +00:00
|
|
|
from trezor.utils import unimport
|
2016-11-12 14:13:00 +00:00
|
|
|
from trezor.messages.wire_types import Initialize, GetFeatures, Ping
|
2016-05-25 12:27:22 +00:00
|
|
|
|
|
|
|
|
2016-12-15 11:48:33 +00:00
|
|
|
@unimport
|
2016-12-08 15:18:12 +00:00
|
|
|
async def respond_Features(session_id, msg):
|
2016-12-15 11:35:18 +00:00
|
|
|
from apps.common import storage, coins
|
2016-09-21 12:21:18 +00:00
|
|
|
from trezor.messages.Features import Features
|
2016-10-20 13:12:25 +00:00
|
|
|
|
|
|
|
f = Features()
|
|
|
|
f.vendor = 'bitcointrezor.com'
|
|
|
|
f.revision = '0123456789'
|
|
|
|
f.bootloader_hash = '0123456789'
|
|
|
|
f.major_version = 2
|
|
|
|
f.minor_version = 0
|
|
|
|
f.patch_version = 0
|
2016-11-11 10:26:38 +00:00
|
|
|
f.coins = coins.COINS
|
2016-10-20 13:12:25 +00:00
|
|
|
|
|
|
|
f.device_id = storage.get_device_id()
|
|
|
|
f.label = storage.get_label()
|
2016-12-15 11:48:33 +00:00
|
|
|
f.language = storage.get_language()
|
2016-10-20 13:12:25 +00:00
|
|
|
f.initialized = storage.is_initialized()
|
|
|
|
f.pin_protection = storage.is_protected_by_pin()
|
|
|
|
f.passphrase_protection = storage.is_protected_by_passphrase()
|
|
|
|
|
2016-11-15 10:51:28 +00:00
|
|
|
return f
|
2016-04-28 21:43:34 +00:00
|
|
|
|
|
|
|
|
2016-12-15 11:48:33 +00:00
|
|
|
@unimport
|
2016-12-08 15:18:12 +00:00
|
|
|
async def respond_Pong(session_id, msg):
|
2016-11-12 14:13:00 +00:00
|
|
|
from trezor.messages.Success import Success
|
2016-12-15 11:35:18 +00:00
|
|
|
|
2016-11-15 10:51:28 +00:00
|
|
|
s = Success()
|
|
|
|
s.message = msg.message
|
2016-12-15 11:35:18 +00:00
|
|
|
|
|
|
|
if msg.pin_protection:
|
|
|
|
from apps.common.request_pin import protect_by_pin
|
|
|
|
await protect_by_pin(session_id)
|
|
|
|
|
2016-11-15 10:51:28 +00:00
|
|
|
# TODO: handle other fields:
|
|
|
|
# button_protection
|
|
|
|
# passphrase_protection
|
|
|
|
return s
|
2016-11-12 14:13:00 +00:00
|
|
|
|
|
|
|
|
2016-04-28 21:43:34 +00:00
|
|
|
def boot():
|
2016-12-08 15:18:12 +00:00
|
|
|
register(Initialize, protobuf_workflow, respond_Features)
|
|
|
|
register(GetFeatures, protobuf_workflow, respond_Features)
|
|
|
|
register(Ping, protobuf_workflow, respond_Pong)
|