nanmu42 / etherscan-api

:guitar: Golang client for Ethereum Etherscan API (and its families like BscScan) / Golang 以太坊 Etherscan API库(也支持同一家族的BscScan)
MIT License
240 stars 107 forks source link

Etherscan api can return the string "0_0" as the traceId for InternalTx requests #6

Closed BenKnigge closed 6 years ago

BenKnigge commented 6 years ago

I've found a bug.

[Error] json unmarshal outcome: json: cannot unmarshal number 0_0 into Go struct field InternalTx.traceId of type int

To recreate this issue

internalTX, err := etherScanClient.InternalTxByAddress(address, &startBlock, &bestBlock, 1, 0, true)

Address "0x8b7B6C61238088593BF75eEC8FBF58D0a615d30c"

where startBlock is 0 and bestBlock is the current best block of around 6.3 million

The Json returned is huge so I'll only quote the relevant node.

{
  "status": "1",
  "message": "OK",
  "result": [
    {
      "blockNumber": "4244642",
      "timeStamp": "1504704720",
      "hash": "0x67419842db50db416b035163ccefca0a06908677f642a93063c5104d2f8dd011",
      "from": "0x1522900b6dafac587d499a862861c0869be6e428",
      "to": "0x8b7b6c61238088593bf75eec8fbf58d0a615d30c",
      "value": "30000000000000000",
      "contractAddress": "",
      "input": "",
      "type": "call",
      "gas": "403263",
      "gasUsed": "0",
      "traceId": "0_0",
      "isError": "1",
      "errCode": "Bad instruction"
    },

The InternalTx.traceId will need to be a string or the string "0_0" will need to be serialized to an int.

Which method do you prefer?

nanmu42 commented 6 years ago

Good catch!

Let's make it string.

nanmu42 commented 6 years ago

Closed via #7 .