예제 #1
0
def test_witness_update():
    # TODO: Remove when witness_update is fixed.
    return
    wif = '5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3'
    c = Commit(steemd_instance=Steemd(nodes=[]), keys=[wif])

    signing_key = 'BMT1111111111111111111111111111111114T1Anm'
    props = {
        'account_creation_fee': '0.500 BMT',
        'maximum_block_size': 65536,
        'sbd_interest_rate': 0
    }

    rpc_error = None
    try:
        c.witness_update(signing_key=signing_key,
                         account='test',
                         props=props,
                         url='foo')
    except RPCError as e:
        rpc_error = str(e)
    else:
        raise Exception('expected RPCError')

    assert 'tx_missing_active_auth' in rpc_error
예제 #2
0
def test_transfer():
    wif = '5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3'
    c = Commit(steemd_instance=Steemd(nodes=[]), keys=[wif])

    rpc_error = None
    try:
        c.transfer('test2', '1.000', 'STEEM', 'foo', 'test')
    except RPCError as e:
        rpc_error = str(e)
    else:
        raise Exception('expected RPCError')

    assert 'tx_missing_active_auth' in rpc_error
예제 #3
0
def claim_rewards(steem, account_name):
    logger.info('Logged In. Checking for rewards.')
    account = steem.get_account(account_name)
    rewards = reward_available(account)
    if rewards:
        logger.info('Claiming rewards.')
        commit = Commit(steem)
        commit.claim_reward_balance(account=account_name)
        logger.info(
            'Rewards are claimed. %s STEEM, %s SBD, %s VESTS',
            rewards["steem"],
            rewards["sbd"],
            rewards["vesting"],
        )
예제 #4
0
def test_claim_reward():
    wif = '5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3'
    c = Commit(steemd_instance=Steemd(nodes=[]), keys=[wif])

    rpc_error = None
    try:
        c.claim_reward_balance(account='test',
                               reward_steem='1.000 STEEM',
                               reward_vests='0.000000 VESTS',
                               reward_sbd='0.000 SBD')
    except RPCError as e:
        rpc_error = str(e)
    else:
        raise Exception('expected RPCError')

    assert 'tx_missing_posting_auth' in rpc_error
예제 #5
0
def run(args):
    log.info("Market summary mode activated", args=args)

    if args is None or len(args) < 3:
        raise ValueError(
            "You must specify a currency pair, title, and one or more tags")

    pair = args[0]
    title = args[1]
    tags = args[2:]

    log.debug("initializing...")
    steem = Steem(keys=[account.key])
    commit = Commit(steem)
    api = Poloniex()
    market = Market(commit, api, pair)
    log.debug("ready", steem=steem, commit=commit, api=api, market=market)

    market.summarize(title, tags)
예제 #6
0
def test_witness_set_properties():
    wif = '5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3'
    c = Commit(steemd_instance=Steemd(nodes=[]),
               keys=[wif])

    signing_key = 'STM1111111111111111111111111111111114T1Anm'
    props = [
        ['account_creation_fee', 'd0070000000000000354455354530000'],
        ['key', ('032d2a4af3e23294e0a1d9dbc46e0272d'
                 '8e1977ce2ae3349527cc90fe1cc9c5db9')]
    ]

    rpc_error = None
    try:
        c.witness_set_properties(
            signing_key=signing_key,
            props=props,
            account='test')
    except RPCError as e:
        rpc_error = str(e)
    else:
        raise Exception('expected RPCError')

    assert 'tx_missing_other_auth' in rpc_error
예제 #7
0
 def __init__(self, steemd_instance, bot_account):
     self.s = steemd_instance
     self.commit = Commit(steemd_instance=self.s)
     self.bot_account = bot_account
     self.debug = bool(1)
예제 #8
0
 def __init__(self, steem):
     self.steem = steem
     self.commit = Commit(steem)
     self.watch_account = settings.BOT_ACCOUNT
