// see https://cryptonote.org/cns/cns007.txt to understand address more
type Address struct {
    Network   uint64
    SpendKey  crypto.Key // these are public keys only
    ViewKey   crypto.Key // these are public keys only
    PaymentID []byte     //integrated payment id is 8 bytes
    // 8 byte version is encrypted on the blockchain
    // 32 byte version is dumped on the chain openly
}

const ChecksumLength = 4

type Checksum [ChecksumLength]byte

地址由 5 部分组成,其中 Network、SpendKey、ViewKey 部分为必需项,PaymentID 和 Checksum 为可选项。

prefix SpendKey ViewKey PaymentID checksum
前缀 花费密钥 查看密钥 备注 校验和
必需 必需 必需 非必需 必需
1 字节,2 字符 32 字节,64 字符 32 字节,64 字符 8 字节或 32 字节 4 字节,8 字符

Network 1 字节,2 字符

SpendKey 32 字节,64 字符

ViewKey 32 字节,64 字符

ChecksumLength 4 字节,8 字符

prefix, a.SpendKey[:], a.ViewKey[:], checksum[:]

总长度 138(如果包含 PaymentID,即为集成地址,会更长)

prefix, a.SpendKey[:], a.ViewKey[:], a.PaymentID, checksum[:]

PaymentID 一般为 8 字节,16 字符。(此时总长度为 154)

                                         Keccak
                      +-----------------------------------+
                      |                                   |
                      |                                   V
   +---------+-------------+-------------+   +----------+--------------+
   | Public  |             |             |   | Checksum |              |
   | address |      A      |      B      |   |  (first  |    Unused    |
   | prefix  |             |             |   | 4 bytes) |              |
   +---------+-------------+-------------+   +----------+--------------+

   +<-------------------------------------------------->+
                              |
                              | Base58
                              V
                   +--------------------+
                   | CryptoNote Address |
                   +--------------------+

可转账到“指定”地址,但构建交易时,程序会自动计算出一次性地址,链上不会明文保存任何地址信息。

有了地址,就可以:

  • 开始挖矿/收款
  • 构建交易/转账给其他人
  • 检查交易是否发送给自己、之后解析交易信息

results matching ""

    No results matching ""