From: Luke Dashjr Date: Mon, 28 Jan 2013 21:05:57 +0000 (+0000) Subject: Bugfix: Serialized numbers are signed, so need an extra \x00 in the case of 0x80... X-Git-Url: https://git.novaco.in/?p=stratum-mining.git;a=commitdiff_plain;h=96e8e7e2937ea62757627350c3ea83f5bbae9772 Bugfix: Serialized numbers are signed, so need an extra \x00 in the case of 0x80...-0xff... Function body taken from Eloipool's bitcoin/script.py encodeUNum function (does not work for zero or negative numbers) --- diff --git a/lib/util.py b/lib/util.py index 3e88fd8..45da424 100644 --- a/lib/util.py +++ b/lib/util.py @@ -188,11 +188,16 @@ def deser_uint256_be(f): r += t << (i * 32) return r -def ser_number(num): +def ser_number(n): # For encoding nHeight into coinbase - d = struct.pack(" 127: + s[0] += 1 + s.append(n % 256) + n //= 256 + s.append(n) + return bytes(s) + def script_to_address(addr): d = address_to_pubkeyhash(addr) if not d: