web3j
web3j copied to clipboard
ethGetTransactionByHash(hash) not returning correctly for a transaction not yet in a block
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
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
我也遇到了同样的问题,超过10分钟无法获取到交易详情。 I also encountered the same problem. I couldn't get the transaction details for more than 10 minutes.
Is anyone going to be assigned to implement this bug fix @conor10 ?
is it fixed?
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?
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