Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transaction ID offline calculation #5935

Closed
phil-dolgolev opened this issue Oct 9, 2018 · 3 comments

Comments

@phil-dolgolev
Copy link

commented Oct 9, 2018

Hi!

I need transaction ID before pushing transaction to network. I found some Java implemetation of signing transactions offline, but as I can see, transaction ID is not equal signed hash. How I can calculate it? Which fields of transaction and in wich order I should pack before calculation?

@taokayan

This comment has been minimized.

Copy link
Contributor

commented Oct 9, 2018

transaction id is the hash of the transaction content itself, and it will not be affected by the signature. However, the signature will use the combined information from chain_id, transaction content and content free data as digest, then be signed by the private key. Therefore, transaction ID will never equal to signature. All of these can be found in transaction.cpp.

@taokayan taokayan closed this Oct 9, 2018

@phil-dolgolev

This comment has been minimized.

Copy link
Author

commented Oct 16, 2018

I understand that signature never equal transaction ID, I want completely understand how exactly transaction ID generated

For example, tx: https://tools.cryptokylin.io/#/tx/88aa28ba94c529aa075fa41f1ff7822703b7271b754be0f3c0253cfd973f4d48

Chain ID: 5fff1dae8dc8e2fc4d5b23b2c7665c97f9e9d8edf2b6485a86ba311c25639191
Transactiond content (aka packed_trx): f736bf5b7213e0d1fae1000000000100a6823403ea3055000000572d3ccdcd0190a7a608998c554e00000000a8ed32322590a7a608998c554e90a7a6089996e934102700000000000004454f5300000000047465737400

Neiter SHA256 of ChainID + packed_trx, neither SHA256 of packed_trx not equals Transaction ID
(for example I use this online hash generator: https://passwordsgenerator.net/sha256-hash-generator/)

@jgiszczak

This comment has been minimized.

Copy link
Contributor

commented Oct 16, 2018

The transaction ID is the sha256 of the transaction structure in memory. See the code here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.