An address is a short string corresponding to some script used to protect a box. Unlike (hex-encoded) binary representation of a script, an address has some useful characteristics:
- Integrity of an address could be checked, as it is incorporating a checksum.
- A prefix of address is showing network and an address type. In particular, the network prefix prevents you from mistakenly sending mainnet tokens to the testnet address.
- An address is using an encoding (namely, Base58) which is avoiding similarly l0Oking characters, friendly to double-clicking and line-breaking in emails.
An address is encoding network type , address type, checksum, and enough information to watch for a particular scripts.
Possible network types are:
Mainnet - 0x00
Testnet - 0x10
Address types are (semantics described below):
- 0x01 - Pay-to-PublicKey(P2PK) address
- 0x02 - Pay-to-Script-Hash(P2SH)
- 0x03 - Pay-to-Script(P2S)
For an address type, we form content bytes as follows:
P2PK - serialized (compressed) public key
P2SH - first 192 bits of the Blake2b256 hash of serialized script bytes
P2S - serialized script
Address examples for testnet:
- 3 - P2PK (3WvsT2Gm4EpsM9Pg18PdY6XyhNNMqXDsvJTbbf6ihLvAmSb7u5RN)
- 8 - P2SH (8UmyuJuQ3FS9ts7j72fn3fKChXSGzbL9WC, 8LnSX95GAWdbDZWJZQ73Uth4uE8HqN3emJ)
- ? - P2S (imdaM2NzX, z4hAmfvfSnQJPChMWzfBzJjpB8ei2HoLCZ2RHTaNArMNHFirdJTc7E)
for mainnet:
- 9 - P2PK (9fRAWhdxEsTcdb8PhGNrZfwqa65zfkuYHAMmkQLcic1gdLSV5vA)
- 2 - P2SH (25qGdVWg2yyYho8uC1pLtc7KxFn4nEEAwD, 23NL9a8ngN28ovtLiKLgHexcdTKBbUMLhH)
- ? - P2S (7bwdkU5V8, BxKBaHkvrTvLZrDcZjcsxsF7aSsrN73ijeFZXtbj4CXZHHcvBtqSxQ)
Prefix byte = network type + address type
checksum = leftmost_4_bytes(blake2b256(prefix byte || content bytes))
address = prefix byte || content bytes || checksum