예제 #9
0
 def reconnect(self):
     """Creates a new Steemd and Commit"""
     self.steemd = Steemd(nodes=self.nodes.copy(), **self.kwargs.copy())
     self.commit = Commit(steemd_instance=self.steemd,
                          no_broadcast=self.no_broadcast,
                          **self.kwargs.copy())
 def get_steem_committer(self):
     retval = Commit(steemd_instance=self.steemd_rpc,
                     debug=self.debug_mode,
                     keys=self.keys)
     return retval
예제 #11
0
# globals
misses = 0
failover_after = 5
counter = 0

# witness
witness_url = "https://yourwebsite.com"
witness_props = {
    "account_creation_fee": "3.000 STEEM",
    "maximum_block_size": 65536,
    "sbd_interest_rate": 0,
}

b = Blockchain(steemd_instance=s)
t = Commit(steemd_instance=s, no_broadcast=debug, keys=steem_keys)


def l(msg, slack=False):
    caller = inspect.stack()[1][3]
    print("[{}] {}".format(str(caller), str(msg)))
    sys.stdout.flush()


def get_witness_key():
    return s.get_witness_by_account(steem_account)['signing_key']


def get_misses():
    return s.get_witness_by_account(steem_account)['total_missed']
예제 #12
0
def run():
    log.info("Timely post mode activated")

    log.debug("initializing...")
    steem = Steem(keys=[cred.key])
    account = Account(cred.id, steem)
    chain = Blockchain(steem)
    commit = Commit(steem)
    log.debug("ready", steem=steem, account=account, blockchain=chain, commit=commit)

    # Because subsequent edits to a post show up as separate post entries in the blockchain,
    # we'll keep a list of candidates keyed by the post identifier which the edits share.
    candidates = {}

    log.info("Checking post history...")
    history = map(Post, account.history(filter_by=['comment']))

    # FIXME: use steem.get_posts() instead?

    for post in history:
        if post.is_main_post():
            log.debug("found a top-level post", post=post, tags=post.tags)

            if post.tags[0] == cred.id and 'boiled' not in post.tags:
                candidates[post.identifier] = post

    if len(candidates) > 0:
        log.info("Found one or more historical posts to process", posts=candidates)

        deleting = []
        for key, post in candidates.items():
            result = process(commit, post)
            if result or result is None:
                deleting.append(key)
        for key in deleting:
            del candidates[key]

    log.info("Watching for new posts...")
    while True:
        stream = map(Post, chain.stream(filter_by=['comment']))

        try:
            for post in stream:
                if post.is_main_post() and post.author == cred.id:
                    log.debug("found a top-level post", post=post, tags=post.tags)

                    if len(post.tags) == 2 and post.tags[0] == cred.id and post.tags[1] == cred.id:
                        candidates[post.identifier] = post

                deleting = []
                for key, post in candidates.items():
                    result = process(commit, post)
                    if result or result is None:
                        deleting.append(key)
                for key in deleting:
                    del candidates[key]

        except PostDoesNotExist as e:
            log.debug("Post has vanished", exception=e)

        except RPCError as e:
            log.error("RPC problem while streaming posts", exception=e)
예제 #13
0
 def __init__(self, steem, config):
     self.steem = steem
     self.account = config["account"]
     self.mysql_uri = config["mysql_uri"]
     self.config = config
     self.commit = Commit(steem)
예제 #14
0
from steem import Steem
from steem.commit import Commit

s = Steem()

query = {
    "limit": 5,  #number of posts
    "tag": ""  #tag of posts
}
# post list from trending post list
posts = s.get_discussions_by_trending(query)

title = 'Please choose post to reblog: '
options = []
# post list
for post in posts:
    options.append('@' + post["author"] + '/' + post["permlink"])

# get index and selected post
option, index = pick(options, title)
pprint.pprint("You selected: " + option)

account = input("Enter your username? ")
wif = input("Enter your Posting private key? ")

# commit or build transaction
c = Commit(steem=Steem(keys=[wif]))

# broadcast transaction
c.resteem(option, account=account)