Example #1
0
    def test_sighash(self):
        first = True
        for vector in self.data:

            # Ignore first header row in the JSON.
            if first:
                first = False
                continue

            tx = transaction.deserialize(convert.hex_to_bytes(vector[0]))
            script = convert.hex_to_bytes(vector[1])
            index = int(vector[2])
            hashtype = int(vector[3]) & 0xffffffff  # This must be unsigned int
            sighash = convert.hex_to_bytes(vector[4])[::-1]  # It's reversed for some reason?

            my_sighash = transaction.sighash(tx, index, script, hashtype)

            self.assertEqual(
                sighash,
                my_sighash,
                'hashtype = {:x}'.format(hashtype)
            )
Example #2
0
 def test_deserialization(self):
     tx_obj = transaction.deserialize(self.tx_bin)
     self.assertEqual(tx_obj, self.tx_obj)