Merge remote-tracking branch 'upstream/main' into exit_clear_screen

This commit is contained in:
kdmukai
2021-06-26 12:05:03 -05:00
42 changed files with 129 additions and 129 deletions
+2 -2
View File
@@ -142,7 +142,7 @@ Description=Seedsigner
[Service]
User=pi
WorkingDirectory=/home/pi/seedsigner
WorkingDirectory=/home/pi/seedsigner/src/
ExecStart=/usr/bin/python3 main.py
Restart=always
@@ -171,4 +171,4 @@ sudo reboot
It will take about a minute after the Pi is powered on for the GUI to launch -- be patient!
_Reminder: If you used option #2, [return the guide](babel/README.md) to remove the internet access over USB configuration._
_Reminder: If you used option #2, [return the guide](docs/usb_relay.md) to remove the internet access over USB configuration._
-12
View File
@@ -1,12 +0,0 @@
import sys
sys.path.append('./views')
sys.path.append('./models')
sys.path.append('./helpers')
from controller import Controller
import time
DEBUG = True
controller = Controller()
controller.start(DEBUG)
+12
View File
@@ -0,0 +1,12 @@
import configparser
import sys
import time
from seedsigner.controller import Controller
config = configparser.ConfigParser()
config.read("settings.ini")
controller = Controller(config)
controller.start()
+21 -26
View File
@@ -4,28 +4,23 @@ from multiprocessing import Process, Queue
from subprocess import call
# Internal file class dependencies
from view import View
from menu_view import MenuView
from seed_tools_view import SeedToolsView
from signing_tools_view import SigningToolsView
from settings_tools_view import SettingsToolsView
from io_test_view import IOTestView
from buttons import Buttons, B
from camera_process import CameraProcess
from path import Path
from seed_storage import SeedStorage
from specter_desktop_multisig_wallet import SpecterDesktopMultisigWallet
from blue_vault_wallet import BlueVaultWallet
from sparrow_multisig_wallet import SparrowMultiSigWallet
from generic_ur2_wallet import GenericUR2Wallet
from .views import (View, MenuView, SeedToolsView,SigningToolsView,
SettingsToolsView, IOTestView)
from .helpers import Buttons, B, CameraProcess,Path
from .models import (SeedStorage, SpecterDesktopMultisigWallet, BlueVaultWallet,
SparrowMultiSigWallet, GenericUR2Wallet)
class Controller:
VERSION = "0.4.1a1"
VERSION = "0.4.1"
def __init__(self) -> None:
def __init__(self, config) -> None:
controller = self
# settings
self.DEBUG = config.getboolean("system", "DEBUG")
# Input Buttons
self.buttons = Buttons()
@@ -48,14 +43,19 @@ class Controller:
p = Process(target=CameraProcess.start, args=(self.from_camera_queue, self.to_camera_queue))
p.start()
return
def start(self, debug = False) -> None:
if debug == False:
crash_cnt = 0
def start(self) -> None:
if self.DEBUG:
# Let Exceptions halt execution
try:
self.show_main_menu()
finally:
# Clear the screen when exiting
self.menu_view.display_blank_screen()
else:
# Handle Unexpected crashes by restarting up to 3 times
crash_cnt = 0
while True:
try:
self.show_main_menu()
@@ -70,11 +70,6 @@ class Controller:
crash_cnt += 1
self.menu_view.draw_modal(["Crashed ..."], "", "requires hard restart")
else:
try:
self.show_main_menu()
finally:
self.menu_view.display_blank_screen()
### Menu
+5
View File
@@ -0,0 +1,5 @@
from .buttons import *
from .camera_process import *
from .path import *
from .qr import *
from .ST7789 import *
+7
View File
@@ -0,0 +1,7 @@
from .wallet import * # base class has to be first
from .blue_vault_wallet import *
from .generic_ur2_wallet import *
from .seed_storage import *
from .sparrow_multisig_wallet import *
from .specter_desktop_multisig_wallet import *
from .specter_desktop_single_sig_wallet import *
@@ -1,5 +1,7 @@
from wallet import Wallet
from qr import QR
from . import Wallet
from seedsigner.helpers import QR
from seedsigner.helpers.bcur import (bcur_decode, cbor_decode, bc32decode,
bc32encode, cbor_encode, bcur_encode)
# External Dependencies
from embit.bip39 import mnemonic_to_bytes
@@ -12,7 +14,6 @@ from embit.networks import NETWORKS
from embit import ec
from io import BytesIO
from binascii import unhexlify, hexlify, a2b_base64, b2a_base64
from bcur import bcur_decode, cbor_decode, bc32decode, bc32encode, cbor_encode, bcur_encode
import re
class BlueVaultWallet(Wallet):
@@ -114,7 +115,7 @@ class BlueVaultWallet(Wallet):
images = []
start = 0
stop = self.qrsize
qr_cnt = (len(qrdata) // self.qrsize) + 1
qr_cnt = ((len(data)-1) // self.qrsize) + 1
while cnt < qr_cnt:
part = "UR:BYTES/" + str(cnt+1) + "OF" + str(qr_cnt) + "/" + qrhash + "/" + qrdata[start:stop]
@@ -1,9 +1,12 @@
from wallet import Wallet
from buttons import Buttons, B
from camera_process import CameraProcess
from camera_process import CameraPoll
from view import View
from qr import QR
from . import Wallet
from seedsigner.helpers import Buttons, B, CameraProcess, CameraPoll, QR
from seedsigner.helpers.bcur import bcur_decode, cbor_decode, bc32decode, bc32encode, cbor_encode, bcur_encode
from seedsigner.helpers.ur2.ur_decoder import URDecoder
from seedsigner.helpers.ur2.ur_encoder import UREncoder
from seedsigner.helpers.ur2.cbor_lite import CBOREncoder
from seedsigner.helpers.ur2.ur import UR
from seedsigner.views import View
# External Dependencies
import time
@@ -17,11 +20,6 @@ from embit.networks import NETWORKS
from embit import ec
from io import BytesIO
from binascii import unhexlify, hexlify, a2b_base64, b2a_base64
from bcur import bcur_decode, cbor_decode, bc32decode, bc32encode, cbor_encode, bcur_encode
from ur2.ur_decoder import URDecoder
from ur2.ur_encoder import UREncoder
from ur2.cbor_lite import CBOREncoder
from ur2.ur import UR
import re
import textwrap
@@ -1,6 +1,5 @@
# External Dependencies
from embit.bip39 import mnemonic_to_bytes
from embit.bip39 import mnemonic_from_bytes
from embit.bip39 import mnemonic_to_bytes, mnemonic_from_bytes
from embit import bip39
class SeedStorage:
@@ -1,27 +1,21 @@
from wallet import Wallet
from buttons import Buttons, B
from camera_process import CameraProcess
from camera_process import CameraPoll
from view import View
from qr import QR
from . import Wallet
from seedsigner.helpers import Buttons, B, CameraProcess, CameraPoll, QR
from seedsigner.helpers.bcur import (bcur_decode, cbor_decode, bc32decode,
bc32encode, cbor_encode, bcur_encode)
from seedsigner.helpers.ur2.ur_decoder import URDecoder
from seedsigner.helpers.ur2.ur_encoder import UREncoder
from seedsigner.helpers.ur2.cbor_lite import CBOREncoder
from seedsigner.helpers.ur2.ur import UR
from seedsigner.views import View
# External Dependencies
import time
from embit.bip39 import mnemonic_to_bytes
from embit.bip39 import mnemonic_from_bytes
from embit import bip39
from embit import script
from embit import bip32
from embit import psbt
from embit import bip32, bip39, ec, script, psbt
from embit.bip39 import mnemonic_to_bytes, mnemonic_from_bytes
from embit.networks import NETWORKS
from embit import ec
from io import BytesIO
from binascii import unhexlify, hexlify, a2b_base64, b2a_base64
from bcur import bcur_decode, cbor_decode, bc32decode, bc32encode, cbor_encode, bcur_encode
from ur2.ur_decoder import URDecoder
from ur2.ur_encoder import UREncoder
from ur2.cbor_lite import CBOREncoder
from ur2.ur import UR
import re
import textwrap
@@ -137,13 +131,15 @@ class SparrowMultiSigWallet(Wallet):
self.buttons.trigger_override()
# if all frames have not all been captured, display progress to screen/display
if not self.capture_complete():
if not self.capture_complete() and self.scan_display_working == 0:
self.scan_display_working = 1
View.draw.rectangle((0, 0, View.canvas_width, View.canvas_height), outline=0, fill=0)
tw, th = View.draw.textsize("Collecting QR Codes:", font=View.IMPACT25)
View.draw.text(((240 - tw) / 2, 15), "Collecting QR Codes:", fill="ORANGE", font=View.IMPACT25)
tw, th = View.draw.textsize(str(round(self.percentage_complete * 100)) + "% Complete", font=View.IMPACT22)
View.draw.text(((240 - tw) / 2, 125), str(round(self.percentage_complete * 100)) + "% Complete", fill="ORANGE", font=View.IMPACT22)
View.DispShowImage()
self.scan_display_working = 0
elif self.scan_started_ind == 0:
self.scan_started_ind = 1
@@ -186,7 +182,7 @@ class SparrowMultiSigWallet(Wallet):
images = []
start = 0
stop = self.qrsize
qr_cnt = (len(data) // self.qrsize) + 1
qr_cnt = ((len(data)-1) // self.qrsize) + 1
while cnt < qr_cnt:
part = "p" + str(cnt+1) + "of" + str(qr_cnt) + " " + data[start:stop]
@@ -1,15 +1,10 @@
from wallet import Wallet
from qr import QR
from . import Wallet
from seedsigner.helpers import QR
# External Dependencies
from embit.bip39 import mnemonic_to_bytes
from embit.bip39 import mnemonic_from_bytes
from embit import bip39
from embit import script
from embit import bip32
from embit import psbt
from embit import bip32, bip39, ec, psbt, script
from embit.bip39 import mnemonic_to_bytes, mnemonic_from_bytes
from embit.networks import NETWORKS
from embit import ec
from io import BytesIO
from binascii import unhexlify, hexlify, a2b_base64, b2a_base64
import re
@@ -112,7 +107,7 @@ class SpecterDesktopMultisigWallet(Wallet):
images = []
start = 0
stop = self.qrsize
qr_cnt = (len(data) // self.qrsize) + 1
qr_cnt = ((len(data)-1) // self.qrsize) + 1
while cnt < qr_cnt:
part = "p" + str(cnt+1) + "of" + str(qr_cnt) + " " + data[start:stop]
@@ -1,15 +1,10 @@
from specter_desktop_multisig_wallet import SpecterDesktopMultisigWallet
from wallet import Wallet
from . import SpecterDesktopMultisigWallet
from . import Wallet
# External Dependencies
from embit.bip39 import mnemonic_to_bytes
from embit.bip39 import mnemonic_from_bytes
from embit import bip39
from embit import script
from embit import bip32
from embit import psbt
from embit import bip32, bip39, ec, psbt, script
from embit.bip39 import mnemonic_to_bytes, mnemonic_from_bytes
from embit.networks import NETWORKS
from embit import ec
from io import BytesIO
from binascii import unhexlify, hexlify, a2b_base64, b2a_base64
import re
@@ -1,19 +1,12 @@
# Internal Dependencies
from buttons import Buttons, B
from camera_process import CameraProcess
from camera_process import CameraPoll
from view import View
from seedsigner.helpers import Buttons, B, CameraProcess, CameraPoll
from seedsigner.views import View
# External Dependencies
import time
from embit.bip39 import mnemonic_to_bytes
from embit.bip39 import mnemonic_from_bytes
from embit import bip39
from embit import script
from embit import bip32
from embit import psbt
from embit import bip32, bip39, ec, psbt, script
from embit.bip39 import mnemonic_to_bytes, mnemonic_from_bytes
from embit.networks import NETWORKS
from embit import ec
from io import BytesIO
from binascii import unhexlify, hexlify, a2b_base64, b2a_base64
import textwrap
@@ -56,6 +49,7 @@ class Wallet:
self.percentage_complete = 0
self.scan_started_ind = 0
self.scan_display_working = 0
###
### Required Methods to implement for Child Wallet Class
@@ -115,6 +109,7 @@ class Wallet:
self.controller.to_camera_queue.put(["stop"])
if self.qr_data[0] == "invalid":
return "invalid"
time.sleep(0.5) # give time for camera loop to complete before returning data
return "".join(self.qr_data)
def process_camera_data(self):
@@ -155,7 +150,8 @@ class Wallet:
self.buttons.trigger_override()
# if all frames have not all been captured, display progress to screen/display
if not self.capture_complete():
if not self.capture_complete() and self.scan_display_working == 0:
self.scan_display_working = 1
View.draw.rectangle((0, 0, View.canvas_width, View.canvas_height), outline=0, fill=0)
tw, th = View.draw.textsize("Collecting QR Codes:", font=View.IMPACT22)
View.draw.text(((240 - tw) / 2, 15), "Collecting QR Codes:", fill="ORANGE", font=View.IMPACT22)
@@ -168,6 +164,7 @@ class Wallet:
tw, th = View.draw.textsize("Right to Exit", font=View.IMPACT18)
View.draw.text(((240 - tw) / 2, 215), "Right to Exit", fill="ORANGE", font=View.IMPACT18)
View.DispShowImage()
self.scan_display_working = 0
elif self.scan_started_ind == 0:
self.scan_started_ind = 1
+6
View File
@@ -0,0 +1,6 @@
from .view import * # base class has to be first
from .io_test_view import *
from .menu_view import *
from .seed_tools_view import *
from .settings_tools_view import *
from .signing_tools_view import *
@@ -3,9 +3,9 @@ import threading
from threading import Timer
# Internal file class dependencies
from view import View
from buttons import B
from camera_process import CameraPoll
from . import View
from seedsigner.helpers import B, CameraPoll
class IOTestView(View):
@@ -1,8 +1,7 @@
# Internal file class dependencies
from view import View
from buttons import B
from path import Path
from seed_storage import SeedStorage
from . import View
from seedsigner.helpers import B, Path
from seedsigner.models import SeedStorage
# External Dependencies
import time
@@ -1,12 +1,12 @@
# External Dependencies
from embit.bip39 import mnemonic_to_bytes
from embit.bip39 import mnemonic_from_bytes
from embit import bip39
from embit.bip39 import mnemonic_to_bytes, mnemonic_from_bytes
import time
# Internal file class dependencies
from view import View
from buttons import B
from . import View
from seedsigner.helpers import B
class SeedToolsView(View):
@@ -1,7 +1,7 @@
# SeedSigner file class dependencies
from view import View
from qr import QR
from buttons import B
from . import View
from seedsigner.helpers import B, QR
class SettingsToolsView(View):
@@ -1,10 +1,11 @@
# Internal file class dependencies
from view import View
from buttons import Buttons, B
from . import View
from seedsigner.helpers import Buttons, B
# External Dependencies
import time
class SigningToolsView(View):
def __init__(self, controller, seed_storage) -> None:
@@ -1,11 +1,10 @@
# External Dependencies
from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont
import ST7789
from PIL import Image, ImageDraw, ImageFont
import spidev as SPI
from multiprocessing import Queue
from seedsigner.helpers import ST7789
### Generic View Class to Instatiate Display
### Static Class variables are used for display
### Designed to be inherited for other view classes, but not required
@@ -58,7 +57,7 @@ class View:
# 240x240 display with hardware SPI:
View.bus = 0
View.device = 0
View.disp = ST7789.ST7789(SPI.SpiDev(View.bus, View.device),View.RST, View.DC, View.BL)
View.disp = ST7789(SPI.SpiDev(View.bus, View.device),View.RST, View.DC, View.BL)
View.disp.Init()
self.queue = Queue()
+7
View File
@@ -0,0 +1,7 @@
[system]
DEBUG = True
DEFAULT_LANGUAGE = en
[display]
BACKGROUND_COLOR = #000
TEXT_COLOR = orange