Open jondoe1337 opened 5 years ago
still couldn't figure out why 4
This is how function signature is encoded in tx.data: hash(methodName)[:4]
.
This is a default fallback function which is triggered when contract address receives value > 0. And, basically, there is no reason to parse this invocation (in terms of Contract.parseInvocation(byte[])
) cause data
array is always empty for such calls.
It may be worth to add a default function as a result of Contract.parseInvocation(byte[])
with empty data
array.
Okay I see the point not to parse the invocation in that case. Therefore I worked around like this:
if (input.isEmpty())
{
Function fallbackFunction = Arrays.stream(c.functions).filter(f -> "".equals(f.name) && f.type == FunctionType.fallback).findFirst()
.orElse(null);
if (fallbackFunction != null)
{
invocation = new Invocation(c, fallbackFunction, new Object[0]);
}
}
It may be worth to add a default function as a result of
Contract.parseInvocation(byte[])
with emptydata
array.
Agree to that, but might have a low priority.
Edit The input parameter of the function
org.ethereum.core.CallTransaction.Contract.parseInvocation(byte[])
is checked for a minimum length of 4 (still couldn't figure out why 4).However if we take this transaction as an example: https://etherscan.io/tx/0xcbbda47e74d692987bcfea5bbd63c4c5ca2b8da9d8c55c19a53c9256343bf4af And the contract: https://etherscan.io/address/0xf069d9f8e394f23878e6beccbdef41c4a957b662#code If I'm correct then the anonymous function in line 190 of the contract was executed in this transaction - which requires no params/names.
But that would also require to let the function
getBySignatureHash
find the anonymous function.