Beispiel #1
0
async def claim():
    stm = Steem(node="https://api.steemit.com", keys=[SR])
    rc = RC(steem_instance=stm)
    acc = Account('sourovafrin')
    current_mana = acc.get_rc_manabar()["current_mana"]
    mana_cost= stm.get_rc_cost(rc.get_resource_count(tx_size=250, execution_time_count=0, state_bytes_count=0, new_account_op_count=1))
    mana_cost+=2500000000
    if current_mana>mana_cost:
        stm.claim_account('sourovafrin','0 STEEM')
        await client.send_message(client.get_channel('544916428881657856'), "<@397972596207124480> I have claimed a steem discounted account just now and that's only for you")
def claim_acct_rc(steem_instance, steem_account):
    rc = RC(steem_instance=steem_instance)
    current_costs = steem_instance.get_rc_cost(
        rc.get_resource_count(tx_size=250,
                              execution_time_count=10000,
                              new_account_op_count=1))
    current_mana = steem_account.get_rc_manabar()["current_mana"]
    last_mana = current_mana
    print("Current costs %.2f G RC - current mana %.2f G RC" %
          (current_costs / 1e9, current_mana / 1e9))
    if current_costs + 10 < current_mana:
        steem_instance.claim_account(steem_account)
        time.sleep(10)
        steem_account.refresh()
        current_mana = steem_account.get_rc_manabar()["current_mana"]
        print("Account claimed and %.2f G RC paid." %
              ((last_mana - current_mana) / 1e9))
        last_mana = current_mana
    else:
        print("Not enough RC for a claim!")
Beispiel #3
0
 def compute_cost(self, type=1, tx_size=1000, perm_len=10, pperm_len=0):
     rc = RC()
     if type == 1:
         cost = rc.comment(tx_size=tx_size,
                           permlink_length=perm_len,
                           parent_permlink_length=pperm_len)
     elif type == 2:
         cost = rc.vote(tx_size=tx_size)
     elif type == 3:
         cost = rc.transfer(tx_size=tx_size, market_op_count=perm_len)
     elif type == 4:
         cost = rc.custom_json(tx_size=tx_size)
     else:
         return False
     return cost
Beispiel #4
0
 def compute_cost(self, type=1, tx_size=1000, perm_len=10, pperm_len=0):
     rc = RC()
     if type == 1:
         cost = rc.comment(tx_size=tx_size,
                           permlink_length=perm_len,
                           parent_permlink_length=pperm_len)
     elif type == 2:
         cost = rc.vote(tx_size=tx_size)
     elif type == 3:
         cost = rc.transfer(tx_size=tx_size, market_op_count=perm_len)
     elif type == 4:
         cost = rc.custom_json(tx_size=tx_size)
     else:
         print("Invalid type.")
         return
     print("RC costs for a comment: %.2f G RC" % (cost))
Beispiel #5
0
 def refresh_account(self):
     if self.hist_account is None:
         return
     self.hist_account.refresh()
     self.accountInfoGroupBox.setTitle("%s (%.3f)" % (self.hist_account["name"], self.hist_account.rep))
     with self.redrawLock:
         self.votePowerProgressBar.setValue(int(self.hist_account.vp))
         if self.hist_account.vp == 100:
             self.votePowerProgressBar.setFormat("%.2f %%" % (self.hist_account.vp))
         else:
             self.votePowerProgressBar.setFormat("%.2f %%, full in %s" % (self.hist_account.vp, self.hist_account.get_recharge_time_str()))
     down_vp = self.hist_account.get_downvoting_power()
     with self.redrawLock:
         self.downvotePowerProgressBar.setValue(int(down_vp))
         if down_vp == 100:
             self.downvotePowerProgressBar.setFormat("%.2f %%" % (down_vp))
         else:
             self.downvotePowerProgressBar.setFormat("%.2f %%, full in %s" % (down_vp, self.hist_account.get_recharge_time(starting_voting_power=down_vp)))
     
     self.votePowerLabel.setText("Vote Power, a 100%% vote is %.3f $" % (self.hist_account.get_voting_value_SBD()))
     self.downvotePowerLabel.setText("DownVote Power")
     self.STEEMLabel.setText(str(self.hist_account["balance"]))
     self.SBDLabel.setText(str(self.hist_account["sbd_balance"]))
     self.SPLabel.setText("%.3f HP" % self.stm.vests_to_sp(self.hist_account["vesting_shares"]))
     try:
         rc_manabar = self.hist_account.get_rc_manabar()
         with self.redrawLock:
             self.RCProgressBar.setValue(int(rc_manabar["current_pct"]))
             self.RCProgressBar.setFormat("%.2f %%, full in %s" % (rc_manabar["current_pct"], self.hist_account.get_manabar_recharge_time_str(rc_manabar)))
     
         rc = self.hist_account.get_rc()
         estimated_rc = int(rc["max_rc"]) * rc_manabar["current_pct"] / 100
         rc_calc = RC(steem_instance=self.stm)
         self.RCLabel.setText("RC (%.0f G RC of %.0f G RC)" % (estimated_rc / 10**9, int(rc["max_rc"]) / 10**9))
         ret = "--- Approx Costs ---\n"
         ret += "comment - %.2f G RC - enough RC for %d comments\n" % (rc_calc.comment() / 10**9, int(estimated_rc / rc_calc.comment()))
         ret += "vote - %.2f G RC - enough RC for %d votes\n" % (rc_calc.vote() / 10**9, int(estimated_rc / rc_calc.vote()))
         ret += "transfer - %.2f G RC - enough RC for %d transfers\n" % (rc_calc.transfer() / 10**9, int(estimated_rc / rc_calc.transfer()))
         ret += "custom_json - %.2f G RC - enough RC for %d custom_json\n" % (rc_calc.custom_json() / 10**9, int(estimated_rc / rc_calc.custom_json()))
         self.text.setText(ret)
     except:
         rc_manabar = None
