status-im / status-keycard

Our Javacard Implementation for making secure transactions within Status and Ethereum
Apache License 2.0
213 stars 65 forks source link

[API Question] How to get the transaction hash before signing? #46

Closed pjcspro closed 5 years ago

pjcspro commented 5 years ago

Hello everyone,

I have followed the documentation and examples for the keycard integration, and I am very close to have a functional app but I got stuck on the following step:

You should instead calculate the transaction hash, according to the rules of the cryptocurrency you are handling and send that for signature instead.

Is there any example where I can see how to get the transaction hash before signing?

I am currently using Web3j but I am open to any other way of doing that.

Thanks a lot and keep the great work!

bitgamma commented 5 years ago

We still don't have examples using Web3j in the documentation, however we have a test using Web3j internally so you can take a look on how we implemented it. The code is quite old and not very clean (it makes use of reflection in places where it is probably not needed anymore). Have a look and see if it helps you. In any case I plan to clean up the code and/or provide a better example soon.

https://github.com/status-im/status-keycard/blob/add5da6ce8407d5e7144777646e28d1ec95adbb9/src/test/java/im/status/keycard/KeycardTest.java#L1369-L1409

https://github.com/status-im/status-keycard/blob/add5da6ce8407d5e7144777646e28d1ec95adbb9/src/test/java/im/status/keycard/KeycardTest.java#L1644-L1699

pjcspro commented 5 years ago

Yes that helps a lot, thanks!