예제 #1
0
    def convert(self, amount, account=None, request_id=None):
        """ Convert SteemDollars to Steem (takes one week to settle)

            :param float amount: number of VESTS to withdraw

            :param str account: (optional) the source account for the transfer
            if not ``default_account``

            :param str request_id: (optional) identifier for tracking the
            conversion`

        """
        if not account:
            account = configStorage.get("default_account")
        if not account:
            raise ValueError("You need to provide an account")

        if request_id:
            request_id = int(request_id)
        else:
            request_id = random.getrandbits(32)
        op = operations.Convert(
            **{
                "owner":
                account,
                "requestid":
                request_id,
                "amount":
                '{:.{prec}f} {asset}'.format(
                    float(amount), prec=3, asset='SBD')
            })

        return self.finalizeOp(op, account, "active")
예제 #2
0
    def test_convert(self):
        op = operations.Convert(**{
            "owner": "xeroc",
            "requestid": 2342343235,
            "amount": "100.000 SBD"
        })
        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 = ("f68585abf4dce7c804570108057865726f6343529d8ba0860100000"
                   "00000035342440000000000011f3d22eb66e5cddcc90f5d6ca0bd7a"
                   "43e0ab811ecd480022af8a847c45eac720b342188d55643d8cb1711"
                   "f516e9879be2fa7dfa329b518f19df4afaaf4f41f7715")
        self.assertEqual(compare[:-130], tx_wire[:-130])