steem使用的是分级授权,因此一个steem账号,具有4个密码:"owner", "active", "posting", "memo". 这些密码都很长,靠人脑记住,是不太现实.只能靠文件存储,让机器人自己读写. 上次已经示范了如何通过beempy,现在就让这个创建过程使用json文件管理.  json文件存储的格式(/bots.json): ```json { "nodes": [ "https://anyx.io", "https://api.steemit.com" ], "steems": { "steemaccount": { } } } ``` 这里就示范beempy创建新号存入json文件(create_claimed_account_beem.py): -------------------------------------- ```python #!/usr/bin/python # -*- coding: UTF-8 -*- # 用消耗RC领取的pending claimed accounts,创建 steem 新号 # Export the key of the specified account from the local Wallet # python create_claimed_account_beem.py creator account import sys import getopt import time import json # from beem import Steem from beem.account import Account from beem.instance import shared_steem_instance from beemgraphenebase.account import BrainKey, PasswordKey # 必须有创建者 creator 和新号 account try: creator = sys.argv[1] account = sys.argv[2] except Exception as e: sys.exit() print('creator:', creator) print('account:', account) stm = shared_steem_instance() # 解锁本地钱包(操作钱包时,需要解锁,否则不用) # 输入本地钱包密码或在代码中直接赋值 # Enter the local wallet password or set value directly in the code password = '' # 'walletkey' if not password: password = input('local wallet password : ') stm.wallet.unlock(password) # 本地存储 steem 账号信息的文件 accounts_file = '/bots.json' try: # 创建者账号 creatorA = Account(creator, steem_instance=stm) accountA = Account(account, steem_instance=stm) except Exception as e: print('account can be created:', account) # 生成一套新密码 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)) # 创建新号:本地存储 owner(默认不存储) tx = stm.create_claimed_account( account, creator=creatorA, password=prikey, store_owner_key=True) print('create_claimed_account:', json.dumps(tx, indent=4)) # 获取整套密钥 posting_key = PasswordKey(account, prikey, role="posting", prefix=stm.prefix) active_key = PasswordKey(account, prikey, role="active", prefix=stm.prefix) memo_key = PasswordKey(account, prikey, role="memo", prefix=stm.prefix) owner_key = PasswordKey(account, prikey, role="owner", prefix=stm.prefix) # 提取整套密钥中的公钥 # 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() # 提取整套密钥中的私钥 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)) with open(accounts_file, 'r', encoding='utf-8') as f: # 直接用load()传入文件对象,将文件中字符串内容转为json字典 accounts_dict = json.load(f) # print('old.accounts_dict:', accounts_dict) accounts_dict['steems'][account] = { "name": account, # steem 账号名称 "email": "sample@,pwd", # steem 注册 email "mobile": "sample9,from", # steem 注册 手机号 "keys": { "brain": brainkey, # steem 账号的脑密码 "private": prikey, # steem 账号当前的私钥 "public": pubkey, # steem 账号当前的公钥 "history": [ # steem 账号的私钥的修改记录 prikey, "sample2", "sample3" ], "posting": str(posting_privkey), # steem 账号的 posting 私钥 "active": str(active_privkey), # steem 账号的 active 私钥 "owner": str(owner_privkey), # steem 账号的 owner 私钥 "memo": str(memo_privkey), # steem 账号的 memo 私钥,用于解密memo "memo_key": str(memo_pubkey) # steem 账号的 memo 公钥,用于加密memo } } with open(accounts_file, 'w', encoding='utf-8') as f: # 用dump()传入字典和文件对象,将json字典转为字符串,存入文件 json.dump(accounts_dict, f, indent=4, ensure_ascii=False) ``` 执行程序:`python create_claimed_account_beem dappcoder newaccddd` 执行结果,和预期一致:
author | dappcoder | ||||||
---|---|---|---|---|---|---|---|
permlink | python-steem-json-beempy-steem | ||||||
category | hive-180932 | ||||||
json_metadata | {"tags":["cn","hive-143316","cn-reader","cn-curation","sct","sct-cn","sct-freeboard","palnet","upfundme","zzan","jjm","mediaofficials","lassecash","liv","steemleo","busy","esteem","esteem-cn","cn-stem","steemstem","cn-programming","dblog","marlians","neoxian","actnearn"],"app":"busy/2.5.4","format":"markdown","community":"esteemapp","image":"https://cdn.steemitimages.com/DQmYi9HNRfvLGpneXnQsY9DjKNpChaNC7P6tNK1L1DJqpBv/beem.png"} | ||||||
created | 2020-02-18 06:51:45 | ||||||
last_update | 2020-02-23 03:00:00 | ||||||
depth | 0 | ||||||
children | 3 | ||||||
last_payout | 2020-02-25 06:51:45 | ||||||
cashout_time | 1969-12-31 23:59:59 | ||||||
total_payout_value | 2.200 HBD | ||||||
curator_payout_value | 2.224 HBD | ||||||
pending_payout_value | 0.000 HBD | ||||||
promoted | 0.000 HBD | ||||||
body_length | 4,194 | ||||||
author_reputation | 9,480,331,507,174 | ||||||
root_title | python开发steem机器人,通过json文件管理beempy创建的steem账号密码 | ||||||
beneficiaries |
| ||||||
max_accepted_payout | 1,000,000.000 HBD | ||||||
percent_hbd | 10,000 | ||||||
post_id | 95,566,965 | ||||||
net_rshares | 15,583,404,153,982 | ||||||
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
good-karma | 0 | 208,244,790,159 | 22.71% | ||
mysteem | 0 | 747,345,835 | 22.71% | ||
bullionstackers | 0 | 92,498,338,966 | 10% | ||
rivalhw | 0 | 1,064,272,151,461 | 50% | ||
demo | 0 | 955,038,589 | 22.71% | ||
feruz | 0 | 49,144,507,572 | 22.71% | ||
busy.org | 0 | 109,975,835 | 0.62% | ||
esteemapp | 0 | 5,113,455,675,348 | 22.71% | ||
steemitboard | 0 | 15,475,021,042 | 1% | ||
techken | 0 | 363,852,473 | 1.7% | ||
exe8422 | 0 | 355,334,198 | 4% | ||
sanat | 0 | 310,672,624 | 100% | ||
cn-reader | 0 | 13,636,479,484 | 50% | ||
pixresteemer | 0 | 496,118,156 | 1.25% | ||
dobartim | 0 | 1,044,792,433,286 | 17% | ||
xiaoshancun | 0 | 23,342,665,188 | 100% | ||
esteem.app | 0 | 4,761,156,830 | 22.71% | ||
stmdev | 0 | 83,599,569 | 1% | ||
mini-zephalexia | 0 | 1,540,162,222 | 18.16% | ||
andrewma | 0 | 46,543,548 | 0.5% | ||
xiguang | 0 | 7,727,722,194 | 0.5% | ||
anonyvoter | 0 | 439,510,371 | 2% | ||
laissez-faire | 0 | 173,365,887 | 100% | ||
gorzalos | 0 | 239,318,220 | 50% | ||
general.guy | 0 | 2,629,246,324 | 22.71% | ||
morningshine | 0 | 19,046,431,197 | 4% | ||
ctime | 0 | 210,765,407,534 | 2% | ||
haxxdump | 0 | 68,231,353 | 3% | ||
aaronli.sct | 0 | 730,026,740 | 10% | ||
steem-drivers | 0 | 4,100,557,403 | 30% | ||
mindtrap-leo | 0 | 0 | 0.88% | ||
cn-leo | 0 | 114,927,136 | 2% | ||
cn-pal | 0 | 605,377,724 | 5% | ||
cn-mot | 0 | 150,244,439 | 30% | ||
cn-marlians | 0 | 1,523,593,311 | 5% | ||
cn-neoxag | 0 | 102,562,771 | 5% | ||
cn-actnearn | 0 | 149,698,415 | 30% | ||
dappcoder | 0 | 295,986,179,416 | 100% | ||
tonimontana.leo | 0 | 0 | 0.89% | ||
tonimontana.neo | 0 | 0 | 0.56% | ||
tex.fund | 0 | 585,828,825 | 100% | ||
hnt | 0 | 666,723,526 | 100% | ||
acu.fund | 0 | 964,680,020 | 100% | ||
mana.bank | 0 | 3,973,123,580 | 100% | ||
acu.fund.witness | 0 | 684,027,422 | 100% | ||
spbank | 0 | 572,932,303 | 100% | ||
yaowl | 0 | 573,242,152 | 100% | ||
alanyao | 0 | 595,851,040 | 100% | ||
missingwolf | 0 | 607,275,922 | 100% | ||
xinhuaren | 0 | 571,964,470 | 100% | ||
acufund | 0 | 562,268,323 | 100% | ||
downvoter | 0 | 461,265,579,666 | 100% | ||
manabot1 | 0 | 556,380,445 | 100% | ||
manabot | 0 | 564,922,232 | 100% | ||
huaren.news | 0 | 6,323,105,316,884 | 100% | ||
cameron.barnes | 0 | 543,260,554 | 100% | ||
manabot2 | 0 | 555,234,422 | 100% | ||
sherryzhou | 0 | 572,689,454 | 98% | ||
goodvoter | 0 | 551,919,481 | 100% | ||
anonymity.inlet | 0 | 798,022,028 | 100% | ||
manabot3 | 0 | 533,372,876 | 100% | ||
manabot4 | 0 | 0 | 100% | ||
manabank | 0 | 538,211,216 | 100% | ||
texfund | 0 | 551,004,974 | 100% | ||
goodreader | 0 | 544,139,749 | 100% | ||
goodposter | 0 | 551,451,403 | 100% | ||
goodcurator | 0 | 2,609,369,615 | 100% | ||
goodauthor | 0 | 584,505,442 | 100% | ||
shanyi | 0 | 556,326,934 | 100% | ||
yuwenzhaobin | 0 | 552,359,514 | 100% | ||
huangyiru | 0 | 554,639,332 | 100% | ||
qiuruling | 0 | 558,270,296 | 100% | ||
tongpingxia | 0 | 646,535,183 | 100% | ||
fushuo | 0 | 547,910,752 | 100% | ||
downscaner | 0 | 615,730,141 | 100% | ||
wang.han | 0 | 541,788,948 | 97% | ||
anonym.inlet | 0 | 544,061,904 | 96% | ||
rongyongyu | 0 | 539,961,312 | 100% | ||
heyaochen | 0 | 546,902,502 | 100% | ||
miyijuan | 0 | 557,056,160 | 100% | ||
xiangsong | 0 | 541,926,513 | 100% | ||
haiyaochang | 0 | 545,699,398 | 100% | ||
zhangyanxie | 0 | 699,259,433 | 100% | ||
jiduanren | 0 | 550,373,922 | 100% | ||
hanyiya | 0 | 539,960,889 | 100% | ||
guxiefeng | 0 | 539,961,138 | 100% | ||
hejuangang | 0 | 539,960,405 | 100% | ||
mengyin | 0 | 539,960,107 | 100% | ||
liaohepeng | 0 | 543,851,343 | 100% | ||
gaituan | 0 | 539,959,502 | 100% | ||
quxibei | 0 | 545,147,185 | 100% | ||
dblogvoter | 0 | 75,016,100 | 1.95% | ||
neoxvoter | 0 | 396,152,990 | 4.2% | ||
creavoter | 0 | 232,503,089 | 4.2% | ||
huarennews | 0 | 602,460,755 | 100% | ||
qukehan | 0 | 18,746,206 | 100% | ||
lvziyun | 0 | 255,634,902,951 | 100% | ||
steem-holder | 0 | 32,220,343 | 2.8% | ||
telangpu | 0 | 0 | 100% | ||
chinesebi | 0 | 167,232,900,320 | 100% | ||
staryao | 0 | 160,363,774,889 | 100% | ||
william.turner | 0 | 0 | 100% | ||
alyssa.mey | 0 | 0 | 100% | ||
raven.mottram | 0 | 0 | 100% | ||
brian.shanno | 0 | 0 | 100% | ||
annmarie.prigge | 0 | 0 | 100% | ||
meaghan.dajer | 0 | 0 | 100% | ||
longye | 0 | 0 | 100% | ||
sweepers | 0 | 0 | 100% | ||
icoer | 0 | 0 | 100% | ||
wangping | 0 | 0 | 100% | ||
likeqianq | 0 | 0 | 100% | ||
jinpingxi | 0 | 0 | 100% | ||
gavinyao | 0 | 0 | 100% | ||
dragon8king | 0 | 0 | 100% | ||
steem.buzz | 0 | 710,465,396 | 100% | ||
gavin.yao | 0 | 726,777,466 | 100% | ||
wangfang | 0 | 523,069,820 | 100% | ||
zhangjin | 0 | 0 | 100% | ||
cnbank | 0 | 0 | 100% | ||
chinesebank | 0 | 0 | 100% | ||
china.news | 0 | 0 | 100% | ||
mingji | 0 | 0 | 100% | ||
liuyan | 0 | 0 | 100% | ||
newcoder | 0 | 0 | 100% | ||
trxsteem | 0 | 0 | 100% | ||
sunyuchen | 0 | 0 | 100% | ||
trxsun | 0 | 0 | 100% | ||
topvoter | 0 | 0 | 100% | ||
coderhappy | 0 | 0 | 100% | ||
steem.voice | 0 | 0 | 100% | ||
voice.steem | 0 | 0 | 100% | ||
voicebot | 0 | 0 | 100% | ||
voice.bot | 0 | 0 | 100% | ||
voicesteem | 0 | 0 | 100% | ||
voicebeta | 0 | 0 | 100% | ||
voicealpha | 0 | 0 | 100% | ||
voice1 | 0 | 0 | 100% | ||
voice8 | 0 | 0 | 100% | ||
voice7 | 0 | 0 | 100% | ||
voice6 | 0 | 0 | 100% | ||
voice5 | 0 | 0 | 100% | ||
voice4 | 0 | 0 | 100% | ||
voice3 | 0 | 0 | 100% | ||
voice2 | 0 | 0 | 100% | ||
voice0 | 0 | 0 | 100% | ||
voice18 | 0 | 0 | 100% | ||
voice28 | 0 | 0 | 100% | ||
voice58 | 0 | 0 | 100% | ||
voice88 | 0 | 0 | 100% | ||
voice.game | 0 | 0 | 100% | ||
voicegame | 0 | 0 | 100% | ||
voiceshot | 0 | 0 | 100% | ||
gongsunyan | 0 | 0 | 100% | ||
siturenxiong | 0 | 0 | 100% | ||
yangshuyi | 0 | 0 | 100% | ||
yukaiyi | 0 | 0 | 100% | ||
coolvoter | 0 | 0 | 100% | ||
tron.sun | 0 | 0 | 100% | ||
news.bot | 0 | 0 | 100% | ||
douxili | 0 | 0 | 100% | ||
voterking | 0 | 0 | 100% | ||
aivote | 0 | 0 | 100% | ||
aivoter | 0 | 0 | 100% | ||
huarennews.hello | 0 | 0 | 100% | ||
voteking | 0 | 0 | 100% | ||
voteai | 0 | 0 | 100% |
**Yay!** <br>Your post has been **boosted with ESTM**. Keep up the good work! <br>Dear reader, Install [Android](https://play.google.com/store/apps/details?id=app.esteem.mobile.android), [iOS](https://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=1451896376&mt=8) Mobile app or [Windows, Mac, Linux](https://github.com/esteemapp/esteem-surfer/releases) Surfer app!<br>Learn more: https://esteem.app <br>Join our discord: https://discord.me/esteem
author | esteemapp |
---|---|
permlink | re-2020221t195929959z |
category | hive-180932 |
json_metadata | {"tags":["esteem"],"app":"esteem/2.2.2-welcome","format":"markdown+html","community":"esteem.app"} |
created | 2020-02-21 18:59:30 |
last_update | 2020-02-21 18:59:30 |
depth | 1 |
children | 0 |
last_payout | 2020-02-28 18:59:30 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 459 |
author_reputation | 420,443,679,514,793 |
root_title | python开发steem机器人,通过json文件管理beempy创建的steem账号密码 |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 95,689,161 |
net_rshares | 0 |
### According to the Bible, *Bro. Eli Soriano: What really happened to Joseph Smith?* ### Watch the Video below to know the Answer... ***(Sorry for sending this comment. We are not looking for our self profit, our intentions is to preach the words of God in any means possible.)*** https://youtu.be/83nsg2zU5_4 Comment what you understand of our Youtube Video to receive our full votes. We have 30,000 #SteemPower. It's our little way to **Thank you, our beloved friend.** Check our [Discord Chat](https://discord.gg/vzHFNd6) Join our Official Community: https://steemit.com/created/hive-182074
author | marcos-708 |
---|---|
permlink | 7mqti74dt23 |
category | hive-180932 |
json_metadata | "" |
created | 2020-02-23 03:08:18 |
last_update | 2020-02-23 03:08:18 |
depth | 1 |
children | 0 |
last_payout | 2020-03-01 03:08:18 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 599 |
author_reputation | -7,490,395,056,362 |
root_title | python开发steem机器人,通过json文件管理beempy创建的steem账号密码 |
beneficiaries | [] |
max_accepted_payout | 10,000.000 HBD |
percent_hbd | 100 |
post_id | 95,730,168 |
net_rshares | -25,311,134,220 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
mack-bot | 0 | -26,004,414,118 | -0.25% | ||
marcos-708 | 0 | 693,279,898 | 1% |
Congratulations @dappcoder! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) : <table><tr><td><img src="https://steemitimages.com/60x70/http://steemitboard.com/@dappcoder/posts.png?202002180745"></td><td>You published more than 30 posts. Your next target is to reach 40 posts.</td></tr> </table> <sub>_You can view [your badges on your Steem Board](https://steemitboard.com/@dappcoder) and compare to others on the [Steem Ranking](https://steemitboard.com/ranking/index.php?name=dappcoder)_</sub> <sub>_If you no longer want to receive notifications, reply to this comment with the word_ `STOP`</sub> To support your work, I also upvoted your post! **Do not miss the last post from @steemitboard:** <table><tr><td><a href="https://steemit.com/steemitboard/@steemitboard/valentine-s-day-challenge-give-a-badge-to-your-beloved"><img src="https://steemitimages.com/64x128/http://i.cubeupload.com/LvDzr5.png"></a></td><td><a href="https://steemit.com/steemitboard/@steemitboard/valentine-s-day-challenge-give-a-badge-to-your-beloved">Valentine's day challenge - Give a badge to your beloved!</a></td></tr></table> ###### [Vote for @Steemitboard as a witness](https://v2.steemconnect.com/sign/account-witness-vote?witness=steemitboard&approve=1) to get one more award and increased upvotes!
author | steemitboard |
---|---|
permlink | steemitboard-notify-dappcoder-20200218t081344000z |
category | hive-180932 |
json_metadata | {"image":["https://steemitboard.com/img/notify.png"]} |
created | 2020-02-18 08:13:42 |
last_update | 2020-02-18 08:13:42 |
depth | 1 |
children | 0 |
last_payout | 2020-02-25 08:13:42 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 1,353 |
author_reputation | 38,975,615,169,260 |
root_title | python开发steem机器人,通过json文件管理beempy创建的steem账号密码 |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 95,568,642 |
net_rshares | 0 |