steem 账号有四个密码:"owner", "active", "posting", "memo".
各司其职,增加了使用安全,但也带来了密码记忆的困难.
正常情况下,用专门的文件保存一份,但文件也有被损坏的时候.
最近就把账号密码搞丢了,怎么办?
后来想想,用这个这个账号研究 steem 的 python编程时,导入过 beem的本地钱包里面,看看能不能提取出来.
想到这儿,立马开干.
获取本地钱包内私钥(get_private_key_from_beempy_wallet.py):
#!/usr/bin/python
# -*- coding: UTF-8 -*-
# python get_private_key_from_beempy_wallet.py
# python get_private_key_from_beempy_wallet.py sample
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 = input('local wallet password : ')
password = "wallet8password"
stm = shared_steem_instance()
stm.wallet.unlock(password)
private_key = {}
try:
account = sys.argv[1]
except Exception as e:
account = None
if not account:
account = input('steem account username: ')
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('private_key:', json.dumps(private_key, indent=4))
执行程序:python get_private_key_from_beempy_wallet.py