additional safety around "wallet_derivation_path"

This commit is contained in:
kdmukai
2023-08-21 18:46:16 -05:00
parent 096b4902bd
commit bd7b25ed98
+7 -2
View File
@@ -142,7 +142,6 @@ def parse_derivation_path(derivation_path: str) -> dict:
}
details = dict()
details["wallet_derivation_path"] = "/".join(sections[:-2])
details["script_type"] = lookups["script_types"].get(sections[1])
if not details["script_type"]:
details["script_type"] = SettingsConstants.CUSTOM_DERIVATION
@@ -153,13 +152,19 @@ def parse_derivation_path(derivation_path: str) -> dict:
details["is_change"] = sections[-2] == "1"
else:
details["is_change"] = None
# Check if there's a standard address index
if sections[-1].isdigit():
details["index"] = int(sections[-1])
else:
details["index"] = None
if details["is_change"] is not None and details["index"] is not None:
# standard change and addr index; safe to truncate to the wallet level
details["wallet_derivation_path"] = "/".join(sections[:-2])
else:
details["wallet_derivation_path"] = None
details["clean_match"] = True
for k, v in details.items():
if v is None: