Skip to content

Commit

Permalink
sans key loading - custom message
Browse files Browse the repository at this point in the history
separate loading options
  • Loading branch information
odudex committed Jun 7, 2024
1 parent 7f779cc commit a54026a
Show file tree
Hide file tree
Showing 16 changed files with 68 additions and 2,822 deletions.
2 changes: 2 additions & 0 deletions i18n/translations/de-DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"%s was removed from flash": "%s wurde aus dem Flash-Speicher gelöscht",
"(%d total)": "(%d insgesamt)",
"(Experimental)": "(Experimental)",
"(watch-only)": "(nur zur Betrachtung)",
"12 words": "12 Wörter",
"24 words": "24 Wörter",
"About": "Über",
Expand Down Expand Up @@ -139,6 +140,7 @@
"Line:": "Linie:",
"Load Mnemonic": "Mnemonic laden",
"Load Wallet": "Wallet laden",
"Load a trusted wallet descriptor to view addresses?": "Einen vertrauenswürdigen Wallet-Deskriptor laden, um Adressen anzuzeigen?",
"Load child?": "Untermnemonik laden?",
"Load from SD card": "Von SD-Karte laden",
"Load from SD card?": "Von SD-Karte laden?",
Expand Down
2 changes: 2 additions & 0 deletions i18n/translations/es-MX.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"%s was removed from flash": "%s se eliminó del flash",
"(%d total)": "(%d total)",
"(Experimental)": "(Experimental)",
"(watch-only)": "(Solo para observación)",
"12 words": "12 palabras",
"24 words": "24 palabras",
"About": "Nosotros",
Expand Down Expand Up @@ -139,6 +140,7 @@
"Line:": "Línea:",
"Load Mnemonic": "Importar Mnemónico",
"Load Wallet": "Cargar Cartera",
"Load a trusted wallet descriptor to view addresses?": "¿Cargar un descriptor de monedero de confianza para ver las direcciones?",
"Load child?": "¿Cargar derivado?",
"Load from SD card": "Cargar desde tarjeta SD",
"Load from SD card?": "¿Cargar desde la tarjeta SD?",
Expand Down
2 changes: 2 additions & 0 deletions i18n/translations/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"%s was removed from flash": "%s a été supprimé du flash",
"(%d total)": "(%d au total)",
"(Experimental)": "(Expérimental)",
"(watch-only)": "(montre uniquement)",
"12 words": "12 mots",
"24 words": "24 mots",
"About": "À propos",
Expand Down Expand Up @@ -139,6 +140,7 @@
"Line:": "Ligne:",
"Load Mnemonic": "Charger mnémonique",
"Load Wallet": "Charger le portefeuille",
"Load a trusted wallet descriptor to view addresses?": "Charger un descripteur de portefeuille de confiance pour afficher les adresses ?",
"Load child?": "Charger le mnémonique dérivé ?",
"Load from SD card": "Charger depuis la carte SD",
"Load from SD card?": "Charger depuis la carte SD ?",
Expand Down
2 changes: 2 additions & 0 deletions i18n/translations/nl-NL.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"%s was removed from flash": "%s verwijderd van flashgeheugen",
"(%d total)": "(%d totaal)",
"(Experimental)": "(Experimenteel)",
"(watch-only)": "(alleen-watch)",
"12 words": "12 woorden",
"24 words": "24 woorden",
"About": "Over",
Expand Down Expand Up @@ -139,6 +140,7 @@
"Line:": "Lijn:",
"Load Mnemonic": "Geheugensteun laden",
"Load Wallet": "Wallet laden",
"Load a trusted wallet descriptor to view addresses?": "Een vertrouwde wallet-descriptor laden om adressen te bekijken?",
"Load child?": "Afgeleide mnemonic laden?",
"Load from SD card": "Laden vanaf SD-kaart",
"Load from SD card?": "Laden vanaf SD-kaart?",
Expand Down
2 changes: 2 additions & 0 deletions i18n/translations/pl-PL.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"%s was removed from flash": "%s usunięto z pamięci flash",
"(%d total)": "(łącznie %d)",
"(Experimental)": "(Eksperymentalny)",
"(watch-only)": "(tylko zegarek)",
"12 words": "12 słów",
"24 words": "24 słowa",
"About": "O",
Expand Down Expand Up @@ -139,6 +140,7 @@
"Line:": "Linia:",
"Load Mnemonic": "Ładuj mnemoniczne",
"Load Wallet": "Załaduj portfel",
"Load a trusted wallet descriptor to view addresses?": "Załadować deskryptor zaufanego portfela, aby wyświetlić adresy?",
"Load child?": "Załadować podrzędną mnemonikę?",
"Load from SD card": "Załaduj z karty SD",
"Load from SD card?": "Załaduj z karty SD?",
Expand Down
2 changes: 2 additions & 0 deletions i18n/translations/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"%s was removed from flash": "%s foi excluído da memória flash",
"(%d total)": "(%d total)",
"(Experimental)": "(Experimental)",
"(watch-only)": "(Somente visualização)",
"12 words": "12 palavras",
"24 words": "24 palavras",
"About": "Sobre",
Expand Down Expand Up @@ -139,6 +140,7 @@
"Line:": "Linha:",
"Load Mnemonic": "Carregar Mnemônico",
"Load Wallet": "Carregar Carteira",
"Load a trusted wallet descriptor to view addresses?": "Carregar um descritor de carteira confiável para visualizar endereços?",
"Load child?": "Carregar derivado?",
"Load from SD card": "Carregar do cartão SD",
"Load from SD card?": "Carregar do cartão SD?",
Expand Down
2 changes: 2 additions & 0 deletions i18n/translations/ru-RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"%s was removed from flash": "%s удален с флеш-памяти",
"(%d total)": "(%d всего)",
"(Experimental)": "(Эксперементальный)",
"(watch-only)": "(Только часы)",
"12 words": "12 слов",
"24 words": "24 слова",
"About": "О Программе",
Expand Down Expand Up @@ -139,6 +140,7 @@
"Line:": "Линия:",
"Load Mnemonic": "Загрузить Мнемонику",
"Load Wallet": "Загрузить кошелек",
"Load a trusted wallet descriptor to view addresses?": "Загрузить дескриптор доверенного кошелька для просмотра адресов?",
"Load child?": "Загрузить дочерний элемент?",
"Load from SD card": "Загрузка с SD-карты",
"Load from SD card?": "Загрузить с SD карты?",
Expand Down
2 changes: 2 additions & 0 deletions i18n/translations/tr-TR.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"%s was removed from flash": "%s flash'tan kaldırıldı",
"(%d total)": "(toplam %d)",
"(Experimental)": "(Deneysel)",
"(watch-only)": "(sadece izle)",
"12 words": "12 kelime",
"24 words": "24 kelime",
"About": "Hakkında",
Expand Down Expand Up @@ -139,6 +140,7 @@
"Line:": "Satır:",
"Load Mnemonic": "Mnemonic Yükle",
"Load Wallet": "Cüzdan Yükle",
"Load a trusted wallet descriptor to view addresses?": "Adresleri görüntülemek için güvenilir bir cüzdan tanımlayıcısı yüklensin mi?",
"Load child?": "Türev yüklensin mi?",
"Load from SD card": "SD karttan yükle",
"Load from SD card?": "SD karttan yüklensin mi?",
Expand Down
2 changes: 2 additions & 0 deletions i18n/translations/vi-VN.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"%s was removed from flash": "%s đã bị xóa khỏi bộ nhớ flash",
"(%d total)": "(tổng cộng %d)",
"(Experimental)": "(Thực nghiệm)",
"(watch-only)": "(chỉ xem)",
"12 words": "12 từ",
"24 words": "24 từ",
"About": "Về chúng tôi",
Expand Down Expand Up @@ -139,6 +140,7 @@
"Line:": "Đường kẻ:",
"Load Mnemonic": "Tải mã mnemonic",
"Load Wallet": "Nạp Ví",
"Load a trusted wallet descriptor to view addresses?": "Tải mô tả ví đáng tin cậy để xem địa chỉ?",
"Load child?": "Nạp Mnemonic phụ?",
"Load from SD card": "Tải từ thẻ SD",
"Load from SD card?": "Tải từ thẻ SD?",
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

