Android DApp开发,调用signAndSend hash不一致


(Boliang) #1

使用web3j 中RawTransactionManager发送时,网络返回的txHashRemote 和本地计算的txHashLocal不一致,导致程序报错,其中网络返回的txHashRemote可以查询到该交易。为什么会出现这种情况的?
public EthSendTransaction signAndSend(RawTransaction rawTransaction)
throws IOException {
String hexValue = sign(rawTransaction);
EthSendTransaction ethSendTransaction = web3j.ethSendRawTransaction(hexValue).send();

if (ethSendTransaction != null && !ethSendTransaction.hasError()) {
String txHashLocal = Hash.sha3(hexValue);
String txHashRemote = ethSendTransaction.getTransactionHash();
if (!txHashVerifier.verify(txHashLocal, txHashRemote)) {
throw new TxHashMismatchException(txHashLocal, txHashRemote);
}
}

return ethSendTransaction;
}