How to use the beem.account.Account function in beem

To help you get started, we’ve selected a few beem examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github holgern / beem / tests / beem / test_account.py View on Github external
def test_blog_history(self):
        account = Account("holger80", steem_instance=self.bts)
        posts = []
        for p in account.blog_history(limit=5):
            if p["author"] != account["name"]:
                continue
            posts.append(p)
        self.assertTrue(len(posts) >= 1)
        self.assertEqual(posts[0]["author"], account["name"])
        self.assertTrue(posts[0].is_main_post())
        self.assertTrue(posts[0].depth == 0)
github holgern / beem / beem / conveyor.py View on Github external
def _conveyor_method(self, account, signing_account, method, params):
        """ Wrapper function to handle account and key lookups

            :param str account: name of the addressed account
            :param str signing_account: name of the account to sign the request
            :param method: Conveyor method name to be called
            :params dict params: request parameters as `dict`

        """
        account = Account(account, blockchain_instance=self.steem)
        if signing_account is None:
            signer = account
        else:
            signer = Account(signing_account, blockchain_instance=self.steem)
        if "posting" not in signer:
            signer.refresh()
        if "posting" not in signer:
            raise AssertionError("Could not access posting permission")
        for authority in signer["posting"]["key_auths"]:
            posting_wif = self.steem.wallet.getPrivateKeyForPublicKey(
                authority[0])
        return self._request(account['name'], method, params,
                             posting_wif)
github holgern / beem / beem / account.py View on Github external
withdrawn, they will be routed to these accounts based on the
            specified weights.

            :param str to: Recipient of the vesting withdrawal
            :param float percentage: The percent of the withdraw to go
                to the 'to' account.
            :param str account: (optional) the vesting account
            :param bool auto_vest: Set to true if the 'to' account
                should receive the VESTS as VESTS, or false if it should
                receive them as STEEM. (defaults to ``False``)

        """
        if account is None:
            account = self
        else:
            account = Account(account, steem_instance=self.steem)
        op = operations.Set_withdraw_vesting_route(
            **{
                "from_account": account["name"],
                "to_account": to,
                "percent": int(percentage * STEEM_1_PERCENT),
                "auto_vest": auto_vest
            })

        return self.steem.finalizeOp(op, account, "active", **kwargs)
github holgern / beem / beem / account.py View on Github external
from beem.account import Account
                from beem import Steem
                active_wif = "5xxxx"
                stm = Steem(keys=[active_wif])
                acc = Account("test", steem_instance=stm)
                acc.transfer("test1", 1, "STEEM", "test")

        """

        if account is None:
            account = self
        else:
            account = Account(account, steem_instance=self.steem)
        amount = Amount(amount, asset, steem_instance=self.steem)
        to = Account(to, steem_instance=self.steem)
        if memo and memo[0] == "#":
            from .memo import Memo
            memoObj = Memo(
                from_account=account,
                to_account=to,
                steem_instance=self.steem
            )
            memo = memoObj.encrypt(memo[1:])["message"]

        op = operations.Transfer(**{
            "amount": amount,
            "to": to["name"],
            "memo": memo,
            "from": account["name"],
            "prefix": self.steem.prefix,
        })
github holgern / beem / examples / benchmark_nodes2.py View on Github external
error_msg = 'NumRetriesReached'
        history_count = -1
        successful = False
    except KeyboardInterrupt:
        error_msg = 'KeyboardInterrupt'
        history_count = -1
        successful = False
        # quit = True
    except Exception as e:
        error_msg = str(e)
        history_count = -1
        successful = False

    try:
        stm = Steem(node=node, num_retries=3, num_retries_call=3, timeout=30)
        account = Account("gtg", steem_instance=stm)
        blockchain_version = stm.get_blockchain_version()

        start = timer()
        Vote(authorpermvoter, steem_instance=stm)
        stop = timer()
        vote_time = stop - start
        start = timer()
        Comment(authorperm, steem_instance=stm)
        stop = timer()
        comment_time = stop - start
        start = timer()
        Account(author, steem_instance=stm)
        stop = timer()
        account_time = stop - start
        start = timer()
        account.get_followers()
github holgern / beem / beem / cli.py View on Github external
if stm.rpc is not None:
        stm.rpc.rpcconnect()
    if not accounts:
        accounts = [stm.config["default_account"]]
    if not comment and not curation and not post:
        post = True
        permlink = True
    if days < 0:
        days = 1

    utc = pytz.timezone('UTC')
    now = utc.localize(datetime.utcnow())
    limit_time = now - timedelta(days=days)
    for account in accounts:
        sum_reward = [0, 0, 0, 0, 0]
        account = Account(account, steem_instance=stm)
        median_price = Price(stm.get_current_median_history(), steem_instance=stm)
        m = Market(steem_instance=stm)
        latest = m.ticker()["latest"]
        if author and permlink:
            t = PrettyTable(["Author", "Permlink", "Payout", "SBD", "SP + STEEM", "Liquid USD", "Invested USD"])
        elif author and title:
                t = PrettyTable(["Author", "Title", "Payout", "SBD", "SP + STEEM", "Liquid USD", "Invested USD"])
        elif author:
            t = PrettyTable(["Author", "Payout", "SBD", "SP + STEEM", "Liquid USD", "Invested USD"])
        elif not author and permlink:
            t = PrettyTable(["Permlink", "Payout", "SBD", "SP + STEEM", "Liquid USD", "Invested USD"])
        elif not author and title:
            t = PrettyTable(["Title", "Payout", "SBD", "SP + STEEM", "Liquid USD", "Invested USD"])
        else:
            t = PrettyTable(["Received", "SBD", "SP + STEEM", "Liquid USD", "Invested USD"])
        t.align = "l"
