fix: accept tsp recipients on Signet and Testnet4 - #70
Open
kkdao wants to merge 2 commits into
Open
Conversation
BIP 352 assigns one human readable prefix to every test network, so codes written for Testnet, Testnet4 and Signet are indistinguishable once encoded and parsing reports `Network::Testnet` for all three. Callers that check a parsed code against a wallet with `code.network == wallet.network()` consequently reject valid recipients on Signet and Testnet4. What the encoding carries is the prefix, not the exact chain, so expose a predicate that compares prefixes and leave the encoding itself untouched. `Display` now shares that mapping through `hrp_for_network` instead of repeating the match, so the two cannot drift apart. The groups follow this crate's encoder rather than `bitcoin::NetworkKind`: regtest has its own `sprt` prefix here, while `NetworkKind` groups it with the other test networks.
`new-tx --to-sp` compared the parsed code's network to the wallet's with `!=`. Because every test network encodes to the same `tsp` prefix and parsing reports `Network::Testnet` for all of them, a Signet or Testnet4 wallet rejected codes that were written for it, including its own. Compare prefixes through `is_valid_for_network` instead, which is the distinction the encoding carries. The bail also gains a message; it was empty, so the rejection surfaced as an error with no text.
kkdao
force-pushed
the
fix/tsp-network-group-compat
branch
from
August 21, 2026 21:36
01408a9 to
ea4cd0c
Compare
kkdao
marked this pull request as draft
August 21, 2026 21:48
kkdao
marked this pull request as ready for review
August 21, 2026 21:56
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.
Description
Fixes #68
Every test network encodes to the same
tspprefix, so parsing always returnsNetwork::Testnet.sp-cli2 new-tx --to-spcompared that to the wallet's network with!=, so Signet and Testnet4 wallets rejected valid codes, including their own.Adds
SilentPaymentCode::is_valid_for_network, which compares prefixes instead, and uses it insp-cli2. The emptybail!("")next to it gets a message.Notes to the reviewers
Encoding is unchanged — this only changes how compatibility is judged.
prefix_assignment_is_unchangedpins that.The prefix match already in
Display::fmtis lifted intohrp_for_networkand shared, so the two can't drift.Groups follow this crate's encoder, not
bitcoin::NetworkKind, which groups regtest with the other test networks while this crate gives regtest its ownsprt.Tests are in
silentpaymentsrather than next to the CLI becausecli/v2isn't indefault-membersandjust check/just testexclude it, so a test there would never run. I built and lintedcli/v2directly to check this change.Changelog notice
Added:
SilentPaymentCode::is_valid_for_networkandencoding::hrp_for_network.Fixed:
sp-cli2 new-tx --to-sprejected validtsprecipients on Signet and Testnet4.Checklists
All Submissions:
just p(fmt, clippy and test) before committingNew Features:
Bugfixes: