Repository navigation
Specter-DIY: import xpubs without the 3s timeout, one confirmation per key set, wrong-network handling #2702
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
Merged
k9ert
merged 11 commits into
cryptoadvance:master
from
schnuartz-ai:fix/specter-diy-xpub-timeout
Sep 3, 2026
Merged
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
4e977d8
Don't apply the 3s HWI timeout to Specter DIY xpub requests
schnuartz-ai d331ed7
Potential fix for pull request finding
k9ert e58f6b1
Batch-authorize Specter-DIY xpub export and skip the mismatched network
Schnuartz d9522e3
Wire batch xpub authorization into the actual "Get via USB" flow
Schnuartz 9c618a0
Surface a clear "switch your device to X" message on network mismatch
Schnuartz 92d023e
Match the firmware's wording for the shared testnet coin type
Schnuartz f7384a4
Name the requested network from the path, and handle Liquid
Schnuartz 6787b60
Show the network-mismatch message cleanly in the UI
Schnuartz 843ab83
Address review: cancel aborts, real test keys, path validation
Schnuartz c4aca37
Harden the wrong-network path and the HWI error boundary
Schnuartz 32f1728
Merge branch 'master' into fix/specter-diy-xpub-timeout
k9ert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| """ | ||
| Regression tests for cryptoadvance.specter.devices.hwi.specter_diy.SpecterClient. | ||
|
|
||
| Specter DIY firmware now requires an on-device user confirmation before | ||
| returning an xpub, so get_pubkey_at_path() must not impose the old 3-second | ||
| response timeout (it should wait indefinitely, like sign_tx() already does). | ||
| get_master_fingerprint() stays non-interactive and keeps its short timeout. | ||
|
|
||
| These are pure unit tests against a mocked transport - no bitcoind, no real | ||
| device, no network required. | ||
| """ | ||
| from unittest.mock import MagicMock | ||
|
|
||
| from cryptoadvance.specter.devices.hwi.specter_diy import SpecterClient | ||
|
|
||
|
|
||
| def _client_with_mocked_transport(): | ||
| # ":" in the path selects the (non-connecting-on-init) simulator transport | ||
| client = SpecterClient("127.0.0.1:9999") | ||
| client.chain = "main" | ||
| client.dev.query = MagicMock(return_value="deadbeef") | ||
| return client | ||
|
|
||
|
|
||
| def test_get_pubkey_at_path_does_not_pass_a_timeout(): | ||
| client = _client_with_mocked_transport() | ||
| client.dev.query.return_value = ( | ||
| "tpubD6NzVbkrYhZ4WZaiWHz59q5EQ61bd6dUYfU4ggRWAtNAyyYRNWT6ktJ7UHJEXURvSCVW" | ||
| "shSCLtQ4pnyNSSVUXQfP7yzzKcVXBEeejuSsn7q" | ||
| ) | ||
| client.get_pubkey_at_path("m/84h/0h/0h") | ||
| args, kwargs = client.dev.query.call_args | ||
| # positional call: self.dev.query(data, timeout) - the timeout arg | ||
| # (positional or via kwarg) must be None, i.e. "wait indefinitely" | ||
| passed_timeout = kwargs.get("timeout", args[1] if len(args) > 1 else None) | ||
| assert passed_timeout is None | ||
|
|
||
|
|
||
| def test_get_master_fingerprint_keeps_bounded_timeout(): | ||
| client = _client_with_mocked_transport() | ||
| client.get_master_fingerprint() | ||
| args, kwargs = client.dev.query.call_args | ||
| passed_timeout = kwargs.get("timeout", args[1] if len(args) > 1 else None) | ||
| assert passed_timeout == SpecterClient.TIMEOUT | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.