web3j icon indicating copy to clipboard operation
web3j copied to clipboard

ethGetTransactionByHash(hash) not returning correctly for a transaction not yet in a block

Open lukerQuant opened this issue 2 years ago • 3 comments

GetTransactionByHash unconfirmed transaction pool bug

Steps To Reproduce

use web3j.ethGetTransactionByHash(hash) for a hash of a transaction broadcast to the network but not yet in a block

Expected behavior

You should be able to retrieve the transaction information.

Actual behavior

There is a issue with the blockNumber parameter...->

org.web3j.protocol.core.methods.response.Transaction["blockNumber"])] with root cause

org.web3j.exceptions.MessageDecodingException: Value must be in format 0x[1-9]+[0-9]* or 0x0 at org.web3j.utils.Numeric.decodeQuantity(Numeric.java:48) ~[utils-4.8.7.jar:na] at org.web3j.protocol.core.methods.response.Transaction.getBlockNumber(Transaction.java:123) ~[core-4.8.7.jar:na]

Environment

  • Web3j v4.8.7
  • Java 11
  • MacOs Monterey v12.0.1

Additional context

N/A

lukerQuant avatar Mar 04 '22 16:03 lukerQuant

I came across the same problem. As a workaround I made a extension function which is parsing raw value number in my case in NewHead:

val NewHead.blockNumber: Long
    get() = this.number.trimStart('0', 'x').toLongOrNull(16)
        ?: throw IllegalArgumentException("Could not parse block number as number. Raw number: ${this.number} block hash: ${this.hash}")

Very same applies to the timestamps and transactionIndexes

ruXlab avatar Mar 05 '22 16:03 ruXlab

我也遇到了同样的问题,超过10分钟无法获取到交易详情。 I also encountered the same problem. I couldn't get the transaction details for more than 10 minutes.

dingan-work avatar Mar 14 '22 03:03 dingan-work

Is anyone going to be assigned to implement this bug fix @conor10 ?

lukerQuant avatar Apr 20 '22 08:04 lukerQuant

is it fixed?

ronaldoguedess avatar Nov 03 '22 22:11 ronaldoguedess

hey, @lukerQuant @lukerQuant we are going through a long backlog of issues to close for web3j, has this issue been reproduced recently using the latest web3j version v4.9.4?

mohamedelshami avatar Nov 04 '22 07:11 mohamedelshami

Hi @mohamedelshami we haven't been able to reproduce it in the latest version so (unless it was a very particular edge case), it seems to have been resolved.

Thanks

lukerQuant avatar Nov 04 '22 09:11 lukerQuant