beempy 利用RC领取的新号资源创建steem 新号

avatar
(Edited)

beempy 利用RC领取的新号资源创建steem 新号

最近虽然在做steem-python 实战教程,但不支持利用RC领取的新号资源创建steem 新号,需要使用beempy.

代码如下(create_account_with_RC.py):

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

# python create_account_with_RC.py creator account

from contextlib import suppress
import sys
import json

# from beem import Steem
from beem.account import Account
from beem.instance import shared_steem_instance
from beemgraphenebase.account import BrainKey, PasswordKey

def run():

    # need creator and  name of the new account
    try:
        creator = sys.argv[1]
        account = sys.argv[2]
    except Exception as e:
        sys.exit()
    print('creator:', creator)
    print('account:', account)

    # gen a set of keys
    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))

    # unlock local wallet
    stm = shared_steem_instance()
    stm.wallet.unlock(password)

    try:
        # Account of creator
        creatorA = Account(creator, steem_instance=stm)
        # test the new account is exist on steem blockchain?
        accountA = Account(account, steem_instance=stm)
    except Exception as e:
        print('account can be created:', account)

    # create new account
    tx = stm.create_claimed_account(account, creator=creatorA, password=pubkey)
    print('create_claimed_account:', json.dumps(tx, indent=4))

    # get keys
    posting_key = PasswordKey(account, pubkey, role="posting", prefix=stm.prefix)
    active_key = PasswordKey(account, pubkey, role="active", prefix=stm.prefix)
    memo_key = PasswordKey(account, pubkey, role="memo", prefix=stm.prefix)
    owner_key = PasswordKey(account, pubkey, role="owner", prefix=stm.prefix)
    # get publick keys
    # 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()
    # get private keys
    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))


if __name__ == '__main__':
    with suppress(KeyboardInterrupt):
        run()

执行程序:python create_account_with_RC.py dappcoder newcoder
执行结果符合预期:
屏幕快照 2020-02-14 上午12.50.30.png



0
0
0.000
3 comments
avatar

According to the Bible, How do you influence faith to Christian believers? (Part 3 of 3)

(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.)



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
Join our Official Community: https://beta.steemit.com/trending/hive-182074

0
0
0.000
avatar

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

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

Vote for @Steemitboard as a witness to get one more award and increased upvotes!
0
0
0.000
avatar

不错啊。免得在第三方网站上创建,还需要提供active蜜月,不太安全

0
0
0.000