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

fix(signing): do not drop shardID for rlp encoding #39

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

MaxMustermann2
Copy link
Collaborator

@MaxMustermann2 MaxMustermann2 commented Oct 19, 2022

This change only impacts chainId >= 1666600000.

@MaxMustermann2
Copy link
Collaborator Author

Example of a signing by this corrected method is below. Note that the correction is independent of harmony-one/go-sdk#295, which adds the ability for a data field to hmy which is not used here.

$ wget -O hmy https://harmony.one/hmycli
$ chmod +x hmy
$ ./hmy transfer --offline-sign --nonce=0 --from=one1r8n7xah8cgfm0el8u3kvwzja6zrd4le2ntjy82 --to=one1r8n7xah8cgfm0el8u3kvwzja6zrd4le2ntjy82 --amount=1 --gas-limit=21000 --gas-price=100 --from-shard 0 --to-shard 1 --chain-id=1666600000 | jq '.[0] | ."raw-transaction"'
"0xf8728085174876e80082520880019419e7e376e7c213b7e7e7e46cc70a5dd086daff2a880de0b6b3a76400008084c6ac98a3a0322cca082c3ca0a1d9ad5fffb4dc0e09ade49b4b0e3b0c9dfa5f6288bc7363d6a05604874964abaaf364e8b10108e8bfed5561c341aa5e4abb92b2c6f4c009ef4c"

Same with Python

#!/usr/bin/python3

from pyhmy import signing

transaction_dict = {
    "chainId": 1666600000,
    "gas": 21000,
    "gasPrice": 100000000000,
    "nonce": 0,
    "shardID": 0,
    "to": "0x19e7e376e7c213b7e7e7e46cc70a5dd086daff2a",
    "toShardID": 1,
    "value": 1000000000000000000,
}
signed_tx = signing.sign_transaction(
    transaction_dict,
    "0x1111111111111111111111111111111111111111111111111111111111111111",
)
print( signed_tx.rawTransaction.hex() )
0xf8728085174876e80082520880019419e7e376e7c213b7e7e7e46cc70a5dd086daff2a880de0b6b3a76400008084c6ac98a3a0322cca082c3ca0a1d9ad5fffb4dc0e09ade49b4b0e3b0c9dfa5f6288bc7363d6a05604874964abaaf364e8b10108e8bfed5561c341aa5e4abb92b2c6f4c009ef4c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant