예제 #1
0
async def respond_Features(ctx, msg):
    from apps.common import storage, coins, cache
    from trezor.messages.Features import Features

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

    f = Features()
    f.vendor = 'trezor.io'
    f.revision = '0123456789'
    f.bootloader_hash = '0123456789'
    f.major_version = 2
    f.minor_version = 0
    f.patch_version = 0
    f.model = 'T'
    f.coins = coins.COINS

    f.device_id = storage.get_device_id()
    f.label = storage.get_label()
    f.initialized = storage.is_initialized()
    f.passphrase_protection = storage.has_passphrase()
    f.pin_protection = config.has_pin()
    f.language = 'english'

    f.state = cache.get_state()

    return f
예제 #2
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
예제 #3
0
파일: boot.py 프로젝트: zhp1254/trezor-core
async def lockscreen():
    label = storage.get_label()
    image = storage.get_homescreen()
    if not label:
        label = "My TREZOR"
    if not image:
        image = res.load("apps/homescreen/res/bg.toif")

    await ui.backlight_slide(ui.BACKLIGHT_DIM)

    ui.display.clear()
    ui.display.avatar(48, 48, image, ui.TITLE_GREY, ui.BG)
    ui.display.text_center(ui.WIDTH // 2, 35, label, ui.BOLD, ui.TITLE_GREY,
                           ui.BG)

    ui.display.bar_radius(40, 100, 160, 40, ui.TITLE_GREY, ui.BG, 4)
    ui.display.bar_radius(42, 102, 156, 36, ui.BG, ui.TITLE_GREY, 4)
    ui.display.text_center(ui.WIDTH // 2, 128, "Locked", ui.BOLD,
                           ui.TITLE_GREY, ui.BG)

    ui.display.text_center(ui.WIDTH // 2 + 10, 220, "Tap to unlock", ui.BOLD,
                           ui.TITLE_GREY, ui.BG)
    ui.display.icon(45, 202, res.load(ui.ICON_CLICK), ui.TITLE_GREY, ui.BG)

    await ui.backlight_slide(ui.BACKLIGHT_NORMAL)
    await ui.click()
예제 #4
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)
예제 #5
0
async def lockscreen():
    from apps.common import storage

    label = storage.get_label()
    image = storage.get_homescreen()
    if not label:
        label = 'My TREZOR'
    if not image:
        image = res.load('apps/homescreen/res/bg.toif')

    await ui.backlight_slide(ui.BACKLIGHT_DIM)

    ui.display.clear()
    ui.display.avatar(48, 48, image, ui.TITLE_GREY, ui.BG)
    ui.display.text_center(120, 35, label, ui.BOLD, ui.TITLE_GREY, ui.BG)

    ui.display.bar_radius(40, 100, 160, 40, ui.TITLE_GREY, ui.BG, 4)
    ui.display.bar_radius(42, 102, 156, 36, ui.BG, ui.TITLE_GREY, 4)
    ui.display.text_center(120, 128, 'Locked', ui.BOLD, ui.TITLE_GREY, ui.BG)

    ui.display.text_center(130, 220, 'Tap to unlock', ui.BOLD, ui.TITLE_GREY,
                           ui.BG)
    ui.display.icon(45, 202, res.load(ui.ICON_CLICK), ui.TITLE_GREY, ui.BG)

    await ui.backlight_slide(ui.BACKLIGHT_NORMAL)
    await ui.click()
예제 #6
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)
예제 #7
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
예제 #8
0
def display_homescreen():
    from apps.common import storage

    image = res.load('apps/homescreen/res/trezor_logo.toig')
    ui.display.icon(0, 0, image, ui.WHITE, ui.BLACK)

    label = storage.get_label()
    if not label:
        label = 'My TREZOR'
    ui.display.text_center(120, 210, label, ui.BOLD, ui.WHITE, ui.BLACK)
