-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
bugA bug in behaviour or functionalityA bug in behaviour or functionality
Description
NullPointerException during encoding when creating a transaction with null data
We are creating a RawTransaction.createTransaction with data = null (data is nullable for a transaction)
Looking at the code data is nullable as null is handled here
web3j/crypto/src/main/java/org/web3j/crypto/transaction/type/LegacyTransaction.java
Line 68 in 1797f5e
| this.data = data != null ? Numeric.cleanHexPrefix(data) : null; |
However during encoding TransactionEncoder.encode we reach this code where nullsafety is not handled
web3j/crypto/src/main/java/org/web3j/crypto/transaction/type/LegacyTransaction.java
Line 93 in 1797f5e
| byte[] data = Numeric.hexStringToByteArray(getData()); |
Internally Numeric.hexStringToByteArray(getData()) throws a NullPointerException as data is null
Steps To Reproduce
TransactionEncoder.encode(
RawTransaction.createTransaction(
BigInteger.ONE,BigInteger.ONE,BigInteger.ONE,"0x0", null
)
)Expected behavior
Encoded Transaction returned
Actual behavior
NullPointerException
Environment
- Web3j 4.12.2 (still present in main)
Additional context
HamedKaramoko
Metadata
Metadata
Assignees
Labels
bugA bug in behaviour or functionalityA bug in behaviour or functionality