Exemplo n.º 1
0
async def respond_Features(ctx, msg):

    if msg.__qualname__ == 'Initialize':
        if msg.state is None or msg.state != cache.get_state(salt=msg.state[:32]):
            cache.clear()

    f = Features()
    f.vendor = 'trezor.io'
    f.major_version = symbol('VERSION_MAJOR')
    f.minor_version = symbol('VERSION_MINOR')
    f.patch_version = symbol('VERSION_PATCH')
    f.device_id = storage.get_device_id()
    f.pin_protection = config.has_pin()
    f.passphrase_protection = storage.has_passphrase()
    f.language = 'english'
    f.label = storage.get_label()
    f.coins = coins.COINS
    f.initialized = storage.is_initialized()
    f.revision = symbol('GITREV')
    f.pin_cached = config.has_pin()
    f.passphrase_cached = cache.has_passphrase()
    f.needs_backup = storage.needs_backup()
    f.flags = storage.get_flags()
    f.model = 'T'
    f.state = cache.get_state()

    return f
Exemplo n.º 2
0
def display_homescreen():
    if not storage.is_initialized():
        label = 'Go to trezor.io/start'
        image = None
    else:
        label = storage.get_label() or 'My TREZOR'
        image = storage.get_homescreen()

    if not image:
        image = res.load('apps/homescreen/res/bg.toif')

    if storage.is_initialized() and storage.unfinished_backup():
        ui.display.bar(0, 0, ui.WIDTH, 30, ui.RED)
        ui.display.text_center(ui.WIDTH // 2, 22, 'BACKUP FAILED!', ui.BOLD, ui.WHITE, ui.RED)
        ui.display.bar(0, 30, ui.WIDTH, ui.HEIGHT - 30, ui.BG)
    elif storage.is_initialized() and storage.needs_backup():
        ui.display.bar(0, 0, ui.WIDTH, 30, ui.YELLOW)
        ui.display.text_center(ui.WIDTH // 2, 22, 'NEEDS BACKUP!', ui.BOLD, ui.BLACK, ui.YELLOW)
        ui.display.bar(0, 30, ui.WIDTH, ui.HEIGHT - 30, ui.BG)
    elif storage.is_initialized() and not config.has_pin():
        ui.display.bar(0, 0, ui.WIDTH, 30, ui.YELLOW)
        ui.display.text_center(ui.WIDTH // 2, 22, 'PIN NOT SET!', ui.BOLD, ui.BLACK, ui.YELLOW)
        ui.display.bar(0, 30, ui.WIDTH, ui.HEIGHT - 30, ui.BG)
    else:
        ui.display.bar(0, 0, ui.WIDTH, ui.HEIGHT, ui.BG)
    ui.display.avatar(48, 48 - 10, image, ui.WHITE, ui.BLACK)
    ui.display.text_center(ui.WIDTH // 2, 220, label, ui.BOLD, ui.FG, ui.BG)
Exemplo n.º 3
0
async def backup_device(ctx, msg):
    if not storage.is_initialized():
        raise wire.ProcessError("Device is not initialized")
    if not storage.needs_backup():
        raise wire.ProcessError("Seed already backed up")

    mnemonic_secret, mnemonic_type = mnemonic.get()
    slip39 = mnemonic_type == mnemonic.TYPE_SLIP39

    # warn user about mnemonic safety
    await layout.show_backup_warning(ctx, "Back up your seed", "I understand",
                                     slip39)

    storage.set_unfinished_backup(True)
    storage.set_backed_up()

    if slip39:
        await backup_slip39_wallet(ctx, mnemonic_secret)
    else:
        await layout.bip39_show_and_confirm_mnemonic(ctx,
                                                     mnemonic_secret.decode())

    storage.set_unfinished_backup(False)

    return Success(message="Seed successfully backed up")
Exemplo n.º 4
0
def display_homescreen():
    image = None
    if storage.is_slip39_in_progress():
        label = "Waiting for other shares"
    elif not storage.is_initialized():
        label = "Go to trezor.io/start"
    else:
        label = storage.get_label() or "My Trezor"
        image = storage.get_homescreen()

    if not image:
        image = res.load("apps/homescreen/res/bg.toif")

    if storage.is_initialized() and storage.no_backup():
        _err("SEEDLESS")
    elif storage.is_initialized() and storage.unfinished_backup():
        _err("BACKUP FAILED!")
    elif storage.is_initialized() and storage.needs_backup():
        _warn("NEEDS BACKUP!")
    elif storage.is_initialized() and not config.has_pin():
        _warn("PIN NOT SET!")
    elif storage.is_slip39_in_progress():
        _warn("SHAMIR IN PROGRESS!")
    else:
        ui.display.bar(0, 0, ui.WIDTH, ui.HEIGHT, ui.BG)
    ui.display.avatar(48, 48 - 10, image, ui.WHITE, ui.BLACK)
    ui.display.text_center(ui.WIDTH // 2, 220, label, ui.BOLD, ui.FG, ui.BG)
Exemplo n.º 5
0
async def respond_Features(ctx, msg):

    if msg.__qualname__ == 'Initialize':
        if msg.state is None or bytes(
                msg.state) != cache.get_state(state=bytes(msg.state)):
            cache.clear()

    f = Features()
    f.vendor = 'trezor.io'
    f.major_version = symbol('VERSION_MAJOR')
    f.minor_version = symbol('VERSION_MINOR')
    f.patch_version = symbol('VERSION_PATCH')
    f.device_id = storage.get_device_id()
    f.pin_protection = config.has_pin()
    f.passphrase_protection = storage.has_passphrase()
    f.language = 'english'
    f.label = storage.get_label()
    f.initialized = storage.is_initialized()
    f.revision = symbol('GITREV')
    f.pin_cached = config.has_pin()
    f.passphrase_cached = cache.has_passphrase()
    f.needs_backup = storage.needs_backup()
    f.flags = storage.get_flags()
    if model() in ['T', 'EMU']:  # emulator currently emulates model T
        f.model = 'T'
    f.unfinished_backup = storage.unfinished_backup()

    return f
Exemplo n.º 6
0
def get_features():
    f = Features()
    f.vendor = "trezor.io"
    f.language = "english"
    f.major_version = utils.VERSION_MAJOR
    f.minor_version = utils.VERSION_MINOR
    f.patch_version = utils.VERSION_PATCH
    f.revision = utils.GITREV
    f.model = utils.MODEL
    f.device_id = storage.get_device_id()
    f.label = storage.get_label()
    f.initialized = storage.is_initialized()
    f.pin_protection = config.has_pin()
    f.pin_cached = config.has_pin()
    f.passphrase_protection = storage.has_passphrase()
    f.passphrase_cached = cache.has_passphrase()
    f.needs_backup = storage.needs_backup()
    f.unfinished_backup = storage.unfinished_backup()
    f.flags = storage.get_flags()
    return f
Exemplo n.º 7
0
async def backup_device(ctx, msg):
    if not storage.is_initialized():
        raise wire.FailureError(ProcessError, 'Device is not initialized')
    if not storage.needs_backup():
        raise wire.FailureError(ProcessError, 'Seed already backed up')

    mnemonic = storage.get_mnemonic()

    storage.set_backed_up()

    # warn user about mnemonic safety
    await show_warning(ctx)
    while True:
        # show mnemonic and require confirmation of a random word
        await show_mnemonic(ctx, mnemonic)
        if await check_mnemonic(ctx, mnemonic):
            break
        await show_wrong_entry(ctx)

    return Success(message='Seed successfully backed up')
Exemplo n.º 8
0
def get_features():
    f = Features()
    f.vendor = 'trezor.io'
    f.language = 'english'
    f.major_version = utils.symbol('VERSION_MAJOR')
    f.minor_version = utils.symbol('VERSION_MINOR')
    f.patch_version = utils.symbol('VERSION_PATCH')
    f.revision = utils.symbol('GITREV')
    f.model = utils.model()
    if f.model == 'EMU':
        f.model = 'T'  # emulator currently emulates model T
    f.device_id = storage.get_device_id()
    f.label = storage.get_label()
    f.initialized = storage.is_initialized()
    f.pin_protection = config.has_pin()
    f.pin_cached = config.has_pin()
    f.passphrase_protection = storage.has_passphrase()
    f.passphrase_cached = cache.has_passphrase()
    f.needs_backup = storage.needs_backup()
    f.unfinished_backup = storage.unfinished_backup()
    f.flags = storage.get_flags()
    return f
Exemplo n.º 9
0
async def backup_device(ctx, msg):
    if not storage.is_initialized():
        raise wire.ProcessError("Device is not initialized")
    if not storage.needs_backup():
        raise wire.ProcessError("Seed already backed up")

    words = mnemonic.restore()

    # warn user about mnemonic safety
    await show_backup_warning(ctx)

    storage.set_unfinished_backup(True)
    storage.set_backed_up()

    while True:
        # show mnemonic and require confirmation of a random word
        await show_mnemonic(ctx, words)
        if await check_mnemonic(ctx, words):
            break
        await show_wrong_entry(ctx)

    storage.set_unfinished_backup(False)

    return Success(message="Seed successfully backed up")