import beem
from beem.rc import RC
from beembase import operations

client = beem.Steem()

rc = RC(steem_instance=client)

# print(rc.comment()) #(self, tx_size=1000, permlink_length=10, parent_permlink_length=10)
# print(rc.vote()) #(self, tx_size=210)
# print(rc.transfer()) #(self, tx_size=290, market_op_count=1)
# print(rc.custom_json())

account = "hrm-user"

json = {'command': 'create'}
# json = {
#     'command': 'confirmation',
#     'transaction': '33715240:24',
#     'status': 'OK'
#     }

id = "institutionList"

op = operations.Custom_json(
    **{
        "json": json,
        "required_auths": [],
        "required_posting_auths": [account],
        "id": id
    })
    def __init__(self, config, data_file, hived_instance):
        self.config = config
        self.data_file = data_file
        data_db = read_data(data_file)
        if "accounts" in data_db:
            accounts = data_db["accounts"]
        else:
            accounts = {}
        self.hive = hived_instance

        # add log stats
        self.log_data = {
            "start_time": 0,
            "last_block_num": None,
            "new_commands": 0,
            "stop_block_num": 0,
            "stop_block_num": 0,
            "time_for_blocks": 0
        }
        config_cnt = 0
        necessary_fields = [
            "delegationAccount", "referrerAccount", "adminAccount",
            "delegationAmount", "delegationLength", "beneficiaryRemoval",
            "minPostRC", "muteAccount", "hpWarning", "maxUserHP", "notifyUser",
            "delegationMsg", "delegationLengthMsg", "delegationMuteMsg",
            "delegationBeneficiaryMsg", "delegationMaxMsg"
        ]

        check_config(self.config, necessary_fields, self.hive)
        self.hive.wallet.unlock(self.config["wallet_password"])
        self.onboard_api = "https://hiveonboard.com/api/referrer/%s" % self.config[
            "referrerAccount"]
        self.blockchain = Blockchain(mode='head',
                                     blockchain_instance=self.hive)
        self.muted_acc = Account(self.config["muteAccount"],
                                 blockchain_instance=self.hive)
        self.delegation_acc = Account(self.config["delegationAccount"],
                                      blockchain_instance=self.hive)
        self.muted_accounts = self.muted_acc.get_mutings(limit=1000)

        active_key = False
        for key in self.delegation_acc["active"]["key_auths"]:
            if key[0] in self.hive.wallet.getPublicKeys(current=True):
                active_key = True
        for key in self.delegation_acc["owner"]["key_auths"]:
            if key[0] in self.hive.wallet.getPublicKeys(current=True):
                active_key = True
        if not active_key:
            logger.warn(
                "Active key from %s is not stored into the beempy wallet." %
                self.delegation_acc["name"])

        rc = RC(blockchain_instance=self.hive)
        self.comment_rc_costs = rc.comment(tx_size=4000,
                                           permlink_length=40,
                                           parent_permlink_length=0)
        self.accounts = self.get_referrer(accounts)
        self.update_delegations()
        self.check_muted(self.muted_accounts)
        self.check_delegation_age()
        self.check_max_hp()
        self.print_account_info()
        store_data(self.data_file, "accounts", self.accounts)