github tiotdev / steem-curationbot / curationbot.py View on Github external
copyrighttext = "Hi @{}, \n Thank you for participating in the #travelfeed curated tag. To maintain a level of quality on the project we have certain criteria that must be met for participation. Please review the following: https://travelfeed.io/@travelfeed/how-to-participate-use-travelfeed-in-your-posts \n We require **proper sourcing** for all media and text that is not your own. \n If you have updated your post with sources, please reply to this comment with <code>!tfreview</code>. For further questions, please contact us on the [TravelFeed Discord](https://discord.gg/jWWu73H). \n Thank you very much for your interest and we hope to read some great travel articles from you soon! \n Regards, @travelfeed"

honours = {}
resteems = {}
walletpw =  os.environ.get('UNLOCK') #Beem wallet passphrase must be set as environment variable
TOKEN = os.environ.get('TOKEN') #Discord secret token must be set as environment variable
logger = logging.getLogger(__name__)
logging.basicConfig(filename=logpath, format='%(asctime)s %(levelname)s: %(message)s', level=logging.INFO)
nl = NodeList()
weights = {'block': 0.1, 'history': 1, 'apicall': 0.1, 'config': 0.1}
node_list = nl.update_nodes(weights)
steem = Steem(nodes=node_list)
steem.set_default_nodes(node_list)
steem.wallet.unlock(walletpw)
blockchain = Blockchain()
acc = Account(curationaccount)
# blacklist = acc.get_mutings(raw_name_list=True)
blacklist = []

"""
Discord functions
"""
async def send_discord(msg, cnl):
    """Sends the message *msg* to the Discord channel *cnl*"""
    await bot.wait_until_ready()
    await bot.send_message(bot.get_channel(cnl), msg)

bot = commands.Bot(command_prefix="!")

@bot.event
async def on_ready():
    """Changes discord presence to "Playing TravelFeed.io" when the bot comes online"""
github holgern / beem / beem / conveyor.py View on Github external
:param str account: requested account

            Sample output:

            .. code-block:: js

                {
                    'jsonrpc': '2.0', 'id': 2, 'result': [
                        {'title': 'draft-title', 'body': 'draft-body',
                         'uuid': '06497e1e-ac30-48cb-a069-27e1672924c9'}
                    ]
                }

        """
        account = Account(account, blockchain_instance=self.steem)
        return self._conveyor_method(account, None,
                                     "conveyor.list_drafts",
                                     [account['name']])
github holgern / beem / beem / account.py View on Github external
.. code-block:: python

                from beem.account import Account
                acc = Account("steemitblog")
                for post in acc.blog_history(limit=10):
                    print(post)

        """
        if limit is not None:
            if not isinstance(limit, integer_types) or limit &lt;= 0:
                raise AssertionError("`limit` has to be greater than 0`")

        if account is None:
            account = self
        else:
            account = Account(account, steem_instance=self.steem)

        post_count = 0
        start_permlink = None
        start_author = None
        while True:
            query_limit = 100
            if limit is not None and reblogs:
                query_limit = min(limit - post_count + 1, query_limit)
            if not start_permlink:
                # first iteration uses `get_blog`
                results = self.get_blog(start_entry_id=start,
                                        account=account,
                                        limit=query_limit)
            else:
                # all following iterations use `get_discussions_by_blog`
                from .discussions import Query, Discussions_by_blog
github holgern / beem / beem / account.py View on Github external
:param str memo: (optional) Memo
            :param str request_id: (optional) identifier for tracking or
                cancelling the withdrawal
            :param str to: (optional) the source account for the transfer if
                not ``default_account``
            :param str account: (optional) the source account for the transfer
                if not ``default_account``

        """
        if asset not in ['STEEM', 'SBD']:
            raise AssertionError()

        if account is None:
            account = self
        else:
            account = Account(account, steem_instance=self.steem)
        if to is None:
            to = account  # move to savings on same account
        else:
            to = Account(to, steem_instance=self.steem)
        amount = Amount(amount, asset, steem_instance=self.steem)
        if request_id:
            request_id = int(request_id)
        else:
            request_id = random.getrandbits(32)

        op = operations.Transfer_from_savings(
            **{
                "from": account["name"],
                "request_id": request_id,
                "to": to["name"],
                "amount": amount,