Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

How to compute transaction id? #10

Open
nguyenhuedang opened this issue May 31, 2018 · 0 comments
Open

How to compute transaction id? #10

nguyenhuedang opened this issue May 31, 2018 · 0 comments

Comments

@nguyenhuedang
Copy link

Hi, I wanna know how to compute the transaction hash from a Transaction instance.

I have tried

const hash = byteArray2hexStr(SHA256(tx.getRawData().serializeBinary()));

Because of this implementation in java-tron

System.out.println(
  "txid = " + ByteArray.toHexString(Hash.sha256(transaction.getRawData().toByteArray())));

But my output is different what is in the blockchain.

For example

Transaction hex from byteArray2hexStr(tx.serializeBinary())
0A8A010A024FAB22089DFE403B668BE88E4088AAA3A8BB2C5A69080112650A2D747970652E676F6F676C65617069732E636F6D2F70726F746F636F6C2E5472616E73666572436F6E747261637412340A15A099357684BC659F5166046B56C95A0E99F1265CBD1215A0F8B3D67B96E807B2525E81A6C443C1C6BE00BF1F1880C8AFA0257080F6D6EB879BEA991512410BA65ABC419ED352FD5377A2D02FCE64556ABC6BF10F713A7652C9B2E42DE4F0BC560CA4BFF285BCBCF23A3DA7EAC95CA3B26CBB7BE642060717D7BCAEAA26DC00
My output is
22F1D5CA7C3A6CBC119C294454238340810DCF8651747CB0D53C381E6A6B3E79
The correct one is
5ab4e286e2f8eda49beef85dd662ca76eb68fd4ec26b85d13b4cfb422e5a55eb
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant