Skip to Content
IntegrationsAddress Validation

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

NetworkP2PKH prefixP2SH prefixAlternate P2SH prefixWitness v0 HRPPQ witness v1 HRP
Mainnet337065tbcq
Testnet92132127ttbctq
Regtest117186122rtbcrq

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

FamilyEncodingChecksumPayload ruleMainnet use
Key hashBase58CheckBase58CheckNetwork P2PKH prefix plus 20-byte HASH160 payloadLive
Script hashBase58CheckBase58CheckNetwork P2SH prefix plus 20-byte HASH160 payloadLive
Witness v0 key hashbech32bech32HRP plus witness version 0 plus 20-byte programLive
Witness v0 script hashbech32bech32HRP plus witness version 0 plus 32-byte programLive
PQ witness v1 script hashbech32mbech32mPQ HRP plus witness version 1 plus 64-byte programBuilt; 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:

  1. Select the target network first: mainnet, testnet, or regtest.
  2. Try Base58Check decode with that network’s Base58 prefixes.
  3. If Base58Check succeeds, require exactly one prefix byte plus a 20-byte payload.
  4. If Base58Check fails and the string has a matching witness HRP, decode bech32 or bech32m.
  5. For legacy witness HRPs, require bech32, witness version 0, and a 20-byte or 32-byte program.
  6. For PQ witness HRPs, require bech32m, witness version 1, and a 64-byte program.
  7. 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:

RuleReason
Decode with the selected network parametersAvoid accepting testnet/regtest addresses on mainnet.
Use bech32 character limits appropriate for the HRP familyPQ witness addresses are longer because the program is 64 bytes.
Convert 5-bit bech32 payload data back to 8-bit bytes before checking lengthThe encoded string length is not the program length.
Return structured destination type, not only true/falseDeposit 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 typeCan parser recognize it?Should mainnet deposit UI enable it today?
Base58Check key hash/script hashYesYes
Witness v0YesYes, if your wallet flow supports it
PQ witness v1 P2WSH-512YesNot 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

PatternWhy it is invalid
Mainnet UI receives ttbc..., tq..., rtbc..., or rq...Wrong network.
q... bech32 address with witness version 0PQ HRP only supports witness version 1.
tbc... bech32m witness version 0Witness v0 must use bech32, not bech32m.
q... witness version 1 with a 32-byte programPQ witness v1 requires a 64-byte program.
Base58 payload with a known prefix but not 20 bytes after the prefixWrong Base58 address length.

Source of truth

TopicSource
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.

Last updated on