从本地beempy钱包提取密码

in STEEM CN/中文4 years ago

自从进入互联网时代,我们生活中的秘密就太多了,难免忘记.我最近又忘记密码了(密钥文件遗失了).

怎么办?

如果我们碰巧用过steem的python 命令行工具 beempy,又碰巧在本地的beempy钱包中导入了密钥.那么,现在我们可以把钱包中的密钥全部导出来,进行备份.
python.jpeg
这里就示范一个到处beempy钱包密码的工具(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))

执行程序:python get_private_keys_in_wallet_beem
执行结果,和预期一致

Sort:  

This post earned a total payout of 1.866$ and 0.933$ worth of author reward that was liquified using @likwid.
Learn more.

Congratulations @dappcoder! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You distributed more than 1000 upvotes. Your next target is to reach 1250 upvotes.

You can view your badges on your Steem Board and compare to others on the Steem Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

To support your work, I also upvoted your post!

Do not miss the last post from @steemitboard:

Valentine's day challenge - Give a badge to your beloved!
Vote for @Steemitboard as a witness to get one more award and increased upvotes!