提交 a528bd04 编写于 作者: T Taylor Gerring

Return nil for certain fields on eth_getTransactionByHash when not part of a block

上级 d381d9a7
package rpc
import (
"bytes"
"encoding/json"
"math/big"
// "sync"
......@@ -247,9 +248,12 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
tx, bhash, bnum, txi := api.xeth().EthTransactionByHash(args.Hash)
if tx != nil {
v := NewTransactionRes(tx)
v.BlockHash = newHexData(bhash)
v.BlockNumber = newHexNum(bnum)
v.TxIndex = newHexNum(txi)
// if the blockhash is 0, assume this is a pending transaction
if bytes.Compare(bhash.Bytes(), []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}) != 0 {
v.BlockHash = newHexData(bhash)
v.BlockNumber = newHexNum(bnum)
v.TxIndex = newHexNum(txi)
}
*reply = v
}
case "eth_getTransactionByBlockHashAndIndex":
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册