Beem is a powerful tool by @holger80 that you can use for interacting with many different Graphene Chains, including Hive, Whaleshares and Smoke.
But powerful tools need to be used with caution, and this is absolutly no exception when it comes to cryptocurrency chains.
With Beem you can interact with an accounts wallet.
from beem import Hive
hive.wallet.unlock("mySecretPassword")
hive.wallet.addPrivateKey("myPrivateActiveKey")
# My totally unsecure script code to follow :(
DO NOT USE YOUR KEYS DIRECTLY!
As the example above can be seen as something very easy to make for interactive with your own wallet in Python, just imagine if your script came in other users hands? Maybe your sever got broken into, or you even accidently pushed or shared your script without thinking about your own keys being in there?
Bummer :)
HOW TO USE YOUR KEYS
Of course there are much better ways to deal with this type of sensitive information, and that is to input the keys only when needed.
from beem import Hive
from beem import exceptions
import getpass
hive_nodeList = NodeList()
hive_nodeList.update_nodes()
hive_nodes = hive_nodeList.get_hive_nodes()
hive = Hive(node=hive_nodes)
def checkHiveWallet():
try:
hive.wallet.getActiveKeysForAccount("myAccount")
except exceptions.MissingKeyError:
key = getpass.getpass('Please Supply the Hive Wallet Active Key:')
try:
hive.wallet.addPrivateKey(key)
except exceptions.InvalidWifError:
print("Invalid Key! Please try again.")
checkHiveWallet()
def unlockWallet():
walletPassword = getpass.getpass('Wallet Password:')
try:
hive.wallet.unlock(walletPassword)
except beemstorage.exceptions.WrongMasterPasswordException:
print('Invalid Password, please try again!')
unlockWallet()
if __name__ == "__main__":
unlockWallet()
checkHiveWallet()
# ...... continue your awsome code here :)
With this little script you will
- Be prompted for your wallet password
- Make sure it's a valid password, otherwise it will ask again
- Check if the wallet has the Active keys for the desired account (here
myAccount
) - Ask for the keys if they are not in the wallet already
Your keys have now been added encrypted to the Beem wallet of hive.wallet
without storing them inside your code, and can be used for transfers and other actions.
Congratulations @sc-steemit! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s) :
You can view your badges on your board And compare to others on the Ranking
If you no longer want to receive notifications, reply to this comment with the word
STOP
Support the HiveBuzz project. Vote for our proposal!
I have picked your post for my daily hive voting initiative, Keep it up and Hive On!!
Congratulations @sc-steemit! You received a personal badge!
You can view your badges on your board And compare to others on the Ranking
Do not miss the last post from @hivebuzz: