Zilliqa / gozilliqa-sdk

Zilliqa golang sdk
GNU General Public License v3.0
33 stars 29 forks source link

Unable to sign transaction #83

Closed euj1n0ng closed 3 years ago

euj1n0ng commented 3 years ago

I faced an issue to be unable to sign a transaction of sending Zil.

The error message was "not checksum Address or bech32". But the target address was a valid address. The transaction payload is as follows:

{ Version: "21823489", SenderPubKey: "0331C7A6FDA8B75D6D5041E8A21F0AC7B76732697C893726A6BF3DB71702660567", ToAddr: "60911ea27a72FD0bF474B0428665F11Ef0cd2189", Amount: "50000000000000", GasPrice: "2000000000", GasLimit: "1", Code: "", Data: "", Priority: false, }

With the same wallet address, I was able to do sending and receiving transaction by using Zilliqa JavaScript library. I am using Zilliqa Go SDK version one (v1.2.0).

Why validator.IsChecksumAddress returns false as for the valid address? I'd like you to correct me if I did something wrong.

Or, do I have to use version 2? Thanks.

renlulu commented 3 years ago

Hey, I have tried your address in unit test, and I see it is fine? image

For your second question, you should put validator.IsChecksumAddress("0x60911ea27a72FD0bF474B0428665F11Ef0cd2189") and it will return true. But this should not be the blocker, as Sign function will handle this for you:

image

euj1n0ng commented 3 years ago

Yes, Sign function prefixes 0x. But still getting the same error message - "not checksum Address or bech32".

renlulu commented 3 years ago

Can you please double check your address in your go code, this is what I use your address to do the transfer:

https://viewblock.io/zilliqa/tx/0x00d08ac49bd43cab083d15a664c852becb6ba8909010e0edab1cec6599c9bdb1?network=testnet

Thanks!

euj1n0ng commented 3 years ago

To say again, I am using v1.2.0. Do I have to update it into the latest version?

Yep, I did see the transactions. Your unit test was Okay.

renlulu commented 3 years ago

Yes, I notice you are on v1.2.0 whose commit hash is 8388182. I was doing the transaction in v1.2.0 too.

euj1n0ng commented 3 years ago

Really weird. What's wrong in my side? Okay, I will check again. Thank you for your responses.

renlulu commented 3 years ago

Maybe you can track the Sign function you are actually using to see if there is anything different.

renlulu commented 3 years ago

The error message is complained by it I believe.

euj1n0ng commented 3 years ago

I will close this issue after resolving it in my side. You mean validator can complain due to not only the target address but also other one. Thank you.

euj1n0ng commented 3 years ago

The problem is in keytools.GetAddressFromPublic, which returns all-lowercased hex address. The payload which caused the error was { ... , ToAddr: "60911ea27a72fd0bf474b0428665f11ef0cd2189", ... }. Please note that there are no capital letters at all. I wrongly mentioned at the time of creating this ticket.

In other words, the all-lowercased wallet address isn't recognized as a valid checksum address by validator.IsChecksumAddress.

I was able to avoid this issue by using bech32 address, instead of using checksum address. I'd like you to handle this issue according to its significance. I haven't any objection if you close this issue at your will freely.

Thank you for your help, @renlulu

renlulu commented 3 years ago

Oh yes, you are right? all lowercased address is not checksumed, i usually call it normal base16 format by the way. so basically we have 3 formats. We are encouraging to use bech32 on top of sdk.