Crypto currency introduction

in #crypto7 years ago

image
In yesterday's post, I introduced how to export and import private keys and other operations:

Use Drum Account Passwords / How to Export, Import Private Key and Backup Wallet in Web Wallet
However, as a program ape, always feel that landing to landed, point ah point too much trouble, so there is no convenient way to obtain the private key? Well, I admit that I dig the pit has not been filled, slowly fill it later, let me first try to use the account password and python-bitshares direct access to the private key.


(Photo Source: pixabay)

Use the PasswordKey class to get the private key
After some learning and found python-bitshares PasswordKey category

With this class, you can get the corresponding private key account password, a simple example of code is as follows:

from bitsharesbase.account import PasswordKey

account = "test2018"
passwd = "P5JiDXtCaDdCTgCrkXAG2fEzVUjrBxSJbx9MsXXXXXX"
role = "active"

pwkey = PasswordKey (account, passwd, role = role)
private_key = pwkey.get_private ()

print ("Account:", account)
print ("Passwd:", passwd)
print ("PrivateKey:", private_key)
The results are as follows:

We have successfully obtained the Active Private Key corresponding to this account.

In order to verify that we obtain the private key is correct, I visit the website wallet to check the private key:

Contrast the above private key, we can see the result is correct.

How to get the public key
We can already use the PasswordKey class to get the private key, but in order to verify that we obtain the private key is correct, but also specifically landing webpage wallet to check the private key. Is this not superfluous! Since you also need to access the web wallet, then get the private key directly, why use the program generated.

So what's the way to check whether the private key generated by our account is the corresponding private key?
Very simple, compared to the public key on it.

In order to compare the public keys, we need to obtain the public key of the account, and to generate the public key using the program.

The public key of the account can be viewed through the blockchain browser

Above is the public key of this account, let us take Active KEY as an example.

The second half of the above code is updated as follows:

pwkey = PasswordK ...

Coin Marketplace

STEEM 0.17
TRX 0.16
JST 0.029
BTC 76027.52
ETH 2923.44
USDT 1.00
SBD 2.62