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