Warn user if imported key has derivation path different from xpub's depth#2454
Warn user if imported key has derivation path different from xpub's depth#2454k9ert merged 6 commits intocryptoadvance:masterfrom
Conversation
✅ Deploy Preview for specter-desktop-docs canceled.
|
|
@stepansnigirev maybe you can have a look whether that PR goes in the right direction. |
|
for the record: I marked it as draft since I want to ensure users are properly notified - so far it is only printing a line to the logs |
|
Makes sense. We should notify about these inconsistencies at least in the logs. Warnings in the UI would be even better. |
|
I did try to have this notification sent top UI but my frontend knowledge is pretty limited. Since I will not have enough time to investigate UI modification, I will leave it as is, with a simple warning in the logs. |
417b178 to
9a0933f
Compare
There was a problem hiding this comment.
seems like there is off-by-one error, testing with this:
[8c24a510/84h/1h/0h]vpub5Y24kG7ZrCFRkRnHia2sdnt5N7MmsrNry1jMrP8XptMEcZZqkjQA6bc1f52RGiEoJmdy1Vk9Qck9tAL1ohKvuq3oFXe3ADVse6UiTHzuyKx
I've logged derivation_path out:
['m', '84h', '1h', '0h']
So this is where the mismatch comes from, it is counting the root whereas the depth of the xpub is counting from the root. @roshii wanna fix it?
Propagating the error to the UI is simple, just raise an Exception instead of the log statement (or in addition):
raise Exception(
f"xpup has a depth of {depth} while derivation path "
f"indicates the key is {len(derivation_path)} levels deep"
)
This code is taking the exceptions and their strings and propagates them to src/cryptoadvance/specter/server_endpoints/devices.py:
@classmethod
def parse_xpubs(cls, xpubs):
xpubs = xpubs
lines = [l.strip() for l in xpubs.split("\n") if len(l) > 0]
failed = []
keys = []
for line in lines:
try:
keys.append(Key.parse_xpub(line))
except Exception as e:
failed.append(line + "\n" + str(e))
return keys, failed
|
@moneymanolis should be addressed. thanks for the detailed review |
01f79ec to
9f10871
Compare
✅ Deploy Preview for specter-desktop-docs canceled.
|
✅ Deploy Preview for specter-desktop-docs canceled.
|
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Fixes #397