Ejemplo n.º 1
0
    def compareConstructedTX(self):
        #    def test_online(self):
        #        self.maxDiff = None
        op = operations.CommentOptions(
            **{
                "author": "xeroc",
                "permlink": "piston",
                "max_accepted_payout": "1000000.000 SBD",
                "percent_steem_dollars": 10000,
                "allow_votes": True,
                "allow_curation_rewards": True,
                "extensions": []
            })
        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(compat_bytes(tx)).decode("ascii")

        # todo
        rpc = self.steem.commit.wallet
        compare = rpc.serialize_transaction(tx.json())

        pprint(tx.json())

        print("\n")
        print(compare[:-130])
        print(tx_wire[:-130])
        print("\n")

        print(tx_wire[:-130] == compare[:-130])
        self.assertEqual(compare[:-130], tx_wire[:-130])
Ejemplo n.º 2
0
    def compareConstructedTX(self):
        #    def test_online(self):
        #        self.maxDiff = None
        op = operations.CommentOptions(
            **{
                "author": "xeroc",
                "permlink": "piston",
                "max_accepted_payout": "1000000.000 SBD",
                "percent_steem_dollars": 10000,
                "allow_votes": True,
                "allow_curation_rewards": True,
                "extensions": []
            })
        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")

        # todo
        rpc = self.steem.commit.wallet
        compare = rpc.serialize_transaction(tx.json())

        pprint(tx.json())

        print("\n")
        print(compare[:-130])
        print(tx_wire[:-130])
        print("\n")

        print(tx_wire[:-130] == compare[:-130])
        self.assertEqual(compare[:-130], tx_wire[:-130])
Ejemplo n.º 3
0
    def sign(self):
        """ Sign a provided transaction witht he provided key(s)

            :param dict tx: The transaction to be signed and returned
            :param string wifs: One or many wif keys to use for signing
                a transaction. If not present, the keys will be loaded
                from the wallet as defined in "missing_signatures" key
                of the transactions.
        """

        # We need to set the default prefix, otherwise pubkeys are
        # presented wrongly!
        if self.steemd:
            operations.default_prefix = self.steemd.chain_params["prefix"]
        elif "blockchain" in self:
            operations.default_prefix = self["blockchain"]["prefix"]

        try:
            signedtx = SignedTransaction(**self.json())
        except Exception as e:  # noqa FIXME(sneak)
            raise e

        if not any(self.wifs):
            raise MissingKeyError

        signedtx.sign(self.wifs, chain=self.steemd.chain_params)
        self["signatures"].extend(signedtx.json().get("signatures"))
Ejemplo n.º 4
0
    def sign(self):
        """ Sign a provided transaction witht he provided key(s)

            :param dict tx: The transaction to be signed and returned
            :param string wifs: One or many wif keys to use for signing
                a transaction. If not present, the keys will be loaded
                from the wallet as defined in "missing_signatures" key
                of the transactions.
        """

        # We need to set the default prefix, otherwise pubkeys are
        # presented wrongly!
        if self.steemd:
            operations.default_prefix = self.steemd.chain_params["prefix"]
        elif "blockchain" in self:
            operations.default_prefix = self["blockchain"]["prefix"]

        try:
            signedtx = SignedTransaction(**self.json())
        except:  # noqa FIXME(sneak)
            raise ValueError("Invalid TransactionBuilder Format")

        if not any(self.wifs):
            raise MissingKeyError

        signedtx.sign(self.wifs, chain=self.steemd.chain_params)
        self["signatures"].extend(signedtx.json().get("signatures"))
Ejemplo n.º 5
0
 def constructTx(self):
     if isinstance(self.op, list):
         ops = [Operation(o) for o in self.op]
     else:
         ops = [Operation(self.op)]
     expiration = fmt_time_from_now(self.expiration)
     ref_block_num, ref_block_prefix = get_block_params(self.steemd)
     tx = SignedTransaction(ref_block_num=ref_block_num,
                            ref_block_prefix=ref_block_prefix,
                            expiration=expiration,
                            operations=ops)
     super(TransactionBuilder, self).__init__(tx.json())
Ejemplo n.º 6
0
 def constructTx(self):
     if isinstance(self.op, list):
         ops = [Operation(o) for o in self.op]
     else:
         ops = [Operation(self.op)]
     expiration = fmt_time_from_now(self.expiration)
     ref_block_num, ref_block_prefix = get_block_params(self.steemd)
     tx = SignedTransaction(
         ref_block_num=ref_block_num,
         ref_block_prefix=ref_block_prefix,
         expiration=expiration,
         operations=ops)
     super(TransactionBuilder, self).__init__(tx.json())
Ejemplo n.º 7
0
    def sign(self):
        """ Sign a provided transaction witht he provided key(s)

            :param dict tx: The transaction to be signed and returned
            :param string wifs: One or many wif keys to use for signing
                a transaction. If not present, the keys will be loaded
                from the wallet as defined in "missing_signatures" key
                of the transactions.
        """
        try:
            signedtx = SignedTransaction(**self.json())
        except:  # noqa FIXME(sneak)
            raise ValueError("Invalid TransactionBuilder Format")

        if not any(self.wifs):
            raise MissingKeyError

        signedtx.sign(self.wifs, chain=self.steemd.chain_params)
        self["signatures"].extend(signedtx.json().get("signatures"))