def withdraw_vesting(self, amount, account=None): """ Withdraw VESTS from the vesting account. :param float amount: number of VESTS to withdraw over a period of 104 weeks :param str account: (optional) the source account for the transfer if not ``default_account`` """ if not account: account = configStorage.get("default_account") if not account: raise ValueError("You need to provide an account") op = operations.WithdrawVesting( **{ "account": account, "vesting_shares": '{:.{prec}f} {asset}'.format( float(amount), prec=6, asset="VESTS"), }) return self.finalizeOp(op, account, "active")
def withdraw(): with open("config/config_withdraw.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'] withdraw_vesting_object = args['withdraw_vesting'] account_name = withdraw_vesting_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.WithdrawVesting(**withdraw_vesting_object)) # do SetWithdrawVestingRoute if 'SetWithdrawVestingRouteList' in args: SetWithdrawVestingRouteList = args['SetWithdrawVestingRouteList'] len_item = len(SetWithdrawVestingRouteList) for i in range(len_item): set_route_parameters = SetWithdrawVestingRouteList[i] operationsList.append( operations.SetWithdrawVestingRoute(**set_route_parameters)) # tell TransactionBuilder to use our serialized transfers tb.appendOps(operationsList) # we need to tell TransactionBuilder about # everyone who needs to sign the transaction. 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()
def test_withdraw_vesting(self): op = operations.WithdrawVesting(**{ "account": "foo", "vesting_shares": "100 VESTS", }) 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 = ( "f68585abf4dce7c80457010403666f6f00e1f5050000000006564553545300000" "00120772da57b15b62780ee3d8afedd8d46ffafb8c62788eab5ce01435df99e1d3" "6de549f260444866ff4e228cac445548060e018a872e7ee99ace324af9844f4c50a" ) self.assertEqual(compare[:-130], tx_wire[:-130])