提交 3a983d24 编写于 作者: T Taylor Gerring

Initial getTransactionReceipt support

上级 6f69b4d6
......@@ -77,6 +77,7 @@ var (
"eth_submitWork": (*ethApi).SubmitWork,
"eth_resend": (*ethApi).Resend,
"eth_pendingTransactions": (*ethApi).PendingTransactions,
"eth_getTransactionReceipt": (*ethApi).GetTransactionReceipt,
}
)
......@@ -596,3 +597,22 @@ func (self *ethApi) PendingTransactions(req *shared.Request) (interface{}, error
return ltxs, nil
}
func (self *ethApi) GetTransactionReceipt(req *shared.Request) (interface{}, error) {
args := new(HashArgs)
if err := self.codec.Decode(req.Params, &args); err != nil {
return nil, shared.NewDecodeParamError(err.Error())
}
rec, _ := self.xeth.GetTxReceipt(common.StringToHash(args.Hash))
// We could have an error of "not found". Should disambiguate
// if err != nil {
// return err, nil
// }
if rec != nil {
v := NewReceiptRes(rec)
return v, nil
}
return nil, nil
}
......@@ -402,6 +402,29 @@ func NewUncleRes(h *types.Header) *UncleRes {
// WorkProved string `json:"workProved"`
// }
type ReceiptRes struct {
TransactionHash *hexdata `json:transactionHash`
TransactionIndex *hexnum `json:transactionIndex`
BlockNumber *hexnum `json:blockNumber`
BlockHash *hexdata `json:blockHash`
CumulativeGasUsed *hexnum `json:cumulativeGasUsed`
GasUsed *hexnum `json:gasUsed`
ContractAddress *hexdata `json:contractAddress`
Logs *[]interface{} `json:logs`
}
func NewReceiptRes(rec *types.Receipt) *ReceiptRes {
if rec == nil {
return nil
}
var v = new(ReceiptRes)
// TODO fill out rest of object
v.CumulativeGasUsed = newHexNum(rec.CumulativeGasUsed)
return v
}
func numString(raw interface{}) (*big.Int, error) {
var number *big.Int
// Parse as integer
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册