Fix ETC handling of transaction receipt

This commit is contained in:
Martin Boehm 2018-12-05 12:26:41 +01:00
parent 0e1725321d
commit 9eb022238d

View File

@ -547,17 +547,26 @@ func (b *EthereumRPC) GetTransaction(txid string) (*bchain.Tx, error) {
} }
var receipt rpcReceipt var receipt rpcReceipt
if b.isETC { if b.isETC {
var rawReceipt json.RawMessage
var etcReceipt rpcEtcReceipt var etcReceipt rpcEtcReceipt
err = b.rpc.CallContext(ctx, &etcReceipt, "eth_getTransactionReceipt", hash) err = b.rpc.CallContext(ctx, &rawReceipt, "eth_getTransactionReceipt", hash)
if err != nil { if err != nil {
return nil, errors.Annotatef(err, "txid %v", txid) return nil, errors.Annotatef(err, "txid %v", txid)
} }
receipt.GasUsed = etcReceipt.GasUsed err = json.Unmarshal(rawReceipt, &etcReceipt)
receipt.Logs = etcReceipt.Logs if err == nil {
if etcReceipt.Status == 0 { receipt.GasUsed = etcReceipt.GasUsed
receipt.Status = "0x0" receipt.Logs = etcReceipt.Logs
if etcReceipt.Status == 0 {
receipt.Status = "0x0"
} else {
receipt.Status = "0x1"
}
} else { } else {
receipt.Status = "0x1" err = json.Unmarshal(rawReceipt, &receipt)
if err != nil {
return nil, errors.Annotatef(err, "unmarshal receipt for txid %v, %v", txid, string(rawReceipt))
}
} }
} else { } else {
err = b.rpc.CallContext(ctx, &receipt, "eth_getTransactionReceipt", hash) err = b.rpc.CallContext(ctx, &receipt, "eth_getTransactionReceipt", hash)