Address Validation
Tidecoin address validation is network-specific. A valid mainnet address can be invalid on testnet or regtest because the Base58 prefixes and witness HRPs differ. Validators must check both the encoding checksum and the destination structure.
This page is for application and exchange integrations. The canonical protocol specification is Address Formats.
Network parameters
| Network | P2PKH prefix | P2SH prefix | Alternate P2SH prefix | Witness v0 HRP | PQ witness v1 HRP |
|---|---|---|---|---|---|
| Mainnet | 33 | 70 | 65 | tbc | q |
| Testnet | 92 | 132 | 127 | ttbc | tq |
| Regtest | 117 | 186 | 122 | rtbc | rq |
The node decoder accepts both script-hash prefixes for the selected
network. The encoder uses the alternate script-hash prefix for
ScriptHash destinations.
Accepted address families
| Family | Encoding | Checksum | Payload rule | Mainnet use |
|---|---|---|---|---|
| Key hash | Base58Check | Base58Check | Network P2PKH prefix plus 20-byte HASH160 payload | Live |
| Script hash | Base58Check | Base58Check | Network P2SH prefix plus 20-byte HASH160 payload | Live |
| Witness v0 key hash | bech32 | bech32 | HRP plus witness version 0 plus 20-byte program | Live |
| Witness v0 script hash | bech32 | bech32 | HRP plus witness version 0 plus 32-byte program | Live |
| PQ witness v1 script hash | bech32m | bech32m | PQ HRP plus witness version 1 plus 64-byte program | Built; mainnet spendability is AuxPoW-gated |
Do not accept a PQ HRP with witness version 0. Do not accept a legacy
witness HRP with witness version 1. Do not accept bech32 for PQ witness
v1 or bech32m for legacy witness v0.
Validation algorithm
Use this order:
- Select the target network first: mainnet, testnet, or regtest.
- Try Base58Check decode with that network’s Base58 prefixes.
- If Base58Check succeeds, require exactly one prefix byte plus a 20-byte payload.
- If Base58Check fails and the string has a matching witness HRP, decode bech32 or bech32m.
- For legacy witness HRPs, require bech32, witness version
0, and a 20-byte or 32-byte program. - For PQ witness HRPs, require bech32m, witness version
1, and a 64-byte program. - Reject all unknown HRPs, unknown prefixes, wrong checksum families, invalid witness versions, invalid padding, and wrong program sizes.
Implementation notes
Treat address validation as parsing, not string matching. Prefix-only
checks such as address.startsWith("q1") are insufficient because they
do not verify the bech32m checksum, witness version, decoded payload, or
network.
If your stack does not use Tidecoin Core directly, port the behavior of
DecodeDestination() from ../tidecoin/src/key_io.cpp. In particular:
| Rule | Reason |
|---|---|
| Decode with the selected network parameters | Avoid accepting testnet/regtest addresses on mainnet. |
| Use bech32 character limits appropriate for the HRP family | PQ witness addresses are longer because the program is 64 bytes. |
| Convert 5-bit bech32 payload data back to 8-bit bytes before checking length | The encoded string length is not the program length. |
Return structured destination type, not only true/false | Deposit systems need to know whether an address is key-hash, script-hash, witness v0, or PQ witness v1. |
Activation policy
Address syntax and spendability are separate.
| Address type | Can parser recognize it? | Should mainnet deposit UI enable it today? |
|---|---|---|
| Base58Check key hash/script hash | Yes | Yes |
| Witness v0 | Yes | Yes, if your wallet flow supports it |
| PQ witness v1 P2WSH-512 | Yes | Not by default while mainnet AuxPoW is disabled |
PQ witness v1 is implemented, but mainnet consensus spendability is tied to AuxPoW activation. An exchange should not silently accept a deposit address type it cannot spend, monitor, or return.
Invalid examples to reject
| Pattern | Why it is invalid |
|---|---|
Mainnet UI receives ttbc..., tq..., rtbc..., or rq... | Wrong network. |
q... bech32 address with witness version 0 | PQ HRP only supports witness version 1. |
tbc... bech32m witness version 0 | Witness v0 must use bech32, not bech32m. |
q... witness version 1 with a 32-byte program | PQ witness v1 requires a 64-byte program. |
| Base58 payload with a known prefix but not 20 bytes after the prefix | Wrong Base58 address length. |
Source of truth
| Topic | Source |
|---|---|
| Network prefixes and HRPs | ../tidecoin/src/kernel/chainparams.cpp |
| Encode/decode behavior | ../tidecoin/src/key_io.cpp |
| Destination script templates | ../tidecoin/src/addresstype.cpp |
| Witness v1 program size and activation flag | ../tidecoin/src/script/interpreter.h |
| Address tests | ../tidecoin/src/test/key_io_tests.cpp |
See also: Protocol / Addresses, Learn / Address Formats, Exchange Integration.