def account_update_dict(self, account_update_dict): """Calc RC costs for account update""" op = operations.Account_update(**account_update_dict) tx_size = self.get_tx_size(op) execution_time_count = resource_execution_time[ "account_update_operation_exec_time"] resource_count = self.get_resource_count(tx_size, execution_time_count) return self.blockchain.get_rc_cost(resource_count)
def time_account_update(self): self.op = operations.Account_update( **{ "account": "streemian", "posting": { "weight_threshold": 1, "account_auths": [["xeroc", 1], ["fabian", 1]], "key_auths": [[ "STM6KChDK2sns9MwugxkoRvPEnyju" "TxHN5upGsZ1EtanCffqBVVX3", 1 ], [ "STM7sw22HqsXbz7D2CmJfmMwt9ri" "mtk518dRzsR1f8Cgw52dQR1pR", 1 ]] }, "owner": { "weight_threshold": 1, "account_auths": [], "key_auths": [[ "STM7sw22HqsXbz7D2CmJfmMwt9r" "imtk518dRzsR1f8Cgw52dQR1pR", 1 ], [ "STM6KChDK2sns9MwugxkoRvPEn" "yjuTxHN5upGsZ1EtanCffqBVVX3", 1 ]] }, "active": { "weight_threshold": 2, "account_auths": [], "key_auths": [[ "STM6KChDK2sns9MwugxkoRvPEnyju" "TxHN5upGsZ1EtanCffqBVVX3", 1 ], [ "STM7sw22HqsXbz7D2CmJfmMwt9ri" "mtk518dRzsR1f8Cgw52dQR1pR", 1 ]] }, "memo_key": "STM728uLvStTeAkYJsQefks3FX8yfmpFHp8wXw3RY3kwey2JGDooR", "json_metadata": "", "prefix": self.default_prefix }) self.doit()
key_auths_public[role] = str(pk.get_public_key()) key_auths_private[role] = str(pk.get_private_key()) op = operations.Account_update( **{ "account": acc["name"], 'owner': { 'account_auths': [], 'key_auths': [[key_auths_public['owner'], 1]], "address_auths": [], 'weight_threshold': 1 }, 'active': { 'account_auths': [], 'key_auths': [[key_auths_public['active'], 1]], "address_auths": [], 'weight_threshold': 1 }, 'posting': { 'account_auths': acc['posting']['account_auths'], 'key_auths': [[key_auths_public['posting'], 1]], "address_auths": [], 'weight_threshold': 1 }, 'memo_key': key_auths_public['memo'], "json_metadata": acc['json_metadata'], "prefix": prefix, }) ops = [op] tb = TransactionBuilder()
def account_update_dict(self, account_update_dict): """Calc RC costs for account update""" op = operations.Account_update(**account_update_dict) tx_size = self.get_tx_size(op) resource_count = self.get_resource_count(tx_size) return self.steem.get_rc_cost(resource_count)
def recover_account(account): """Recover ACCOUNT. This action has to be initiated/signed by the account to be recovered. """ acc = Account(account) if acc.get_owner_history() == []: logger.error("@%s has an empty owner history - recovering " "this account is not possible!" % (acc['name'])) return # ask & verify the old owner key old_priv_owner_key = getpass("Enter the old master password or owner " "key for @%s: " % (acc['name'])) old_pk = passwordkey_to_key(old_priv_owner_key, acc['name'], role="owner", prefix=acc.steem.prefix) old_public_owner_key = format(old_pk.get_public(), acc.steem.prefix) # get the new password to prepare all new keys new_pwd = getpass("Enter the new master password for @%s: " % (acc['name'])) key_auths = {} for role in ['owner', 'active', 'posting', 'memo']: pk = PasswordKey(acc['name'], new_pwd, role=role) key_auths[role] = format(pk.get_public_key(), acc.steem.prefix) if role == 'owner': new_priv_owner_key = str(pk.get_private()) # Assemble the account recovery operation recent_owner_authority = { "key_auths": [[old_public_owner_key, 1]], "account_auths": [], "weight_threshold": 1, "prefix": acc.steem.prefix } new_owner_authority = { "key_auths": [[key_auths['owner'], 1]], "account_auths": [], "weight_threshold": 1, "prefix": acc.steem.prefix } op = operations.Recover_account( **{ 'account_to_recover': acc['name'], 'new_owner_authority': new_owner_authority, 'recent_owner_authority': recent_owner_authority, 'extensions': [], "prefix": acc.steem.prefix }) # Send the recovery operations to the blockchain tb = TransactionBuilder(steem_instance=acc.steem) tb.appendOps([op]) tb.appendWif(new_priv_owner_key) tb.appendWif(old_priv_owner_key) tb.sign() tb.broadcast() logger.info("@%s recovered." % (acc['name'])) # Assemble the account update operation op = operations.Account_update( **{ "account": acc["name"], 'active': { 'account_auths': [], 'key_auths': [[key_auths['active'], 1]], "address_auths": [], 'weight_threshold': 1, 'prefix': acc.steem.prefix }, 'posting': { 'account_auths': acc['posting']['account_auths'], 'key_auths': [[key_auths['posting'], 1]], "address_auths": [], 'weight_threshold': 1, 'prefix': acc.steem.prefix }, 'memo_key': key_auths['memo'], "json_metadata": acc['json_metadata'], "prefix": acc.steem.prefix }) # Send the recovery operations to the blockchain tb = TransactionBuilder(steem_instance=acc.steem) tb.appendOps([op]) tb.appendWif(new_priv_owner_key) tb.sign() tb.broadcast() logger.info("SUCCESS: @%s's active, posting and memo keys updated." % (acc['name']))