python-bitcoinlib
python-bitcoinlib copied to clipboard
Inconsistency in uint256_from_compact?
trafficstars
Maybe I'm missing something, but shouldn't this:
>>> uint256_from_compact(0x1d00ffff)
26959535291011309493156476344723991336010898738574164086137773096960L
return this?
26959946667150639794667015087019630673637144422540572481103610249215L
More info from my tests:
>>> m = int('0x00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF', 16)
>>> m
26959946667150639794667015087019630673637144422540572481103610249215L
>>> compact_from_uint256(m)
486604799L
>>> h = '%x' % compact_from_uint256(m)
>>> h
'1d00ffff'
>>> uint256_from_compact(compact_from_uint256(m))
26959535291011309493156476344723991336010898738574164086137773096960L
>>>