随笔- 53  评论- 0  文章- 0 

从网络协议解析比特币交易的流程

    比特币交易时会向node发送一个Tx数据,交易的头部数据格式如下

 常见的command类型如下所示:

const (
	CmdVersion     = "version"
	CmdVerAck      = "verack"
	CmdGetAddr     = "getaddr"
	CmdAddr        = "addr"
	CmdGetBlocks   = "getblocks"
	CmdInv         = "inv"
	CmdGetData     = "getdata"
	CmdNotFound    = "notfound"
	CmdBlock       = "block"
	CmdTx          = "tx"
	CmdGetHeaders  = "getheaders"
	CmdHeaders     = "headers"
	CmdPing        = "ping"
	CmdPong        = "pong"
	CmdAlert       = "alert"
	CmdMemPool     = "mempool"
	CmdFilterAdd   = "filteradd"
	CmdFilterClear = "filterclear"
	CmdFilterLoad  = "filterload"
	CmdMerkleBlock = "merkleblock"
	CmdReject      = "reject"
	CmdSendHeaders = "sendheaders"
	CmdFeeFilter   = "feefilter"
)

  交易消息的头部command是"tx",交易内容的格式如下:

    

   比特币中对脚本的解析可以参考这个网址

http://www.infoq.com/cn/articles/deep-understanding-of-bitcoin-transaction-script

 

 

 

 

 

 

  

posted on 2018-06-02 17:56 xgcode 阅读(...) 评论(...) 编辑 收藏