Example #1
0
    def __init__(self, wallet, network, idx=None, branch_index=0):
        self.wallet = wallet
        self.network = network
        self.idx = wallet.unused_recv
        addr, gap = wallet.get_address(self.idx,
                                       network=network,
                                       branch_index=branch_index)
        super().__init__(
            "    " + wallet.name + "  #708092 " + lv.SYMBOL.EDIT,
            format_addr(addr, words=4),
            "bitcoin:" + addr,
            qr_width=350,
        )
        self.title.set_recolor(True)
        self.title.set_click(True)
        self.title.set_event_cb(on_release(self.rename))
        self.policy = add_label(wallet.policy, y=55, style="hint", scr=self)

        style = lv.style_t()
        lv.style_copy(style, self.message.get_style(0))
        style.text.font = lv.font_roboto_mono_22
        self.message.set_style(0, style)

        # index
        self.branch_index = branch_index
        self.note = add_label("%s address #%d" % (self.prefix, self.idx),
                              y=80,
                              style="hint",
                              scr=self)
        self.qr.align(self.note, lv.ALIGN.OUT_BOTTOM_MID, 0, 15)
        self.message.align(self.qr, lv.ALIGN.OUT_BOTTOM_MID, 0, 15)

        # warning label for address gap limit
        self.warning = add_label("", scr=self)
        self.warning.align(self.message, lv.ALIGN.OUT_BOTTOM_MID, 0, 15)
        style = lv.style_t()
        lv.style_copy(style, self.note.get_style(0))
        style.text.color = lv.color_hex(0xFF9A00)
        self.warning.set_style(0, style)

        # delbtn = add_button("Delete wallet", on_release(cb_del), y=610)
        self.prv = add_button(lv.SYMBOL.LEFT, on_release(self.prev), scr=self)
        self.nxt = add_button(lv.SYMBOL.RIGHT, on_release(self.next), scr=self)
        if self.idx <= 0:
            self.prv.set_state(lv.btn.STATE.INA)
        self.prv.set_width(70)
        self.prv.align(self.qr, lv.ALIGN.OUT_LEFT_MID, -20, 0)
        self.prv.set_x(0)
        self.nxt.set_width(70)
        self.nxt.align(self.qr, lv.ALIGN.OUT_RIGHT_MID, 20, 0)
        self.nxt.set_x(HOR_RES - 70)

        self.menubtn = add_button(lv.SYMBOL.SETTINGS + " Settings",
                                  on_release(self.show_menu),
                                  scr=self)
        self.menubtn.align(self.close_button, lv.ALIGN.OUT_TOP_MID, 0, -20)

        if idx is not None:
            self.idx = idx
            self.update_address()
Example #2
0
    def __init__(
        self,
        xpub,
        slip132=None,
        prefix=None,
        title="Your master public key",
        qr_width=None,
        button_text="Close",
        sd=True,
    ):
        message = xpub
        if slip132 is not None:
            message = slip132
        if prefix is not None:
            message = prefix + message
        super().__init__(title, message, message, qr_width=320)
        self.message.set_style(0, styles["small"])
        self.xpub = xpub
        self.prefix = prefix
        self.slip132 = slip132

        if prefix is not None:
            lbl = lv.label(self)
            lbl.set_text("Show derivation path")
            lbl.set_pos(2 * PADDING, 500)
            self.prefix_switch = lv.sw(self)
            self.prefix_switch.on(lv.ANIM.OFF)
            self.prefix_switch.align(lbl, lv.ALIGN.OUT_LEFT_MID, 350, 0)

        if slip132 is not None:
            lbl = lv.label(self)
            lbl.set_text("Use SLIP-132")
            lbl.set_pos(2 * PADDING, 560)
            self.slip_switch = lv.sw(self)
            self.slip_switch.on(lv.ANIM.OFF)
            self.slip_switch.align(lbl, lv.ALIGN.OUT_LEFT_MID, 350, 0)

        if prefix is not None:
            self.prefix_switch.set_event_cb(on_release(self.toggle_event))
        if slip132 is not None:
            self.slip_switch.set_event_cb(on_release(self.toggle_event))

        if sd:
            btn = add_button("Save to SD card",
                             on_release(self.save_to_sd),
                             y=610,
                             scr=self)
    def __init__(self, title, message, note=None):
        super().__init__()
        self.title = add_label(title, scr=self, style="title")
        obj = self.title
        if note is not None:
            self.note = add_label(note, scr=self, style="hint")
            self.note.align(self.title, lv.ALIGN.OUT_BOTTOM_MID, 0, 5)
            obj = self.note
        self.page = lv.page(self)
        self.page.set_size(480, 600)
        self.message = add_label(message, scr=self.page)
        self.page.align(obj, lv.ALIGN.OUT_BOTTOM_MID, 0, 0)

        (self.close_button, self.again_button) = add_button_pair(
            lv.SYMBOL.LEFT + " Back",
            on_release(cb_with_args(self.set_value, False)),
            "Roll again",
            on_release(cb_with_args(self.set_value, True)),
            scr=self,
        )
