diff --git a/bchain/coins/eth/ethparser.go b/bchain/coins/eth/ethparser.go index 0256099b..391ef2eb 100644 --- a/bchain/coins/eth/ethparser.go +++ b/bchain/coins/eth/ethparser.go @@ -8,7 +8,6 @@ import ( "strconv" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/golang/glog" "github.com/golang/protobuf/proto" "github.com/juju/errors" ) @@ -76,6 +75,12 @@ type rpcReceipt struct { Logs []*rpcLog `json:"logs"` } +type rpcEtcReceipt struct { + GasUsed string `json:"gasUsed"` + Status int `json:"status"` + Logs []*rpcLog `json:"logs"` +} + type completeTransaction struct { Tx *rpcTransaction `json:"tx"` Receipt *rpcReceipt `json:"receipt,omitempty"` @@ -178,14 +183,8 @@ func (p *EthereumParser) GetAddrDescFromAddress(address string) (bchain.AddressD address = address[2:] } if len(address) != EthereumTypeAddressDescriptorLen*2 { - if len(address) != 0 { - glog.Warning("Ignoring address ", address) - } return nil, bchain.ErrAddressMissing } - if len(address)&1 == 1 { - address = "0" + address - } return hex.DecodeString(address) } diff --git a/bchain/coins/eth/ethrpc.go b/bchain/coins/eth/ethrpc.go index cbe24e1d..766a1723 100644 --- a/bchain/coins/eth/ethrpc.go +++ b/bchain/coins/eth/ethrpc.go @@ -529,7 +529,7 @@ func (b *EthereumRPC) GetTransaction(txid string) (*bchain.Tx, error) { return nil, errors.Annotatef(err, "txid %v", txid) } } else { - // non mempool tx - we must read the block header to get the block time + // non mempool tx - read the block header to get the block time raw, err := b.getBlockRaw(tx.BlockHash, 0, false) if err != nil { return nil, err @@ -545,9 +545,24 @@ func (b *EthereumRPC) GetTransaction(txid string) (*bchain.Tx, error) { return nil, errors.Annotatef(err, "txid %v", txid) } var receipt rpcReceipt - err = b.rpc.CallContext(ctx, &receipt, "eth_getTransactionReceipt", hash) - if err != nil { - return nil, errors.Annotatef(err, "txid %v", txid) + if b.isETC { + var etcReceipt rpcEtcReceipt + err = b.rpc.CallContext(ctx, &etcReceipt, "eth_getTransactionReceipt", hash) + if err != nil { + return nil, errors.Annotatef(err, "txid %v", txid) + } + receipt.GasUsed = etcReceipt.GasUsed + receipt.Logs = etcReceipt.Logs + if etcReceipt.Status == 0 { + receipt.Status = "0x0" + } else { + receipt.Status = "0x1" + } + } else { + err = b.rpc.CallContext(ctx, &receipt, "eth_getTransactionReceipt", hash) + if err != nil { + return nil, errors.Annotatef(err, "txid %v", txid) + } } n, err := ethNumber(tx.BlockNumber) if err != nil { diff --git a/db/rocksdb_ethereumtype.go b/db/rocksdb_ethereumtype.go index 66f8aeb9..2f9d5018 100644 --- a/db/rocksdb_ethereumtype.go +++ b/db/rocksdb_ethereumtype.go @@ -72,9 +72,7 @@ func (d *RocksDB) GetAddrDescContracts(addrDesc bchain.AddressDescriptor) (*Addr }) buf = buf[eth.EthereumTypeAddressDescriptorLen+l:] } - return &AddrContracts{ - EthTxs: et, - Contracts: c}, nil + return &AddrContracts{EthTxs: et, Contracts: c}, nil } func findContractInAddressContracts(contract bchain.AddressDescriptor, contracts []AddrContract) (int, bool) {