Validate chain/network parameter consistency to detect unsupported chains#2537
Draft
Validate chain/network parameter consistency to detect unsupported chains#2537
Conversation
✅ Deploy Preview for specter-desktop-docs canceled.
|
Co-authored-by: k9ert <117085+k9ert@users.noreply.github.com>
Co-authored-by: k9ert <117085+k9ert@users.noreply.github.com>
Co-authored-by: k9ert <117085+k9ert@users.noreply.github.com>
Co-authored-by: k9ert <117085+k9ert@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add support for testnet4 in Specter Desktop
Validate chain/network parameter consistency to detect unsupported chains
Feb 5, 2026
al-munazzim
reviewed
Feb 6, 2026
Contributor
al-munazzim
left a comment
There was a problem hiding this comment.
Good workaround for the embit limitation. A few observations:
-
Root cause filed upstream: Created embit#108 - once embit adds testnet4 support, this validation becomes simpler.
-
Fallback to 'main' in node.py could confuse users: If someone connects to a testnet4 node, the node info display will show mainnet parameters while wallet operations fail. Consider: could we show 'unknown/unsupported' in the UI instead of mainnet values?
-
Minor: The function-attribute caching pattern (
validate_network_for_chain._known_chains_text) is unusual. A module-level constant would be more Pythonic:
_KNOWN_CHAINS = frozenset(['main', 'test', 'regtest', ...])
_KNOWN_CHAINS_TEXT = ', '.join(sorted(_KNOWN_CHAINS))- Test coverage is good - covers valid chains and the testnet4 edge case.
Overall: ✅ Approve with minor suggestions. The approach is sound.
This was referenced Feb 7, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Bitcoin Core 28.0+ returns
"chain": "testnet4"for testnet4 networks. embit 0.6.1 doesn't recognize this chain and defaults toelementsregtestwith bech32 prefixert, causing wallets to generate Liquid addresses that Bitcoin Core rejects.Changes
Added
validate_network_for_chain()inhelpers.py: Maps chains to expected bech32 prefixes, detects mismatches when embit returns wrong network parameters (e.g.,ertprefix fortestnet4chain)Applied validation in
Wallet.networkproperty: RaisesSpecterErrorwith actionable message when chain/network mismatch detected, prevents address generation with wrong prefixApplied validation in
Node.network_parameters: Logs warning and falls back to mainnet parameters for node display (wallet operations still fail with clear error)Added tests: Validates correct behavior for supported chains (
main,test,regtest,signet, liquid chains) and proper error detection for unsupported chainsExample
Before:
After:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.