MMoSP003C- steem-python 定制修改密码的工具

in #esteemlast year (edited)

MMoSP003C- steem-python 定制修改密码的工具

一般我们从官网 注册账号,相对比较安全.

密码丢失后(被盗后),可以找 帮助恢复.



我们一般登陆,在官方在线钱包中 修改密码,但就比较麻烦,不如直接命令行用工具改.


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

# 修改 steem 帐号密码
# python MMoSP003_customize_a_tools_for_change_keys acc wif
# acc:steem账户名
# wif:steem账户名旧的 owner private key

import sys
import json
import steem
import steembase
from steem.steemd import Steemd
from steem.instance import set_shared_steemd_instance
from steembase.account import PasswordKey, BrainKey
from steembase import operations

# 必须参数
    acc = sys.argv[1]
    wif = sys.argv[2]
except Exception as e:
print('acc:', acc)
print('wif:', wif)

steemd_api_nodes = [
stm = Steemd(nodes=steemd_api_nodes)

# 生成一套新密码
bk = BrainKey()
brainkey = bk.get_brainkey()
print('brain key:', str(brainkey))
prikey = str(bk.get_private())
print('private key:', str(prikey))
pubkey = format(bk.get_public(), "STM")
print('public key:', str(pubkey))

# 获取整套密钥
posting_key = PasswordKey(acc, pubkey, role="posting")
active_key = PasswordKey(acc, pubkey, role="active")
memo_key = PasswordKey(acc, pubkey, role="memo")
owner_key = PasswordKey(acc, pubkey, role="owner")
# 提取整套密钥中的私钥
active_privkey = active_key.get_private_key()
posting_privkey = posting_key.get_private_key()
owner_privkey = owner_key.get_private_key()
memo_privkey = memo_key.get_private_key()
print('posting_privkey:', str(posting_privkey))
print('active_privkey:', str(active_privkey))
print('owner_privkey:', str(owner_privkey))
print('memo_privkey:', str(memo_privkey))
# 提取整套密钥中的公钥
# active_pubkey = active_key.get_public_key()
# owner_pubkey = owner_key.get_public_key()
# posting_pubkey = posting_key.get_public_key()
memo_pubkey = memo_key.get_public_key()
print('memo_pubkey:', str(memo_pubkey))

    old_owner_key = str(PasswordKey(acc, wif, "owner").get_private_key())

    client = steem.Steem(nodes=steemd_api_nodes, keys=[old_owner_key])
    #client = steem.Steem(nodes=[''], keys=[wif])

    new_pubkey = {}
    for role in ["owner", "active", "posting", "memo"]:
        private_key = PasswordKey(
            acc, pubkey, role).get_private_key()
        new_pubkey[role] = str(private_key.pubkey)

    new_data = {
        "account": acc,
        "json_metadata": {},
        "owner": {
            "key_auths": [
                [new_pubkey["owner"], 1]
            "account_auths": [],
            "weight_threshold": 1
        "active": {
            "key_auths": [
                [new_pubkey["active"], 1]
            "account_auths": [],
            "weight_threshold": 1
        "posting": {
            "key_auths": [
                [new_pubkey["posting"], 1]
            "account_auths": [],
            "weight_threshold": 1
        "memo_key": new_pubkey["memo"]
    print("New data:", new_data)

    op = operations.AccountUpdate(**new_data)
    result = client.commit.finalizeOp(op, acc, "owner")
    print("Result:", result)
except Exception as err:
    print(acc, " err:", err)

执行程序:python MMoSP003_customize_a_tools_for_change_keys dappcoder ownerkey
屏幕快照 2020-02-17 上午2.58.34.png

English list:

#esteem #hive-139531 #steemdevs #community #programming
MMoSP000E-< make money on steem-python > Preface
MMoSP001E- install steem python with anaconda
MMoSP002E - use steem-python make a robot that can automatically say hello to contents under the tag


#cn #hive-180932 #chinese #hive-143316
MMoSP001C- Anaconda 安装 steem-python 开发环境
MMoSP002C- steem-python 开发一个会自动问某个标签下内容的机器人


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

You distributed more than 800 upvotes. Your next target is to reach 900 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!

Coin Marketplace

STEEM 0.50
TRX 0.07
JST 0.057
BTC 40609.83
ETH 2809.00
USDT 1.00
SBD 7.02