Exemple #1
0
    def set_withdraw_vesting_route(self,
                                   to,
                                   percentage=100,
                                   account=None,
                                   auto_vest=False):
        """ Set up a vesting withdraw route. When vesting shares are
            withdrawn, they will be routed to these accounts based on the
            specified weights.

            :param str to: Recipient of the vesting withdrawal
            :param float percentage: The percent of the withdraw to go
                to the 'to' account.
            :param str account: (optional) the vesting account
            :param bool auto_vest: Set to true if the from account
                should receive the VESTS as VESTS, or false if it should
                receive them as STEEM. (defaults to ``False``)
        """
        if not account:
            account = configStorage.get("default_account")
        if not account:
            raise ValueError("You need to provide an account")

        op = operations.SetWithdrawVestingRoute(
            **{
                "from_account": account,
                "to_account": to,
                "percent": int(percentage * STEEMIT_1_PERCENT),
                "auto_vest": auto_vest
            })

        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()
Exemple #3
0
    def test_set_route(self):
        op = operations.SetWithdrawVestingRoute(
            **{
                "from_account": "xeroc",
                "to_account": "xeroc",
                "percent": 1000,
                "auto_vest": False
            })
        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 = ("f68585abf4dce7c804570114057865726f63057865726f63e803"
                   "0000011f12d2b8f93f9528f31979e0e1f59a6d45346a88c02ab2"
                   "c4115b10c9e273fc1e99621af0c2188598c84762b7e99ca63f6b"
                   "6be6fca318dd85b0d7a4f09f95579290")
        self.assertEqual(compare[:-130], tx_wire[:-130])