mirror of
https://github.com/SeedSigner/seedsigner.git
synced 2026-10-05 23:18:25 +00:00
update settings to remove script type since it’s only in the xpub flow
This commit is contained in:
@@ -10,6 +10,4 @@ text_color = ORANGE
|
||||
network = main
|
||||
software = Prompt
|
||||
qr_density = 2
|
||||
script_policy = PKWSH
|
||||
custom_derivation_enabled = False
|
||||
custom_derivation = m/0/0
|
||||
@@ -151,8 +151,6 @@ class Controller(Singleton):
|
||||
ret_val = self.show_wallet_tool()
|
||||
elif ret_val == Path.QR_DENSITY_SETTING:
|
||||
ret_val = self.show_qr_density_tool()
|
||||
elif ret_val == Path.WALLET_POLICY:
|
||||
ret_val = self.show_wallet_policy_tool()
|
||||
elif ret_val == Path.PERSISTENT_SETTINGS:
|
||||
ret_val = self.show_persistent_settings_tool()
|
||||
elif ret_val == Path.DONATE:
|
||||
@@ -524,7 +522,7 @@ class Controller(Singleton):
|
||||
self.buttons.wait_for([B.KEY_RIGHT])
|
||||
|
||||
self.signing_tools_view.draw_modal(["Generating xPub QR ..."])
|
||||
e = EncodeQR(seed_phrase=seed.mnemonic_list, passphrase=seed.passphrase, derivation=derivation, network=self.settings.network, policy=self.settings.script_policy, qr_type=qr_xpub_type, qr_density=self.settings.qr_density, wordlist=self.settings.wordlist)
|
||||
e = EncodeQR(seed_phrase=seed.mnemonic_list, passphrase=seed.passphrase, derivation=derivation, network=self.settings.network, qr_type=qr_xpub_type, qr_density=self.settings.qr_density, wordlist=self.settings.wordlist)
|
||||
|
||||
while e.totalParts() > 1:
|
||||
image = e.nextPartImage(240,240,2)
|
||||
@@ -803,15 +801,6 @@ class Controller(Singleton):
|
||||
|
||||
return Path.SETTINGS_SUB_MENU
|
||||
|
||||
### Show Wallet Policy Tool
|
||||
|
||||
def show_wallet_policy_tool(self):
|
||||
r = self.settings_tools_view.display_wallet_policy_selection()
|
||||
if r is not None:
|
||||
self.settings.script_policy = r
|
||||
|
||||
return Path.SETTINGS_SUB_MENU
|
||||
|
||||
### Show Version Info
|
||||
|
||||
def show_version_info(self):
|
||||
|
||||
@@ -27,7 +27,6 @@ class Path:
|
||||
DONATE = 63
|
||||
WALLET = 64
|
||||
QR_DENSITY_SETTING = 65
|
||||
WALLET_POLICY = 66
|
||||
PERSISTENT_SETTINGS = 67
|
||||
RESET = 68
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ class EncodeQR:
|
||||
self.passphrase = None
|
||||
self.derivation = None
|
||||
self.network = None
|
||||
self.policy = None
|
||||
self.qr_type = None
|
||||
self.qr_density = None
|
||||
self.qr = QR()
|
||||
@@ -41,8 +40,6 @@ class EncodeQR:
|
||||
self.derivation = value
|
||||
elif key == "network":
|
||||
self.network = value
|
||||
elif key == "policy":
|
||||
self.policy = value
|
||||
elif key == "qr_type":
|
||||
self.qr_type = value
|
||||
elif key == "qr_density":
|
||||
@@ -67,9 +64,9 @@ class EncodeQR:
|
||||
elif self.qr_type == QRType.SEEDSSQR:
|
||||
self.encoder = SeedSSQR(self.seed_phrase, self.wordlist)
|
||||
elif self.qr_type == QRType.XPUBQR:
|
||||
self.encoder = XPubQR(self.seed_phrase, self.passphrase, self.derivation, self.network, self.policy, self.wordlist)
|
||||
self.encoder = XPubQR(self.seed_phrase, self.passphrase, self.derivation, self.network, self.wordlist)
|
||||
elif self.qr_type == QRType.SPECTERXPUBQR:
|
||||
self.encoder = SpecterXPubQR(self.seed_phrase, self.passphrase, self.derivation, self.network, self.policy, self.qr_density, self.wordlist)
|
||||
self.encoder = SpecterXPubQR(self.seed_phrase, self.passphrase, self.derivation, self.network, self.qr_density, self.wordlist)
|
||||
else:
|
||||
raise Exception('Encoder Type not Supported')
|
||||
|
||||
@@ -215,7 +212,7 @@ class SeedSSQR:
|
||||
|
||||
class XPubQR:
|
||||
|
||||
def __init__(self, seed_phrase, passphrase, derivation, network, policy, wordlist):
|
||||
def __init__(self, seed_phrase, passphrase, derivation, network, wordlist):
|
||||
self.seed_phrase = seed_phrase
|
||||
self.passphrase = passphrase
|
||||
self.derivation = derivation
|
||||
@@ -259,7 +256,7 @@ class XPubQR:
|
||||
|
||||
class SpecterXPubQR(XPubQR):
|
||||
|
||||
def __init__(self, seed_phrase, passphrase, derivation, network, policy, qr_density, wordlist):
|
||||
def __init__(self, seed_phrase, passphrase, derivation, network, qr_density, wordlist):
|
||||
self.qr_max_fragement_size = 65
|
||||
if qr_density == EncodeQRDensity.LOW:
|
||||
self.qr_max_fragement_size = 40
|
||||
@@ -268,7 +265,7 @@ class SpecterXPubQR(XPubQR):
|
||||
elif qr_density == EncodeQRDensity.HIGH:
|
||||
self.qr_max_fragement_size = 90
|
||||
|
||||
XPubQR.__init__(self, seed_phrase, passphrase, derivation, network, policy, wordlist)
|
||||
XPubQR.__init__(self, seed_phrase, passphrase, derivation, network, wordlist)
|
||||
self.__createParts()
|
||||
|
||||
def __createParts(self):
|
||||
|
||||
@@ -32,8 +32,6 @@ class Settings(Singleton):
|
||||
'network': "main",
|
||||
'software': "Specter Desktop",
|
||||
'qr_density': EncodeQRDensity.MEDIUM,
|
||||
'script_policy': "PKWSH",
|
||||
'custom_derivation_enabled': False,
|
||||
'custom_derivation': 'm/0/0'
|
||||
}
|
||||
}
|
||||
@@ -54,8 +52,6 @@ class Settings(Singleton):
|
||||
self.network = config["wallet"]["network"]
|
||||
self.software = config["wallet"]["software"]
|
||||
self.qr_density = int(config["wallet"]["qr_density"])
|
||||
self.script_policy = config["wallet"]["script_policy"]
|
||||
self.custom_derivation_enabled = config.getboolean("wallet", "custom_derivation_enabled")
|
||||
self.custom_derivation = config["wallet"]["custom_derivation"]
|
||||
|
||||
### persistent settings handling
|
||||
@@ -196,62 +192,14 @@ class Settings(Singleton):
|
||||
else:
|
||||
return "Unknown"
|
||||
|
||||
@property
|
||||
def script_policy(self):
|
||||
return self._data["wallet"]["script_policy"]
|
||||
|
||||
@script_policy.setter
|
||||
def script_policy(self, value):
|
||||
if value in ("PKWSH", "PKWPKH"):
|
||||
self._data["wallet"]["script_policy"] = value
|
||||
self.__writeConfig()
|
||||
else:
|
||||
raise Exception("Unexpected wallet.script_policy settings.ini value")
|
||||
|
||||
@property
|
||||
def policy_name(self):
|
||||
if self.script_policy == "PKWSH":
|
||||
return "Multi Sig"
|
||||
elif self.script_policy == "PKWPKH":
|
||||
return "Single Sig"
|
||||
else:
|
||||
raise Exception("Unexpected Wallet policy value")
|
||||
|
||||
@property
|
||||
def custom_derivation(self):
|
||||
if self._data["wallet"]["custom_derivation_enabled"]:
|
||||
return self._data["wallet"]["custom_derivation"]
|
||||
else:
|
||||
return None
|
||||
|
||||
@property
|
||||
def derivation(self):
|
||||
if self.script_policy == "PKWSH" and self.network == "main":
|
||||
return "m/48'/0'/0'/2'"
|
||||
elif self.script_policy == "PKWSH" and self.network == "test":
|
||||
return "m/48'/1'/0'/2'"
|
||||
elif self.script_policy == "PKWPKH" and self.network == "main":
|
||||
return "m/84'/0'/0'"
|
||||
elif self.script_policy == "PKWPKH" and self.network == "test":
|
||||
return "m/84'/1'/0'"
|
||||
else:
|
||||
raise Exception("Unsupported Derivation Path or Policy")
|
||||
return self._data["wallet"]["custom_derivation"]
|
||||
|
||||
@custom_derivation.setter
|
||||
def custom_derivation(self, value):
|
||||
# TODO: parse and validate custom derivation path
|
||||
self._data["wallet"]["custom_derivation"] = value
|
||||
|
||||
@property
|
||||
def custom_derivation_enabled(self):
|
||||
return self._data["wallet"]["custom_derivation_enabled"]
|
||||
|
||||
@custom_derivation_enabled.setter
|
||||
def custom_derivation_enabled(self, value):
|
||||
if type(value) == bool:
|
||||
self._data["wallet"]["custom_derivation_enabled"] = value
|
||||
else:
|
||||
raise Exception("Unexpected wallet.custom_derivation_enabled settings.ini value")
|
||||
|
||||
@staticmethod
|
||||
def calc_derivation(network, wallet_type, script_type):
|
||||
|
||||
@@ -124,14 +124,13 @@ class MenuView(View):
|
||||
### Settings Menu
|
||||
|
||||
def display_settings_menu(self) -> int:
|
||||
lines = ["... [ Return to Main ]", "Wallet: <wallet>", "Script Policy: <policy>", "Network: <network>", "QR Density: <density>", "Input / Output Tests", "Persistent Settings: <persistent>", "Version Info", "Donate to SeedSigner", "Reset SeedSigner"]
|
||||
lines = ["... [ Return to Main ]", "Wallet: <wallet>", "Network: <network>", "QR Density: <density>", "Input / Output Tests", "Persistent Settings: <persistent>", "Version Info", "Donate to SeedSigner", "Reset SeedSigner"]
|
||||
input = 0
|
||||
|
||||
lines[1] = lines[1].replace("<wallet>", Settings.get_instance().software)
|
||||
lines[2] = lines[2].replace("<policy>", Settings.get_instance().policy_name)
|
||||
lines[3] = lines[3].replace("<network>", Settings.get_instance().network)
|
||||
lines[4] = lines[4].replace("<density>", Settings.get_instance().qr_density_name)
|
||||
lines[6] = lines[6].replace("<persistent>", Settings.get_instance().persistent_display)
|
||||
lines[2] = lines[2].replace("<network>", Settings.get_instance().network)
|
||||
lines[3] = lines[3].replace("<density>", Settings.get_instance().qr_density_name)
|
||||
lines[5] = lines[5].replace("<persistent>", Settings.get_instance().persistent_display)
|
||||
|
||||
# Draw Menu
|
||||
self.selected_menu_num = 1
|
||||
@@ -150,20 +149,18 @@ class MenuView(View):
|
||||
elif self.selected_menu_num == 2:
|
||||
return Path.WALLET
|
||||
elif self.selected_menu_num == 3:
|
||||
return Path.WALLET_POLICY
|
||||
elif self.selected_menu_num == 4:
|
||||
return Path.CURRENT_NETWORK
|
||||
elif self.selected_menu_num == 5:
|
||||
elif self.selected_menu_num == 4:
|
||||
return Path.QR_DENSITY_SETTING
|
||||
elif self.selected_menu_num == 6:
|
||||
elif self.selected_menu_num == 5:
|
||||
return Path.IO_TEST_TOOL
|
||||
elif self.selected_menu_num == 7:
|
||||
elif self.selected_menu_num == 6:
|
||||
return Path.PERSISTENT_SETTINGS
|
||||
elif self.selected_menu_num == 8:
|
||||
elif self.selected_menu_num == 7:
|
||||
return Path.VERSION_INFO
|
||||
elif self.selected_menu_num == 9:
|
||||
elif self.selected_menu_num == 8:
|
||||
return Path.DONATE
|
||||
elif self.selected_menu_num == 10:
|
||||
elif self.selected_menu_num == 9:
|
||||
return Path.RESET
|
||||
raise Exception("Unhandled case")
|
||||
|
||||
|
||||
@@ -62,24 +62,6 @@ class SettingsToolsView(View):
|
||||
else:
|
||||
return None
|
||||
|
||||
### Display Wallet Policy Selection
|
||||
|
||||
def display_wallet_policy_selection(self) -> str:
|
||||
|
||||
lines = ["... [ Return to Settings ]"]
|
||||
lines.append("Multi Sig Native Segwit")
|
||||
lines.append("Single Sig Native Segwit")
|
||||
|
||||
r = self.controller.menu_view.display_generic_selection_menu(lines, "Which Wallet Policy?")
|
||||
if r == 1:
|
||||
return None
|
||||
elif lines[r-1] == "Multi Sig Native Segwit":
|
||||
return "PKWSH"
|
||||
elif lines[r-1] == "Single Sig Native Segwit":
|
||||
return "PKWPKH"
|
||||
else:
|
||||
return None
|
||||
|
||||
def display_persistent_settings(self) -> bool:
|
||||
|
||||
lines = ["... [ Return to Settings ]"]
|
||||
|
||||
+1
-3
@@ -10,6 +10,4 @@ text_color = ORANGE
|
||||
network = main
|
||||
software = Prompt
|
||||
qr_density = 2
|
||||
script_policy = PKWSH
|
||||
custom_derivation_enabled = False
|
||||
custom_derivation = m/0/0
|
||||
custom_derivation = m/0
|
||||
@@ -30,8 +30,6 @@ def test_singleton_get_instance_preserves_state():
|
||||
network = main
|
||||
software = Prompt
|
||||
qr_density = 2
|
||||
script_policy = PKWSH
|
||||
custom_derivation_enabled = False
|
||||
custom_derivation = m/0/0
|
||||
"""
|
||||
config = configparser.ConfigParser()
|
||||
|
||||
@@ -70,7 +70,7 @@ def test_xpub_qr():
|
||||
|
||||
mnemonic = "obscure bone gas open exotic abuse virus bunker shuffle nasty ship dash"
|
||||
|
||||
e = EncodeQR(seed_phrase=mnemonic.split(" "), passphrase="pass", qr_type=QRType.XPUBQR, network="test", policy="PKWPKH", derivation="m/48h/1h/0h/2h", wordlist=bip39.WORDLIST)
|
||||
e = EncodeQR(seed_phrase=mnemonic.split(" "), passphrase="pass", qr_type=QRType.XPUBQR, network="test", derivation="m/48h/1h/0h/2h", wordlist=bip39.WORDLIST)
|
||||
|
||||
assert e.nextPart() == "[c49122a5/48h/1h/0h/2h]vpub5adb6xr5X1yqx2v7qoo5uR32BBCQsj9tRe9zbMRsH8X6tYGE6CzuiF6k3njCyHrU5JWPMsoPwNZd9Bk9Kaqy29izB8PbuU6smtv8HLcTEAv"
|
||||
|
||||
@@ -78,7 +78,7 @@ def test_specter_xpub_qr():
|
||||
|
||||
mnemonic = "obscure bone gas open exotic abuse virus bunker shuffle nasty ship dash"
|
||||
|
||||
e = EncodeQR(seed_phrase=mnemonic.split(" "), passphrase="pass", qr_type=QRType.SPECTERXPUBQR, network="test", policy="PKWPKH", derivation="m/48h/1h/0h/2h", qr_density=EncodeQRDensity.LOW, wordlist=bip39.WORDLIST)
|
||||
e = EncodeQR(seed_phrase=mnemonic.split(" "), passphrase="pass", qr_type=QRType.SPECTERXPUBQR, network="test", derivation="m/48h/1h/0h/2h", qr_density=EncodeQRDensity.LOW, wordlist=bip39.WORDLIST)
|
||||
|
||||
assert e.nextPart() == "p1of4 [c49122a5/48h/1h/0h/2h]vpub5adb6xr5X1yqx"
|
||||
assert e.nextPart() == "p2of4 2v7qoo5uR32BBCQsj9tRe9zbMRsH8X6tYGE6Czui"
|
||||
|
||||
Reference in New Issue
Block a user