export keys from local beempy Wallet

in hive-180932 •  last month  (edited)

Since entering the Internet era, there are so many keys in our life that we can't avoid forgetting. I forgot my password (key file lost) recently.

How to do it?

If we happen to use the beempy command-line tool of steem's Python and import the key into the local beempy wallet, then now we can export all the keys in the wallet for backup.

python.jpeg
Demo for export all keys in beempy wallet (get_private_keys_in_wallet_beem.py):


#!/usr/bin/env python
# -*- coding: UTF-8 -*-

# Export all keys in the local Wallet
# python get_private_keys_in_wallet_beem.py

import sys
import json
from beem import Steem
from beem.instance import shared_steem_instance

# Enter the local wallet password or set value directly in the code
# password = "walletkey"
password = input('local wallet password : ')

stm = shared_steem_instance()
stm.wallet.unlock(password)
accounts = stm.wallet.getAccounts()
account_list = []
for account in accounts:
    if account["name"] not in account_list:
        account_list.append(account["name"])
print("account_list:", account_list)

for account in account_list:
    private_key = {}
    for role in ["owner", "active", "posting", "memo"]:
        try:
            private_key[role] = stm.wallet.getKeyForAccount(account, role)
        except Exception as e:
            print('no', role, ' key in local wallet for', account)

    print(account, ' private_key:', json.dumps(private_key, indent=4))

Run it:python get_private_keys_in_wallet_beem
Results consistent with expectations.

中文版:《从本地beempy钱包提取密码》

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!