Skip to content
This repository has been archived by the owner on Jun 27, 2020. It is now read-only.

TransactionSerializer isn't working as expected. #2

Open
arkoc opened this issue Jan 28, 2019 · 1 comment
Open

TransactionSerializer isn't working as expected. #2

arkoc opened this issue Jan 28, 2019 · 1 comment

Comments

@arkoc
Copy link

arkoc commented Jan 28, 2019

After serializing transaction with TransactionSerializer we can't de-serialize result object back to original one.

Expected:
TransactionSerializer should deserialize transaction that is serialized by him.

Actual:
KeyNotFoundException is thrown for txHash key.

As I understood, the reason is that send transaction rpc call isn't accepting "txHash".

Any Ideas, how to fix this? Maybe we can build hash during deserialization, if it isn't set.
Up to contribute the fix.

@zsaladin
Copy link
Owner

zsaladin commented Jan 28, 2019

TransactionSerializer.Deserialize was designed to restore tx data from JsonRPC result. It has txHash. But I agree that serialized tx data by TransactionSerializer can be deserialized to Transaction object.

If you want to contribute the fix I suggest you to use Hasher in IconSDK.Crypto namespace. Hasher.Digest(param) will generate hash based on param. And the param will be a Dictionary<string, object> object which excludes "txHash" and "signature" from txSerialized.

I am summarizing below.

  1. txSerialized has txHash
  • Use it.
  1. txSerialized does not have txhash.
  • Copy txSerialized to new variable(to avoid modifying original data). Then delete signature from copied one. Use Hasher.Digest(coped) as tx hash.

You can see how to use Hasher.Digest in TestTransaction.cs.

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

2 participants