Example #4
0
    def __init__(
        self,
        xpub,
        slip132=None,
        prefix=None,
        title="Your master public key",
        qr_width=None,
        button_text="Close",
    ):
        message = xpub
        if slip132 is not None:
            message = slip132
        if prefix is not None:
            message = prefix + message
        super().__init__(title, message, message)
        self.xpub = xpub
        self.prefix = prefix
        self.slip132 = slip132

        if prefix is not None:
            lbl = lv.label(self)
            lbl.set_text("Show derivation path")
            lbl.set_pos(2 * PADDING, 580)
            self.prefix_switch = lv.sw(self)
            self.prefix_switch.on(lv.ANIM.OFF)
            self.prefix_switch.align(lbl, lv.ALIGN.OUT_LEFT_MID, 350, 0)

        if slip132 is not None:
            lbl = lv.label(self)
            lbl.set_text("Use SLIP-132")
            lbl.set_pos(2 * PADDING, 640)
            self.slip_switch = lv.sw(self)
            self.slip_switch.on(lv.ANIM.OFF)
            self.slip_switch.align(lbl, lv.ALIGN.OUT_LEFT_MID, 350, 0)

        if prefix is not None:
            self.prefix_switch.set_event_cb(on_release(self.toggle_event))
        if slip132 is not None:
            self.slip_switch.set_event_cb(on_release(self.toggle_event))
Example #5
0
    def __init__(self, name, policy, keys):
        super().__init__('Add wallet "%s"?' % name, "")
        self.policy = add_label("Policy: " + policy, y=75, scr=self)

        lbl = lv.label(self)
        lbl.set_text(
            "Canonical xpub                     SLIP-132             ")
        lbl.align(self.policy, lv.ALIGN.OUT_BOTTOM_MID, 0, 30)
        self.slip_switch = lv.sw(self)
        self.slip_switch.align(lbl, lv.ALIGN.CENTER, 0, 0)
        self.slip_switch.set_event_cb(on_release(self.fill_message))

        self.page.align(self.policy, lv.ALIGN.OUT_BOTTOM_MID, 0, 70)
        self.message.set_recolor(True)
        self.page.set_height(500)
        self.keys = keys
        self.fill_message()
    def __init__(self, title, message, note=None):
        super().__init__()
        self.title = add_label(title, scr=self, style="title")
        obj = self.title
        if note is not None:
            self.note = add_label(note, scr=self, style="hint")
            self.note.align(self.title, lv.ALIGN.OUT_BOTTOM_MID, 0, 5)
            obj = self.note
        self.page = lv.page(self)
        self.page.set_size(480, 600)
        self.message = add_label(message, scr=self.page)
        self.page.align(obj, lv.ALIGN.OUT_BOTTOM_MID, 0, -10)

        self.pips_1 = add_button("1",
                                 on_release(
                                     cb_with_args(self.set_value,
                                                  DICE_ROLLED_1)),
                                 scr=self)
        self.pips_1.set_width(130)
        self.pips_1.align(self.page, lv.ALIGN.OUT_LEFT_MID, 20, 20)
        self.pips_1.set_x(100)

        self.pips_2 = add_button("2",
                                 on_release(
                                     cb_with_args(self.set_value,
                                                  DICE_ROLLED_2)),
                                 scr=self)
        self.pips_2.set_width(130)
        self.pips_2.align(self.page, lv.ALIGN.OUT_RIGHT_MID, 20, 20)
        self.pips_2.set_x(HOR_RES - 230)

        self.pips_3 = add_button("3",
                                 on_release(
                                     cb_with_args(self.set_value,
                                                  DICE_ROLLED_3)),
                                 scr=self)
        self.pips_3.set_width(130)
        self.pips_3.align(self.page, lv.ALIGN.OUT_LEFT_MID, -20, 110)
        self.pips_3.set_x(100)

        self.pips_4 = add_button(u"4",
                                 on_release(
                                     cb_with_args(self.set_value,
                                                  DICE_ROLLED_4)),
                                 scr=self)
        self.pips_4.set_width(130)
        self.pips_4.align(self.page, lv.ALIGN.OUT_RIGHT_MID, 20, 110)
        self.pips_4.set_x(HOR_RES - 230)

        self.pips_5 = add_button("5",
                                 on_release(
                                     cb_with_args(self.set_value,
                                                  DICE_ROLLED_5)),
                                 scr=self)
        self.pips_5.set_width(130)
        self.pips_5.align(self.page, lv.ALIGN.OUT_LEFT_MID, -20, 200)
        self.pips_5.set_x(100)

        self.pips_6 = add_button("6",
                                 on_release(
                                     cb_with_args(self.set_value,
                                                  DICE_ROLLED_6)),
                                 scr=self)
        self.pips_6.set_width(130)
        self.pips_6.align(self.page, lv.ALIGN.OUT_RIGHT_MID, 20, 200)
        self.pips_6.set_x(HOR_RES - 230)

        (self.close_button, self.again_button) = add_button_pair(
            lv.SYMBOL.LEFT + " Back",
            on_release(cb_with_args(self.set_value, BACK)),
            "TODO: Use this seed",
            on_release(cb_with_args(self.set_value, USE_SEED)),
            scr=self,
        )