-
Notifications
You must be signed in to change notification settings - Fork 300
Added implementation for custom derivation park #916
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -571,21 +571,31 @@ def __init__(self, seed_num: int = None, script_type: str = None, custom_derivat | |
| self.seed = self.controller.storage.seeds[seed_num] | ||
| data["seed_num"] = self.seed | ||
| seed_derivation_override = self.seed.derivation_override(sig_type=SettingsConstants.SINGLE_SIG) | ||
|
|
||
| custom_derivation_details = None | ||
| from seedsigner.helpers import embit_utils | ||
| if self.script_type == SettingsConstants.CUSTOM_DERIVATION: | ||
| derivation_path = self.custom_derivation | ||
| custom_derivation_details = embit_utils.parse_derivation_path(derivation_path) | ||
| elif seed_derivation_override: | ||
| derivation_path = seed_derivation_override | ||
| else: | ||
| from seedsigner.helpers import embit_utils | ||
| derivation_path = embit_utils.get_standard_derivation_path( | ||
| network=self.settings.get_value(SettingsConstants.SETTING__NETWORK), | ||
| wallet_type=SettingsConstants.SINGLE_SIG, | ||
| script_type=self.script_type, | ||
| ) | ||
|
|
||
| xpub_derivation_path = derivation_path | ||
| if custom_derivation_details and custom_derivation_details["wallet_derivation_path"]: | ||
| # If the user entered a full path that includes /change/index, derive | ||
| # from the wallet-level path so we can still enumerate addresses. | ||
| # The receive/change branch is selected later via the UI toggle. | ||
| xpub_derivation_path = custom_derivation_details["wallet_derivation_path"] | ||
|
|
||
| data["derivation_path"] = derivation_path | ||
| data["xpub"] = self.seed.get_xpub(derivation_path, network=network) | ||
| if custom_derivation_details: | ||
| data["custom_derivation_details"] = custom_derivation_details | ||
| data["xpub"] = self.seed.get_xpub(xpub_derivation_path, network=network) | ||
|
|
||
| else: | ||
| data["wallet_descriptor"] = self.controller.multisig_wallet_descriptor | ||
|
|
@@ -675,14 +685,27 @@ def run(self): | |
| if "xpub" in data: | ||
| # Single sig explore from seed | ||
| if "script_type" in data and data["script_type"] != SettingsConstants.CUSTOM_DERIVATION: | ||
| # Standard derivation path | ||
| for i in range(self.start_index, self.start_index + addrs_per_screen): | ||
| address = embit_utils.get_single_sig_address(xpub=data["xpub"], script_type=data["script_type"], index=i, is_change=self.is_change, embit_network=data["embit_network"]) | ||
| addresses.append(address) | ||
| data[addr_storage_key].append(address) | ||
| script_type = data["script_type"] | ||
| index_offset = 0 | ||
|
|
||
| else: | ||
| # TODO: Custom derivation path | ||
| raise Exception(_("Custom Derivation address explorer not yet implemented")) | ||
| custom_derivation_details = data.get("custom_derivation_details") | ||
| if not custom_derivation_details: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This fallback can never execute as |
||
| raise Exception(_("Routing error: missing custom derivation details")) | ||
|
|
||
| script_type = custom_derivation_details["script_type"] | ||
| if script_type == SettingsConstants.CUSTOM_DERIVATION: | ||
| raise Exception(_("Address Explorer does not support non-standard custom script paths")) | ||
|
|
||
| # Keep the user-entered index as the pagination start offset. | ||
| # Intentionally ignore parsed `is_change`: branch selection comes | ||
| # from the current Receive/Change screen selection (`self.is_change`). | ||
| index_offset = custom_derivation_details["index"] if custom_derivation_details["index"] is not None else 0 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| for i in range(self.start_index + index_offset, self.start_index + index_offset + addrs_per_screen): | ||
| address = embit_utils.get_single_sig_address(xpub=data["xpub"], script_type=script_type, index=i, is_change=self.is_change, embit_network=data["embit_network"]) | ||
| addresses.append(address) | ||
| data[addr_storage_key].append(address) | ||
|
|
||
| elif "wallet_descriptor" in data: | ||
| from embit.descriptor import Descriptor | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parse_derivation_path()doessections[2]unconditionally (embit_utils.py). A short custom path like willIndexErrorhere. Could be a follow-up issue since existing callers inseed_views.pyhave the same problem.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I should fix the
parse_derivation_path()then to be safe for length