use of org.fisco.bcos.web3j.protocol.core.methods.response.SendTransaction in project web3sdk by FISCO-BCOS.
the class RawTransactionManager method signAndSend.
public SendTransaction signAndSend(RawTransaction rawTransaction) throws IOException {
byte[] signedMessage;
if (chainId > ChainId.NONE) {
signedMessage = TransactionEncoder.signMessage(rawTransaction, chainId, credentials);
} else {
signedMessage = TransactionEncoder.signMessage(rawTransaction, credentials);
}
String hexValue = Numeric.toHexString(signedMessage);
SendTransaction sendTransaction = web3j.sendRawTransaction(hexValue).send();
if (sendTransaction != null && !sendTransaction.hasError()) {
String txHashLocal = Hash.sha3(hexValue);
String txHashRemote = sendTransaction.getTransactionHash();
if (!txHashVerifier.verify(txHashLocal, txHashRemote)) {
throw new TxHashMismatchException(txHashLocal, txHashRemote);
}
}
return sendTransaction;
}
Aggregations