Skip to content

Commit

Permalink
parallelize SD and QR message loading and signing options
Browse files Browse the repository at this point in the history
group home-only pages in a folder
  • Loading branch information
odudex committed Feb 19, 2024
1 parent b0d1e64 commit dc969c1
Show file tree
Hide file tree
Showing 15 changed files with 386 additions and 301 deletions.
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.beta17"
version = "24.04.beta18"
description = "Open-source signing device firmware for Bitcoin"
authors = ["Jeff S <[email protected]>"]

Expand Down
2 changes: 1 addition & 1 deletion src/boot.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def login(ctx_login):

def home(ctx_home):
"""Loads and run the Login page"""
from krux.pages.home import Home
from krux.pages.home_pages.home import Home

if ctx_home.wallet is not None:
while True:
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.beta17"
VERSION = "24.04.beta18"
SIGNER_PUBKEY = "03339e883157e45891e61ca9df4cd3bb895ef32d475b8e793559ea10a36766689b"
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
# THE SOFTWARE.

import gc
from ..krux_settings import t
from ..themes import theme
from ..qr import FORMAT_NONE
from .utils import Utils
from . import (
from ...krux_settings import t
from ...themes import theme
from ...qr import FORMAT_NONE
from ..utils import Utils
from .. import (
Page,
Menu,
MENU_CONTINUE,
Expand Down Expand Up @@ -134,7 +134,7 @@ def list_address_type(self, addr_type=0):

def show_address(self, addr, title="", quick_exit=False):
"""Show addr provided as a QRCode"""
from .qr_view import SeedQRView
from ..qr_view import SeedQRView

seed_qr_view = SeedQRView(self.ctx, data=addr, title=title)
seed_qr_view.display_qr(
Expand Down Expand Up @@ -171,7 +171,7 @@ def scan_address(self, addr_type=0):

addr = None
try:
from ..wallet import parse_address
from ...wallet import parse_address

addr = parse_address(data)
except:
Expand Down
26 changes: 13 additions & 13 deletions src/krux/pages/home.py → src/krux/pages/home_pages/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
# THE SOFTWARE.

import gc
from ..themes import theme
from ..qr import FORMAT_NONE, FORMAT_PMOFN
from ..krux_settings import t
from . import (
from ...themes import theme
from ...qr import FORMAT_NONE, FORMAT_PMOFN
from ...krux_settings import t
from .. import (
Page,
Menu,
MENU_CONTINUE,
Expand Down Expand Up @@ -61,7 +61,7 @@ def mnemonic(self):

def encrypt_mnemonic(self):
"""Handler for Mnemonic > Encrypt Mnemonic menu item"""
from .encryption_ui import EncryptMnemonic
from ..encryption_ui import EncryptMnemonic

Check warning on line 64 in src/krux/pages/home_pages/home.py

View check run for this annotation

Codecov / codecov/patch

src/krux/pages/home_pages/home.py#L64

Added line #L64 was not covered by tests

encrypt_mnemonic_menu = EncryptMnemonic(self.ctx)
return encrypt_mnemonic_menu.encrypt_menu()

Check warning on line 67 in src/krux/pages/home_pages/home.py

View check run for this annotation

Codecov / codecov/patch

src/krux/pages/home_pages/home.py#L66-L67

Added lines #L66 - L67 were not covered by tests
Expand All @@ -75,7 +75,7 @@ def public_key(self):

def wallet(self):
"""Handler for the 'wallet' menu item"""
from .home_pages.wallet_descriptor import WalletDescriptor
from .wallet_descriptor import WalletDescriptor

Check warning on line 78 in src/krux/pages/home_pages/home.py

View check run for this annotation

Codecov / codecov/patch

src/krux/pages/home_pages/home.py#L78

Added line #L78 was not covered by tests

wallet_descriptor = WalletDescriptor(self.ctx)
return wallet_descriptor.wallet()

Check warning on line 81 in src/krux/pages/home_pages/home.py

View check run for this annotation

Codecov / codecov/patch

src/krux/pages/home_pages/home.py#L80-L81

Added lines #L80 - L81 were not covered by tests
Expand Down Expand Up @@ -126,16 +126,16 @@ def load_psbt(self):
return (data, qr_format, "")

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

utils = Utils(self.ctx)
psbt_filename, data = utils.load_file(PSBT_FILE_EXTENSION, prompt=False)
return (data, FORMAT_NONE, psbt_filename)

def sign_psbt(self):
"""Handler for the 'sign psbt' menu item"""
from ..sd_card import (
from ...sd_card import (
PSBT_FILE_EXTENSION,
SIGNED_FILE_SUFFIX,
)
Expand All @@ -152,7 +152,7 @@ def sign_psbt(self):
if not self.prompt(t("Proceed?"), self.ctx.display.bottom_prompt_line):
return MENU_CONTINUE

# Try to read a PSBT from camera
# Load a PSBT
data, qr_format, psbt_filename = self.load_psbt()

if data is None:
Expand All @@ -165,7 +165,7 @@ def sign_psbt(self):
self.ctx.display.draw_centered_text(t("Loading.."))

qr_format = FORMAT_PMOFN if qr_format == FORMAT_NONE else qr_format
from ..psbt import PSBTSigner
from ...psbt import PSBTSigner

signer = PSBTSigner(self.ctx.wallet, data, qr_format)
outputs = signer.outputs()
Expand Down Expand Up @@ -212,7 +212,7 @@ def sign_psbt(self):

self.display_qr_codes(qr_signed_psbt, qr_format)

from .utils import Utils
from ..utils import Utils

utils = Utils(self.ctx)
utils.print_standard_qr(qr_signed_psbt, qr_format, title, width=45)
Expand All @@ -224,7 +224,7 @@ def sign_psbt(self):
# memory management
del signer
gc.collect()
from .files_operations import SaveFile
from ..files_operations import SaveFile

save_page = SaveFile(self.ctx)
save_page.save_file(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

from .utils import Utils
from ..qr import FORMAT_NONE
from ..krux_settings import t, Settings, THERMAL_ADAFRUIT_TXT
from . import (
from ..utils import Utils
from ...qr import FORMAT_NONE
from ...krux_settings import t, Settings, THERMAL_ADAFRUIT_TXT
from .. import (
Page,
Menu,
MENU_CONTINUE,
Expand Down Expand Up @@ -74,7 +74,7 @@ def show_mnemonic(self, mnemonic, suffix=""):
t("Print?\n\n%s\n\n") % Settings().hardware.printer.driver,
self.ctx.display.height() // 2,
):
from .print_page import PrintPage
from ..print_page import PrintPage

print_page = PrintPage(self.ctx)
print_page.print_mnemonic_text(mnemonic, suffix)
Expand Down Expand Up @@ -129,14 +129,14 @@ def display_standard_qr(self):
def display_seed_qr(self, binary=False):
"""Display Seed QR with with different view modes"""

from .qr_view import SeedQRView
from ..qr_view import SeedQRView

seed_qr_view = SeedQRView(self.ctx, binary)
return seed_qr_view.display_qr()

def stackbit(self):
"""Displays which numbers 1248 user should punch on 1248 steel card"""
from .stack_1248 import Stackbit
from ..stack_1248 import Stackbit

stackbit = Stackbit(self.ctx)
word_index = 1
Expand Down Expand Up @@ -164,7 +164,7 @@ def stackbit(self):

def tiny_seed(self):
"""Displays the seed in Tiny Seed format"""
from .tiny_seed import TinySeed
from ..tiny_seed import TinySeed

tiny_seed = TinySeed(self.ctx)
tiny_seed.export()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

from ..krux_settings import t
from . import (
from ...krux_settings import t
from .. import (
Page,
Menu,
MENU_CONTINUE,
MENU_EXIT,
)

from ..sd_card import PUBKEY_FILE_EXTENSION
from ...sd_card import PUBKEY_FILE_EXTENSION

# to start xpub value without the xpub/zpub/ypub prefix
WALLET_XPUB_START = 4
Expand All @@ -45,7 +45,7 @@ def public_key(self):
"""Handler for the 'xpub' menu item"""

def _save_xpub_to_sd(version):
from .files_operations import SaveFile
from ..files_operations import SaveFile

Check warning on line 48 in src/krux/pages/home_pages/pub_key_view.py

View check run for this annotation

Codecov / codecov/patch

src/krux/pages/home_pages/pub_key_view.py#L48

Added line #L48 was not covered by tests

save_page = SaveFile(self.ctx)
xpub = self.ctx.wallet.key.key_expression(version)
Expand Down Expand Up @@ -95,7 +95,7 @@ def _pub_key_qr(version):
:WALLET_XPUB_START
].upper()
xpub = self.ctx.wallet.key.key_expression(version)
from .qr_view import SeedQRView
from ..qr_view import SeedQRView

seed_qr_view = SeedQRView(self.ctx, data=xpub, title=title)
seed_qr_view.display_qr(allow_export=True, transcript_tools=False)
Expand Down
Loading

0 comments on commit dc969c1

Please sign in to comment.