Exemple #1
0
def test_unpackers():
    b = bytes(range(256))
    assert util.unpack_int32_from(b, 0) == (50462976, )
    assert util.unpack_int32_from(b, 42) == (757869354, )
    assert util.unpack_int64_from(b, 0) == (506097522914230528, )
    assert util.unpack_int64_from(b, 42) == (3544384782113450794, )

    assert util.unpack_uint16_from(b, 0) == (256, )
    assert util.unpack_uint16_from(b, 42) == (11050, )
    assert util.unpack_uint32_from(b, 0) == (50462976, )
    assert util.unpack_uint32_from(b, 42) == (757869354, )
    assert util.unpack_uint64_from(b, 0) == (506097522914230528, )
    assert util.unpack_uint64_from(b, 42) == (3544384782113450794, )
def _get_txout_value(coin, txout):
    if coin.EXTENDED_VOUT:
        s_value = txout.value[1:]
        int_value, = unpack_uint64_from(s_value[::-1], 0)
        return int_value
    else:
        return txout.value
Exemple #3
0
 def _get_txout_value(self, txout):
     assert self.coin.EXTENDED_VOUT
     s_value = txout.value[1:]
     version = txout.value[0]
     if version == 1 or version == 0xff:
         int_value, = unpack_uint64_from(s_value[::-1], 0)
         return int_value
     else:
         raise Exception("Confidential transactions are not yet handled")
Exemple #4
0
    def _get_txout_value(self, txout):
        assert self.coin.EXTENDED_VOUT

        conf_value_s = txout.value[1:]
        conf_value_v = txout.value[0]

        if conf_value_v == 1 or conf_value_v == 0xff:
            int_value, = unpack_uint64_from(conf_value_s[::-1], 0)
            return txout.asset[1:] + pack('<Q', int_value)
        else:
            raise Exception("Confidential transactions are not yet handled")
Exemple #5
0
 def _read_le_uint64(self):
     result, = unpack_uint64_from(self.binary, self.cursor)
     self.cursor += 8
     return result