X-Git-Url: https://git.novaco.in/?p=stratum-mining.git;a=blobdiff_plain;f=lib%2Futil.py;h=36e259d7198aa7dc80914f43b4f4c09259f047e3;hp=45da424f72895accbf35feaa5b9abb111cc1d2c5;hb=679245b565edcb2a03d865df3c08e86c0d6f402d;hpb=8a7474eb0eefdbc68e9b57371a68c25f33427f0d diff --git a/lib/util.py b/lib/util.py index 45da424..36e259d 100644 --- a/lib/util.py +++ b/lib/util.py @@ -139,14 +139,14 @@ def b58decode(v, length): 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): @@ -160,17 +160,17 @@ def address_to_pubkeyhash(addr): 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): @@ -179,7 +179,7 @@ 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 @@ -203,4 +203,4 @@ def script_to_address(addr): 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'