From: slush0 Date: Mon, 28 Jan 2013 23:51:07 +0000 (-0800) Subject: Merge pull request #2 from luke-jr/bugfix_sernum X-Git-Url: https://git.novaco.in/?p=stratum-mining.git;a=commitdiff_plain;h=b825c123e3265118a43cc5a9cf49315eff694a16;hp=fa88ef8cb19bf006cacb988a0ce42a86f72bcb23 Merge pull request #2 from luke-jr/bugfix_sernum Bugfix: Serialized numbers are signed, so need an extra \x00 in the case of 0x80...-0xff... This was a reason for rejecting v2 blocks on testnet. --- 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: