Skip to content

Commit

Permalink
<fix>(model): fix transaction jni hash bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
kyonRay committed Mar 26, 2024
1 parent 78b4588 commit eb0ae4d
Showing 1 changed file with 16 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -316,39 +316,22 @@ public String calculateHash(CryptoSuite cryptoSuite) throws ClientException {
*/
public String calculateHash(int cryptoSuiteType) throws ClientException {
try {
// FIXME: core dump in here
// return TransactionStructBuilderJniObj.calcTransactionDataStructHash(
// cryptoSuiteType,
// new TransactionDataV2()
// .buildExtension(getExtension())
// .buildValue(getValue())
// .buildGasPrice(getGasPrice())
// .buildGasLimit(getGasLimit())
// .buildMaxFeePerGas(getMaxFeePerGas())
// .buildMaxPriorityFeePerGas(getMaxPriorityFeePerGas())
// .buildVersion(getVersion())
// .buildGroupId(getGroupID())
// .buildChainId(getChainID())
// .buildTo(getTo())
// .buildNonce(new String(Hex.decode(getNonce())))
// .buildInput(Hex.decode(getInput()))
// .buildAbi(getAbi())
// .buildBlockLimit(getBlockLimit()));
return TransactionBuilderV1JniObj.calcTransactionDataHashWithFullFields(
cryptoSuiteType,
(getVersion() == 0 ? TransactionVersion.V0 : TransactionVersion.V1),
getGroupID(),
getChainID(),
getTo(),
new String(Hex.decode(getNonce())),
Hex.decode(getInput()),
getAbi(),
getBlockLimit(),
getValue(),
getGasPrice(),
getGasLimit(),
getMaxFeePerGas(),
getMaxPriorityFeePerGas());
return new TransactionDataV2()
.buildExtension(getExtension())
.buildValue(getValue())
.buildGasPrice(getGasPrice())
.buildGasLimit(getGasLimit())
.buildMaxFeePerGas(getMaxFeePerGas())
.buildMaxPriorityFeePerGas(getMaxPriorityFeePerGas())
.buildVersion(getVersion())
.buildGroupId(getGroupID())
.buildChainId(getChainID())
.buildTo(getTo())
.buildNonce(new String(Hex.decode(getNonce())))
.buildInput(Hex.decode(getInput()))
.buildAbi(getAbi())
.buildBlockLimit(getBlockLimit())
.calculateHash(cryptoSuiteType);
} catch (Exception e) {
logger.warn(
"calculate hash for the transaction failed, version: {}, transactionHash: {}, error info: {}",
Expand Down

0 comments on commit eb0ae4d

Please sign in to comment.