getTransactionHash static method
Implementation
static Hash getTransactionHash(AccountBlockTemplate transaction) {
var versionBytes = BytesUtils.longToBytes(transaction.version);
var chainIdentifierBytes =
BytesUtils.longToBytes(transaction.chainIdentifier);
var blockTypeBytes = BytesUtils.longToBytes(transaction.blockType);
var previousHashBytes = transaction.previousHash.getBytes()!;
var heightBytes = BytesUtils.longToBytes(transaction.height);
var momentumAcknowledgedBytes = transaction.momentumAcknowledged.getBytes();
var addressBytes = transaction.address.getBytes();
var toAddressBytes = transaction.toAddress.getBytes();
var amountBytes =
BytesUtils.bigIntToBytes(BigInt.from(transaction.amount), 32);
var tokenStandardBytes = transaction.tokenStandard.getBytes();
var fromBlockHashBytes = transaction.fromBlockHash.hash;
var descendentBlocksBytes = Hash.digest([]).getBytes();
var dataBytes = Hash.digest(transaction.data).getBytes();
var fusedPlasmaBytes = BytesUtils.longToBytes(transaction.fusedPlasma);
var difficultyBytes = BytesUtils.longToBytes(transaction.difficulty);
var nonceBytes = BytesUtils.leftPadBytes(HEX.decode(transaction.nonce), 8);
var source = BytesUtils.merge([
versionBytes,
chainIdentifierBytes,
blockTypeBytes,
previousHashBytes,
heightBytes,
momentumAcknowledgedBytes,
addressBytes,
toAddressBytes,
amountBytes,
tokenStandardBytes,
fromBlockHashBytes,
descendentBlocksBytes,
dataBytes,
fusedPlasmaBytes,
difficultyBytes,
nonceBytes
]);
return Hash.digest(source);
}