def test_witness_vote(self): op = operations.AccountWitnessVote(**{ "account": "xeroc", "witness": "chainsquad", "approve": True, }) ops = [operations.Operation(op)] tx = SignedTransaction(ref_block_num=ref_block_num, ref_block_prefix=ref_block_prefix, expiration=expiration, operations=ops) tx = tx.sign([wif], chain=self.steem.chain_params) tx_wire = hexlify(bytes(tx)).decode("ascii") compare = ("f68585abf4dce7c80457010c057865726f630a636" "861696e73717561640100011f16b43411e11f4739" "4c1624a3c4d3cf4daba700b8690f494e6add7ad9b" "ac735ce7775d823aa66c160878cb3348e6857c531" "114d229be0202dc0857f8f03a00369") self.assertEqual(compare[:-130], tx_wire[:-130])
def approve_witness(self, witness, account=None, approve=True): """ Vote **for** a witness. This method adds a witness to your set of approved witnesses. To remove witnesses see ``disapprove_witness``. :param str witness: witness to approve :param str account: (optional) the account to allow access to (defaults to ``default_account``) """ if not account: account = configStorage.get("default_account") if not account: raise ValueError("You need to provide an account") account = Account(account, steemd_instance=self.steemd) op = operations.AccountWitnessVote(**{ "account": account["name"], "witness": witness, "approve": approve, }) return self.finalizeOp(op, account["name"], "active")
def vote_witness(): with open("config_vote_witness.json", 'r') as load_f: input_args = json.load(load_f) for i in range(len(input_args)): args = input_args[i] key = args['key'] operation_object = args['vote_witness'] account_name = operation_object['account'] steem = Steem(nodes=nodes_remote, keys=key) # now we can construct the transaction # we will set no_broadcast to True because # we don't want to really send funds, just testing. tb = TransactionBuilder() # lets serialize our transfers into a format Steem can understand operationsList = [] operationsList.append( operations.AccountWitnessVote(**operation_object)) # tell TransactionBuilder to use our serialized transfers tb.appendOps(operationsList) # we need to tell TransactionBuilder about # everyone who needs to sign the transaction. # since all payments are made from `richguy`, # we just need to do this once tb.appendSigner(account_name, 'active') # sign the transaction tb.sign() # broadcast the transaction (publish to steem) # since we specified no_broadcast=True earlier # this method won't actually do anything tx = tb.broadcast() print(account_name + " done")