icon-project / icon-sdk-python

ICON SDK for Python
45 stars 45 forks source link

V0.9 Documentation Error #42

Closed pieman64 closed 5 years ago

pieman64 commented 5 years ago

At https://www.icondev.io/v0.9/docs/python-sdk#section-wallet you have the following text:

# Loads a wallet from a key store file
wallet = KeyWallet.load(TEST_PRIVATE_KEY) # bytes of the private key
print("address: ", wallet.get_address()) # Returns an address
print("private key: ", wallet.get_private_key()) # Returns a private key

Please confirm the first line of the code block above is incorrect.

Spl3en commented 5 years ago

What's incorrect ? TEST_PRIVATE_KEY is a constant that you're supposed to replace with your own private key.

pieman64 commented 5 years ago

@Spl3en the first line of the code block states:

# Loads a wallet from a key store file

key store is incorrect, right?

boyeon555 commented 5 years ago

The first line of the code block states seems to make you confused.

Loading a wallet from a private key is correct. TEST_PRIVATE_KEY is a constant you can replace with your own private key in bytes.

pieman64 commented 5 years ago

But the code is nothing to do with a key store file as that would require a path to the file.

I'm not confused by the TEST_PRIVATE_KEY constant in bytes.

pieman64 commented 5 years ago

For version 0.8 the documentation at https://www.icondev.io/docs/python-sdk-1#section-loading-a-wallet-and-storing-the-keystore is:

# Loads a wallet from bytes of the private key
wallet = KeyWallet.load(b'-B\x99...xedy')

# Loads a wallet from a keystore file
wallet = KeyWallet.load("./keystore", "password")

Notice loading a keystore file for V0.8 is totally different for V0.9. V0.9 docs are wrong, right?

boyeon555 commented 5 years ago

How to load a keystore file for V0.9 is totally the same as V0.8. You can load your own wallet with the keystore file or bytes of the private key as below.

# Loads a wallet from bytes of the private key
wallet = KeyWallet.load(b'-B\x99...xedy')

# Loads a wallet from a keystore file
wallet = KeyWallet.load("./keystore", "password")

Loads a wallet from bytes of the private key

Loads a wallet from a keystore file

pieman64 commented 5 years ago

@boyeon555 but look at the first post above and you will see that is NOT what V0.9 docs show.

boyeon555 commented 5 years ago

I think V0.9 docs had been made more simple than the previous version and skipped it. You can refer to README of python SDK.

pieman64 commented 5 years ago

No @boyeon555 the docs are not simpler they are WRONG. Please amend accordingly as new users of the rep will not be able to load a wallet from a keystore with the incorrect code. The code shown is to load a wallet from from a private key!

Spl3en commented 5 years ago

Alright @pieman64, I submitted a pull request to the documentation : https://github.com/icon-project/documentation/pull/25

Please don't hesitate to send a pull request with your patches, it's very easy to do with the GitHub interface without knowing anything about git if you're not familiar with that tool.

pieman64 commented 5 years ago

Thanks for the correction @Spl3en

Spl3en commented 5 years ago

Thanks to you for reporting this issue. 👍