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:
            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"))
    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())

        self.assertEqual(compare[:-130], tx_wire[:-130])
 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())