コード例 #1
0
 def test_asset_reserve(self):
     op = operations.Asset_reserve(
         **{
             "fee": {
                 "amount": 0,
                 "asset_id": "1.3.0"
             },
             "payer": "1.2.0",
             "amount_to_reserve": {
                 "amount": 1234567890,
                 "asset_id": "1.3.0"
             },
             "extensions": []
         })
     ops = [Operation(op)]
     tx = Signed_Transaction(ref_block_num=ref_block_num,
                             ref_block_prefix=ref_block_prefix,
                             expiration=expiration,
                             operations=ops)
     tx = tx.sign([wif], chain=prefix)
     tx.verify([PrivateKey(wif).pubkey], "BTS")
     txWire = hexlify(bytes(tx)).decode("ascii")
     compare = ("f68585abf4dce7c80457010f00000000000000000000d202964"
                "900000000000000011f75065cb1155bfcaabaf55d3357d69679"
                "c7c1fe589b6dc0919fe1dde1a305009c360823a40c28907299a"
                "40c241db9cad86e27369d0e5a76b5832d585505ff177d")
     self.assertEqual(compare[:-130], txWire[:-130])
コード例 #2
0
    def compareConstructedTX(self):
        #    def test_online(self):
        #        self.maxDiff = None
        op = operations.Asset_reserve(
            **{
                "fee": {
                    "amount": 0,
                    "asset_id": "1.3.0"
                },
                "payer": "1.2.0",
                "amount_to_reserve": {
                    "amount": 1234567890,
                    "asset_id": "1.3.0"
                },
                "extensions": []
            })
        ops = [Operation(op)]
        tx = Signed_Transaction(ref_block_num=ref_block_num,
                                ref_block_prefix=ref_block_prefix,
                                expiration=expiration,
                                operations=ops)
        tx = tx.sign([wif], chain=prefix)
        tx.verify([PrivateKey(wif).pubkey], "BTS")
        txWire = hexlify(bytes(tx)).decode("ascii")
        print("=" * 80)
        pprint(tx.json())
        print("=" * 80)

        from grapheneapi.grapheneapi import GrapheneAPI
        rpc = GrapheneAPI("localhost", 8092)
        compare = rpc.serialize_transaction(tx.json())
        print(compare[:-130])
        print(txWire[:-130])
        print(txWire[:-130] == compare[:-130])
        self.assertEqual(compare[:-130], txWire[:-130])
コード例 #3
0
    def reserve(self, amount, account=None):
        """ Reserve/Burn an amount of this shares

            This removes the shares from the supply

            :param bitshares.amount.Amount amount: The amount to be burned.
            :param str account: (optional) the account to allow access
                to (defaults to ``default_account``)
        """
        assert isinstance(amount, Amount)
        if not account:
            if "default_account" in config:
                account = config["default_account"]
        if not account:
            raise ValueError("You need to provide an account")
        account = Account(account)
        op = operations.Asset_reserve(
            **{
                "fee": {
                    "amount": 0,
                    "asset_id": "1.3.0"
                },
                "payer": account["id"],
                "amount_to_reserve": {
                    "amount": int(amount),
                    "asset_id": amount["asset"]["id"]
                },
                "extensions": []
            })
        return self.finalizeOp(op, account, "active")
コード例 #4
0
 def test_asset_reserve(self):
     self.op = operations.Asset_reserve(**{
         "fee": {"amount": 0, "asset_id": "1.3.0"},
         "payer": "1.2.0",
         "amount_to_reserve": {"amount": 1234567890, "asset_id": "1.3.0"},
         "extensions": []
     })
     self.cm = ("f68585abf4dce7c80457010f00000000000000000000d202964"
                "900000000000000011f75065cb1155bfcaabaf55d3357d69679"
                "c7c1fe589b6dc0919fe1dde1a305009c360823a40c28907299a"
                "40c241db9cad86e27369d0e5a76b5832d585505ff177d")
     self.doit()