예제 #9
0
def display_homescreen():
    from apps.common import storage

    image = res.load('apps/homescreen/res/trezor_logo.toig')
    ui.display.icon(0, 0, image, ui.FG, ui.BG)

    if not storage.is_initialized():
        label = 'Go to trezor.io/start'
    else:
        label = storage.get_label()
        if not label:
            label = 'My TREZOR'
    ui.display.text_center(120, 210, label, ui.BOLD, ui.FG, ui.BG)
예제 #10
0
async def display_homescreen():
    from apps.common import storage

    image = res.load('apps/homescreen/res/homescreen.toif')
    ui.display.bar(0, 0, ui.SCREEN, ui.SCREEN, ui.BG)
    ui.display.avatar((ui.SCREEN - 144) // 2, (ui.SCREEN - 144) // 2 - 10,
                      image, ui.WHITE, ui.BLACK)

    if not storage.is_initialized():
        label = 'Go to trezor.io/start'
    else:
        label = storage.get_label() or 'My TREZOR'
    ui.display.text_center(ui.SCREEN // 2, ui.SCREEN - 20, label, ui.BOLD,
                           ui.FG, ui.BG)

    await dim_screen()
예제 #11
0
async def display_homescreen():
    from apps.common import storage

    image = res.load('apps/homescreen/res/trezor_lock.toig')
    ui.display.bar(0, 0, ui.SCREEN, ui.SCREEN, ui.BG)
    ui.display.icon((ui.SCREEN - 124) // 2, (ui.SCREEN - 40 - 180) // 2, image,
                    ui.FG, ui.BG)

    if not storage.is_initialized():
        label = 'Go to trezor.io/start'
    else:
        label = storage.get_label() or 'My TREZOR'
    ui.display.text_center(ui.SCREEN // 2, ui.SCREEN - 20, label, ui.BOLD,
                           ui.FG, ui.BG)

    await dim_screen()
예제 #12
0
def display_homescreen():
    from apps.common import storage

    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')

    ui.display.bar(0, 0, ui.SCREEN, ui.SCREEN, ui.BG)
    ui.display.avatar(48, 48 - 10, image, ui.WHITE, ui.BLACK)
    ui.display.text_center(120, 220, label, ui.BOLD, ui.FG, ui.BG)
예제 #13
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
예제 #14
0
async def respond_Features(session_id, msg):
    from apps.common import storage, coins
    from trezor.messages.Features import Features

    f = Features()
    f.vendor = 'trezor.io'
    f.revision = '0123456789'
    f.bootloader_hash = '0123456789'
    f.major_version = 2
    f.minor_version = 0
    f.patch_version = 0
    f.coins = coins.COINS

    f.device_id = storage.get_device_id()
    f.label = storage.get_label()
    f.language = storage.get_language()
    f.initialized = storage.is_initialized()
    f.pin_protection = storage.is_protected_by_pin()
    f.passphrase_protection = storage.is_protected_by_passphrase()

    return f
예제 #15
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
예제 #16
0
async def lockscreen():
    from apps.common import storage

    label = storage.get_label()
    image = storage.get_homescreen()
    if not label:
        label = 'My TREZOR'
    if not image:
        image = res.load('apps/homescreen/res/bg.toif')

    await ui.backlight_slide(ui.BACKLIGHT_DIM)

    ui.display.bar(0, 0, 240, 240, ui.WHITE)
    ui.display.avatar(48, 48, image, ui.BLACK, ui.WHITE)
    ui.display.text_center(120, 35, label, ui.BOLD, ui.BLACK, ui.WHITE)

    ui.display.text_center(130, 220, 'Tap to unlock', ui.BOLD, ui.DARK_GREY,
                           ui.WHITE)
    ui.display.icon(45, 202, res.load(ui.ICON_CLICK), ui.DARK_GREY, ui.WHITE)

    await ui.backlight_slide(ui.BACKLIGHT_NORMAL)
    await ui.click()