Thanks ArtForz! ^_^
Quote from: ArtForz on August 04, 2010, 2:21:22 PM UTCCode:import struct
def SetCompact(nCompact): """convert bc compact uint to number""" nSize = (nCompact >> 24) & 0xFF tbuf = “\x00\x00\x00” + chr(nSize) if nSize >= 1: tbuf += chr((nCompact >> 16) & 0xFF) if nSize >= 2: tbuf += chr((nCompact >> 8) & 0xFF) if nSize >= 3: tbuf += chr((nCompact >> 0) & 0xFF) tbuf += “\x00” * (nSize - 3) return mpi2num(tbuf)
def uint256_from_compact(c):
nbytes = (c >> 24) & 0xFF
v = (c & 0xFFFFFFL) << (8 * (nbytes - 3))
return v
I confirmed again that both of these produce same output when using 0x1d00ffff