Merge branch '0_4_6b' into ui_overhaul

This commit is contained in:
kdmukai
2022-02-20 16:28:50 -06:00
5 changed files with 115 additions and 44 deletions
+24 -27
View File
@@ -51,49 +51,45 @@ When you exit the System Configuration tool, you will be prompted to reboot the
### Change the default password
Change the system's password from the default "raspberry". Do do this, use the command:
Change the system's default password from the default "raspberry". Run the command:
```
passwd
```
You will be prompted to enter the current password (raspberry) and then to enter a new password twice. In our prepared release image, the password used is `AirG@pped!` (without quotes).
You will be prompted to enter the current password ("raspberry") and then to enter a new password twice. In our prepared release image, the password used is `AirG@pped!`.
### Install dependencies
Copy this entire box and run it as one command (will take 15-20min to complete):
```
sudo apt-get update && sudo apt-get install -y wiringpi python3-pip python3-numpy python-pil libopenjp2-7 git python3-opencv python3-picamera libatlas-base-dev qrencode
sudo apt-get update && sudo apt-get install -y wiringpi python3-pip \
python3-numpy python-pil libopenjp2-7 git python3-opencv \
python3-picamera libatlas-base-dev qrencode
```
### Install `zbar`
v0.4.6 requires `zbar` at 0.23.x or higher.
`zbar` is "an open source software suite for reading bar codes" (more info here: [https://github.com/mchehab/zbar](https://github.com/mchehab/zbar)).
see: [https://github.com/mchehab/zbar](https://github.com/mchehab/zbar)
SeedSigner requires `zbar` at 0.23.x or higher.
#### Get the `zbar` binary
Download the binary:
```
curl -L http://raspbian.raspberrypi.org/raspbian/pool/main/z/zbar/libzbar0_0.23.90-1_armhf.deb --output libzbar0_0.23.90-1_armhf.deb
```
And then install it:
```
sudo apt install ./libzbar0_0.23.90-1_armhf.deb
```
#### Or install `zbar` by compiling from source
This step isn't necessary. It's only if you prefer to compile `zbar` from source. The whole process takes about 30 minutes.
Cleanup:
```
sudo apt-get install -y autopoint
cd ~/
git clone https://github.com/mchehab/zbar.git
cd zbar
git checkout 0.23.90
```
Configure the compiler settings and compile.
```
autoreconf -vfi && ./configure
make
make check
sudo make install
rm libzbar0_0.23.90-1_armhf.deb
```
### Install the [C library for Broadcom BCM 2835](http://www.airspayce.com/mikem/bcm2835/)
This library "provides functions for reading digital inputs and setting digital outputs, using SPI and I2C, and for accessing the system timers."
Run each of the following individual steps:
```
wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.60.tar.gz
tar zxvf bcm2835-1.60.tar.gz
@@ -102,6 +98,7 @@ sudo ./configure
sudo make && sudo make check && sudo make install
cd ..
rm bcm2835-1.60.tar.gz
sudo rm -rf bcm2835-1.60
```
### Set up `virtualenv`
@@ -121,8 +118,6 @@ Now create the python virtualenv for SeedSigner with these two commands:
```
source ~/.profile
mkvirtualenv --python=python3 seedsigner-env
cd seedsigner
setvirtualenvproject
```
For convenience you can configure your `.profile` to auto-activate the SeedSigner virtualenv when you ssh in. Once again `nano ~/.profile` and add at the end:
@@ -173,7 +168,6 @@ where `pr_123` is any name you want to give to the new branch in your local repo
### Install Python `pip` dependencies:
```
pip3 install -r requirements.txt
cd ..
```
#### `pyzbar`
@@ -207,9 +201,12 @@ _Note: If you'll be testing new code on the SeedSigner, you'll want to omit the
Use `CTRL-X` and `y` to exit and save changes.
Run `sudo systemctl enable seedsigner.service` to enable service on boot. (This will restart the seedsigner code automatically at startup and if it crashes.)
Configure the service to start running (this will restart the seedsigner code automatically at startup and if it crashes):
```
sudo systemctl enable seedsigner.service
```
Now reboot the Raspberry Pi with the command:
Now reboot the Raspberry Pi:
```
sudo reboot
```
+2 -2
View File
@@ -650,7 +650,7 @@ class Controller(Singleton):
# No valid seed yet, If there is a saved seed, ask to use saved seed
if self.storage.num_of_saved_seeds() > 0:
r = self.menu_view.display_generic_selection_menu(["Yes", "No"], "Use Save Seed?")
r = self.menu_view.display_generic_selection_menu(["Yes", "No"], "Use Saved Seed?")
if r == 1: #Yes
slot_num = self.menu_view.display_saved_seed_menu(self.storage,3,None)
if slot_num == 0:
@@ -832,7 +832,7 @@ class Controller(Singleton):
if not seed:
# No valid seed yet, If there is a saved seed, ask to use saved seed
if self.storage.num_of_saved_seeds() > 0:
r = self.renderer.display_generic_selection_menu(["Yes", "No"], "Use Save Seed?")
r = self.menu_view.display_generic_selection_menu(["Yes", "No"], "Use Saved Seed?")
if r == 1: #Yes
slot_num = self.menu_view.display_saved_seed_menu(self.storage,3,None)
if slot_num == 0:
+1 -6
View File
@@ -21,11 +21,6 @@ from .settings import SettingsConstants
logger = logging.getLogger(__name__)
logger = logging.getLogger(__name__)
###
### DecodeQR Class
### Purpose: used to process images or string data from animated qr codes with psbt data to create binary/base64 psbt
@@ -376,7 +371,7 @@ class DecodeQR:
bitstream = ""
for b in s:
bitstream += bin(b).lstrip('0b').zfill(8)
logger.debug(bitstream)
# logger.debug(bitstream)
return QRType.COMPACTSEEDQR
except Exception as e:
+80 -3
View File
@@ -63,9 +63,9 @@ class EncodeQR:
elif self.qr_type == QRType.SPECTERXPUBQR:
self.encoder = SpecterXPubQR(self.seed_phrase, self.passphrase, self.derivation, self.network, self.qr_density, self.wordlist_language_code)
elif self.qr_type == QRType.SEEDQR:
self.encoder = SeedQR(self.seed_phrase, self.wordlist)
self.encoder = SeedQR(self.seed_phrase, self.wordlist_language_code)
elif self.qr_type == QRType.COMPACTSEEDQR:
self.encoder = CompactSeedQR(self.seed_phrase, self.wordlist)
self.encoder = CompactSeedQR(self.seed_phrase, self.wordlist_language_code)
else:
raise Exception('Encoder Type not Supported')
@@ -444,4 +444,81 @@ class URXPubQR(XPubQR):
def isComplete(self):
return self.ur2_encode.is_complete()
return self.sent_complete
class URXPubQR(XPubQR):
def __init__(self, seed_phrase, passphrase, derivation, network, qr_density, wordlist_language_code):
super().__init__(self, seed_phrase, passphrase, derivation, network, wordlist_language_code)
if qr_density == EncodeQR.LOW:
self.qr_max_fragement_size = 10
elif qr_density == EncodeQR.MEDIUM:
self.qr_max_fragement_size = 30
elif qr_density == EncodeQR.HIGH:
self.qr_max_fragement_size = 120
def derivation_to_keypath(path: str) -> list:
arr = path.split("/")
if arr[0] == "m":
arr = arr[1:]
if len(arr) == 0:
return Keypath([],self.root.my_fingerprint, None)
if arr[-1] == "":
# trailing slash
arr = arr[:-1]
for i, e in enumerate(arr):
if e[-1] == "h" or e[-1] == "'":
arr[i] = PathComponent(int(e[:-1]), True)
else:
arr[i] = PathComponent(int(e), False)
return Keypath(arr, self.root.my_fingerprint, len(arr))
origin = derivation_to_keypath(derivation)
self.ur_hdkey = HDKey({ 'key': self.xpub.key.serialize(),
'chain_code': self.xpub.chain_code,
'origin': origin,
'parent_fingerprint': self.xpub.fingerprint})
ur_outputs = []
if len(origin.components) > 0:
if origin.components[0].index == 84: # Native Single Sig
ur_outputs.append(Output([SCRIPT_EXPRESSION_TAG_MAP[404]],self.ur_hdkey))
elif origin.components[0].index == 49: # Nested Single Sig
ur_outputs.append(Output([SCRIPT_EXPRESSION_TAG_MAP[400], SCRIPT_EXPRESSION_TAG_MAP[404]],self.ur_hdkey))
elif origin.components[0].index == 48: # Multisig
if len(origin.components) >= 4:
if origin.components[3].index == 2: # Native Multisig
ur_outputs.append(Output([SCRIPT_EXPRESSION_TAG_MAP[401]],self.ur_hdkey))
elif origin.components[3].index == 1: # Nested Multisig
ur_outputs.append(Output([SCRIPT_EXPRESSION_TAG_MAP[400], SCRIPT_EXPRESSION_TAG_MAP[401]],self.ur_hdkey))
# If empty, add all script types
if len(ur_outputs) == 0:
ur_outputs.append(Output([SCRIPT_EXPRESSION_TAG_MAP[404]],self.ur_hdkey))
ur_outputs.append(Output([SCRIPT_EXPRESSION_TAG_MAP[400], SCRIPT_EXPRESSION_TAG_MAP[404]],self.ur_hdkey))
ur_outputs.append(Output([SCRIPT_EXPRESSION_TAG_MAP[401]],self.ur_hdkey))
ur_outputs.append(Output([SCRIPT_EXPRESSION_TAG_MAP[400], SCRIPT_EXPRESSION_TAG_MAP[401]],self.ur_hdkey))
ur_outputs.append(Output([SCRIPT_EXPRESSION_TAG_MAP[403]],self.ur_hdkey))
ur_account = Account(self.root.my_fingerprint, ur_outputs)
qr_ur_bytes = UR("crypto-account", ur_account.to_cbor())
self.ur2_encode = UREncoder(qr_ur_bytes, self.qr_max_fragement_size, 0)
def seqLen(self):
return self.ur2_encode.fountain_encoder.seq_len()
def nextPart(self) -> str:
return self.ur2_encode.next_part().upper()
def isComplete(self):
return self.ur2_encode.is_complete()
File diff suppressed because one or more lines are too long