result = chr(0)*nPad + result
if length is not None and len(result) != length:
return None
-
+
return result
def reverse_hash(h):
# This only revert byte order, nothing more
if len(h) != 64:
raise Exception('hash must have 64 hexa chars')
-
+
return ''.join([ h[56-i:64-i] for i in range(0, 64, 8) ])
def doublesha(b):
addr = b58decode(addr, 25)
except:
return None
-
+
if addr is None:
return None
-
+
ver = addr[0]
cksumA = addr[-4:]
cksumB = doublesha(addr[:-4])[:4]
-
+
if cksumA != cksumB:
return None
-
+
return (ver, addr[1:-4])
def ser_uint256_be(u):
for i in xrange(8):
rs += struct.pack(">I", u & 0xFFFFFFFFL)
u >>= 32
- return rs
+ return rs
def deser_uint256_be(f):
r = 0L
if not d:
raise ValueError('invalid address')
(ver, pubkeyhash) = d
- return b'\x76\xa9\x14' + pubkeyhash + b'\x88\xac'
\ No newline at end of file
+ return b'\x76\xa9\x14' + pubkeyhash + b'\x88\xac'