[tool.poetry]
name = "krux"
version = "24.04.beta31"
version = "24.04.beta32"
description = "Open-source signing device firmware for Bitcoin"
authors = ["Jeff S <[email protected]>"]

Expand Down
2 changes: 1 addition & 1 deletion src/krux/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
VERSION = "24.04.beta31"
VERSION = "24.04.beta32"
SIGNER_PUBKEY = "03339e883157e45891e61ca9df4cd3bb895ef32d475b8e793559ea10a36766689b"
19 changes: 19 additions & 0 deletions src/krux/pages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@
BATTERY_WIDTH = 22
BATTERY_HEIGHT = 7

LOAD_FROM_CAMERA = 0
LOAD_FROM_SD = 1


class Page:
"""Represents a page in the app, with helper methods for common display and
Expand All @@ -96,6 +99,22 @@ def esc_prompt(self):
return ESC_KEY
return None

def load_method(self):
"""Prompts user to choose a method to load data from"""
load_menu = Menu(
self.ctx,
[
(t("Load from camera"), lambda: None),
(
t("Load from SD card"),
None if not self.has_sd_card() else lambda: None,
),
(t("Back"), lambda: None),
],
)
index, _ = load_menu.run_loop()
return index

def flash_text(
self,
text,
Expand Down
21 changes: 6 additions & 15 deletions src/krux/pages/home_pages/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
MENU_CONTINUE,
MENU_EXIT,
ESC_KEY,
LOAD_FROM_CAMERA,
LOAD_FROM_SD,
)

MAX_POLICY_COSIGNERS_DISPLAYED = 5
Expand Down Expand Up @@ -198,27 +200,16 @@ def sign(self):
def load_psbt(self):
"""Loads a PSBT from camera or SD card"""

load_menu = Menu(
self.ctx,
[
(t("Load from camera"), lambda: None),
(
t("Load from SD card"),
None if not self.has_sd_card() else lambda: None,
),
(t("Back"), lambda: None),
],
)
index, _ = load_menu.run_loop()
load_method = self.load_method()

if index == 2:
if load_method > LOAD_FROM_SD:
return (None, None, "")

if index == 0:
if load_method == LOAD_FROM_CAMERA:
data, qr_format = self.capture_qr_code()
return (data, qr_format, "")

# If index == 1
# If load_method == LOAD_FROM_SD
from ..utils import Utils
from ...sd_card import PSBT_FILE_EXTENSION

Expand Down
21 changes: 5 additions & 16 deletions src/krux/pages/home_pages/sign_message_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from embit import bip32, compact
import hashlib
import binascii
from .. import MENU_CONTINUE, Menu
from .. import MENU_CONTINUE, LOAD_FROM_CAMERA, LOAD_FROM_SD, Menu
from ...themes import theme
from ...display import (
DEFAULT_PADDING,
Expand All @@ -50,27 +50,16 @@ class SignMessage(Utils):
def load_message(self):
"""Loads a message from camera or SD card"""

load_menu = Menu(
self.ctx,
[
(t("Load from camera"), lambda: None),
(
t("Load from SD card"),
None if not self.has_sd_card() else lambda: None,
),
(t("Back"), lambda: None),
],
)
index, _ = load_menu.run_loop()
load_method = self.load_method()

if index == 2:
if load_method > LOAD_FROM_SD:
return (None, None, "")

if index == 0:
if load_method == LOAD_FROM_CAMERA:
data, qr_format = self.capture_qr_code()
return (data, qr_format, "")

# If index == 1
# If load_method == LOAD_FROM_SD
message_filename, data = self.load_file(prompt=False)
return (data, FORMAT_NONE, message_filename)

Expand Down
23 changes: 17 additions & 6 deletions src/krux/pages/home_pages/wallet_descriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
from .. import (
Page,
MENU_CONTINUE,
LOAD_FROM_CAMERA,
LOAD_FROM_SD,
)
from ...display import DEFAULT_PADDING, BOTTOM_PROMPT_LINE
from ...krux_settings import t
Expand All @@ -42,7 +44,13 @@ def wallet(self):
"""Handler for the 'wallet descriptor' menu item"""
title = t("Wallet output descriptor")
self.ctx.display.clear()
if not self.ctx.wallet.is_loaded():
if self.ctx.wallet.key is None:
# No key loaded, so it's being called from tools -> descriptor addresses
text = t("Load a trusted wallet descriptor to view addresses?")
text += "\n" + t("(watch-only)")
if self.prompt(text, self.ctx.display.height() // 2):
return self._load_wallet()
elif not self.ctx.wallet.is_loaded():
text = t("Wallet output descriptor not found.")
self.ctx.display.draw_centered_text(text)
if self.prompt(t("Load one?"), BOTTOM_PROMPT_LINE):
Expand Down Expand Up @@ -72,9 +80,12 @@ def wallet(self):
return MENU_CONTINUE

def _load_wallet(self):
wallet_data, qr_format = self.capture_qr_code()

persisted = None
if wallet_data is None:
load_method = self.load_method()
if load_method == LOAD_FROM_CAMERA:
wallet_data, qr_format = self.capture_qr_code()
elif load_method == LOAD_FROM_SD:
# Try to read the wallet output descriptor from a file on the SD card
qr_format = FORMAT_NONE
try:
Expand All @@ -87,11 +98,11 @@ def _load_wallet(self):
persisted = True
except OSError:
pass
else:
persisted = False
else: # Cancel
return MENU_CONTINUE

if wallet_data is None:
# Both the camera and the file on SD card failed!
# Camera or SD card loading failed!
self.flash_error(t("Failed to load output descriptor"))
return MENU_CONTINUE

Expand Down
Loading

0 comments on commit a54026a

Please sign in to comment.