比特币区块链格式

Block Chain 区块链
Magic Number 4 魔数 0xD9B4BEF9
Block Size 4 区块大小  
Block Head 80 区块头  
Block Body - 区块体  
Block Head 区块头
Version 4 区块头版本  
Prev Block Hash 32 前一区块头hash256 hash256(x)=sha256(sha256(x))
Merkle Root Hash 32 交易内容hash256  
Time 4 UNIX时间戳 197011日起的秒数
Bits 4 目标值 用以标注挖矿难度
Nonce 4 随机数 用以调整当前区块头hash
Block Body 区块体
Transactions Counter 1-9 交易单数量 Variable Integer类型
Merkle Root - 交易单内容  
Merkle Root 交易单内容
Transactions 1 - 交易单1 挖矿奖励(Coinbase
Transactions 2 - 交易单2  
 
Transactions n - 交易单n  
Transactions 交易单
Version 4 交易单版本  
Inputs Counter 1-9 收入单数量 Variable Integer类型
Inputs Detail - 收入单内容  
Outputs Counter 1-9 支出单数量 Variable Integer类型
Outputs Detail - 支出单内容  
Lock Time 4 锁定时间 从当前时间起无法用于支出的秒数
Inputs Detail 收入单内容
Inputs 1 - 收入单1  
Inputs 2 - 收入单2  
 
Inputs n - 收入单n  
Outputs Detail 支出单内容
Outputs 1 - 支出单1  
Outputs 2 - 支出单2  
 
Outputs n - 支出单n  
Inputs 收入单
Previous tx Hash 32 引用交易单hash  
Previous Output Index 4 引用交易单支出单索引号  
Inputs Script Length 1-9 收入脚本长度 Variable Integer类型
Inputs Script - 收入脚本  
Sequence Number 4 序列号 0xFFFFFFFF
Outputs 支出单
Amount 8 比特币数量 单位:1=0.00000001比特币
Outputs Script Length 1-9 支出脚本长度 Variable Integer类型
Outputs Script - 支出脚本  
Inputs Script(Coinbase) 收入脚本(挖矿)
Signature Length 1-91 签名长度 0x48
Signature 72 签名  
Outputs Script(Coinbase) 支出脚本(挖矿)
Pubkey Length 1-91 公钥长度 0x41
Pubkey 65 公钥  
OP_CHECKSIG 1 操作符(检查签名) 0xAC
Inputs Script(Standard) 收入脚本(默认)
Signature Length 1-91 签名长度 0x48
Signature 72 签名  
PubKey Length 1-91 公钥长度 0x41
Pubkey 65 公钥  
Outputs Script(Standard) 支出脚本(默认)
OP_DUP 1 操作符(复制堆栈) 0x76
OP_HASH160 1 操作符(哈希160 0xA9
PubkeyHash Length 1-91 公钥hash160长度 0x14
PubkeyHash 20 公钥hash160 hash160(x)=Ripemd160(sha256(x))
OP_EQUALVERIFY 1 操作符(检查相等) 0x87
OP_CHECKSIG 1 操作符(检查签名) 0xAC
备注
下一区块头hash最大值=后三字节(目标值)*2^(8*(第一字节(目标值)-3))
挖矿难度=创世区块链下一区块头hash最大值/下一区块头hash最大值
比特币地址='1'+Base58(0+公钥hash160+前四字节(hash256(0+公钥hash160)))
Variable Integer按第一字节<0xFD,=0xFD,=0xFE,=0xFF分为1,3,5,9四种长度。
如果Variable Integer长度>1,那么值为将第一字节去掉后的剩余部分,否则为第一字节。

猜你喜欢

转载自blog.csdn.net/mengzaishenqiu/article/details/80340877