web3j
web3j copied to clipboard
Transaction MessageDecode exception
Transaction MessageDecode exception
For any unconfirmed transaction in the pending pool, we have been getting a messageDecode exception.
Steps To Reproduce
We are using web3j 4.8.4 and getting a transaction object fo transactions recently been added to the pending pool (example data found here: https://etherscan.io/txsPending?&so)
Expected behavior
Web3js returns a transaction object (with a few params set to null) in this case (https://web3js.readthedocs.io/en/v1.2.0/web3-eth.html#gettransaction)
Actual behavior
We get a messageDecode exception for Block Number & Block Hash
Environment
- Web3j version: 4.8.4
- geth v1.10.1 node (i.e. latest)
- Java web3j version
Additional context
Using ethGetTransactionByHash
"message": "JSON mapping problem: io.overledger.standards.transaction.TransactionResponse["transaction"]->io.overledger.standards.transaction.Transaction["nativeData"]->org.web3j.protocol.core.methods.response.Transaction["blockNumber"]; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Value must be in format 0x[1-9]+[0-9]* or 0x0 (through reference chain: io.overledger.standards.transaction.TransactionResponse["transaction"]->io.overledger.standards.transaction.Transaction["nativeData"]->org.web3j.protocol.core.methods.response.Transaction["blockNumber"])",
H!
I've tried that on web3j core version 4.8.1 and 4.9.6 .
I was calling txPoolContent() and once then I called getBlockNumber() on pending transaction which resulted in an exception:
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) at org.web3j.protocol.core.methods.response.Transaction.getBlockNumber(Transaction.java:175)
IMO the assumption is that blockNumber cannot be null and that is why it fails. There need to be a code change in Transaction.getBlockNumber() to either return Optional or null otherwise it will fail.