Address format
Protocol and consensus12.4.15+

Address format

How a Lotus address is built: the lotus prefix, the network character, the Base58 payload, its checksum, and the two address types.

A Lotus address is a short text that encodes an output script. Mainnet addresses start with lotus_.

Text
lotus_16PSJPVHNWEF4t1nSFefhth6HAtqn6oripT4k9iNv

Structure #

Text
<token><network character><Base58(type || payload || checksum)>
PartSizeValue
Token5 characterslotus, in plain text
Network character1 character_ mainnet, T testnet, R regtest, in plain text
Type1 byteAddress type, see below
PayloadvariableDepends on the type
Checksum4 bytesIntegrity check, see below

Only the type, the payload and the checksum are Base58-encoded. The token and the network character are readable as they are, so you can tell the network from the first six characters:

NetworkPrefix
Mainnetlotus_
Testnet and the Napoleon testnetlotusT
RegtestlotusR

A node rejects an address whose network character is not the one of the network it runs on.

Address types #

Type byteNamePayload
0ScriptThe complete output script (scriptPubKey).
1ReservedNot assigned. An address of this type does not decode.
2TaprootThe 33-byte Taproot commitment (a compressed public key).

Type 0: script #

The payload is the output script itself. The node encodes these two scripts as type 0:

ScriptBytes
Pay to public key hashOP_DUP OP_HASH160 <20-byte hash> OP_EQUALVERIFY OP_CHECKSIG
Pay to script hashOP_HASH160 <20-byte hash> OP_EQUAL

The example at the top of this page decodes to type 0 with the payload 76a914d03a7e6b979b705c931d137762582b27b10f442c88ac, a pay-to-public-key-hash script.

Type 2: Taproot #

The payload is exactly the 33 bytes that follow OP_SCRIPTTYPE OP_1 0x21 in a Taproot output script. Decoding fails when the payload is not 33 bytes or is not a valid compressed public key.

Text
Address:      lotus_JHGFUAijruWK1NG8Nw9UatXG9qmD1E3gq4jYFQMdtMvQ4hvpNzX
Type:         2
Commitment:   039a1cfea64fb7e7c3dbc56516e0fb08c9bc116d4ca10b45881e6987a3541c385a
scriptPubKey: 625121039a1cfea64fb7e7c3dbc56516e0fb08c9bc116d4ca10b45881e6987a3541c385a

Checksum #

The checksum is the first 4 bytes of one SHA-256 over these bytes, in this order:

Text
SHA256( token || network character || type byte || payload )

The token is hashed as its 5 ASCII bytes and the network character as its single ASCII byte (_ is 0x5f). The checksum detects a mistyped address; it does not correct errors.

Encode an address #

  1. Build the payload: the output script (type 0) or the 33-byte commitment (type 2).
  2. Compute the checksum over lotus, the network character, the type byte and the payload.
  3. Base58-encode type || payload || checksum.
  4. Write lotus, the network character, then the Base58 text.

Decode an address #

  1. Find the first character that is an upper-case letter, a digit or _. It is the network character; everything before it is the token.
  2. Base58-decode the rest. The result must be at least 5 bytes.
  3. The first byte is the type, the last 4 bytes are the checksum, the bytes between are the payload.
  4. Recompute the checksum and compare.
  5. Check that the token is lotus and that the network character matches your network.

Check an address with the node #

Shell
lotus-cli validateaddress lotus_JHGFUAijruWK1NG8Nw9UatXG9qmD1E3gq4jYFQMdtMvQ4hvpNzX
JSON
{
  "isvalid": true,
  "address": "lotus_JHGFUAijruWK1NG8Nw9UatXG9qmD1E3gq4jYFQMdtMvQ4hvpNzX",
  "scriptPubKey": "625121039a1cfea64fb7e7c3dbc56516e0fb08c9bc116d4ca10b45881e6987a3541c385a",
  "isscript": false,
  "istaproot": true
}

The node also accepts the internal form taproot:<66 hex characters> wherever it accepts an address.

Source share/www/docs/addresses.md in the lotusd repository
Checked against src/addresses/xaddress.cpp src/addresses/xaddress.h src/key_io.cpp src/script/standard.cpp doc/xaddress.md