From 5685129bd2eb316b5e31f0e6ece8295399a6cc57 Mon Sep 17 00:00:00 2001 From: Chris Shucksmith Date: Mon, 9 Oct 2023 13:19:21 +0100 Subject: [PATCH] Use python decimal classes within the JSON parser to prevent floating-point errors causing a validation failure. Observed in testnet e.g. 2023-10-07 below INFO:root:***RESULTS*** Height of proof: 2530608 Block proven against: 000000000000009ebfcdeb127badf0e55bc7c3656e13acf85ccf792fbecef1a3 Claimed amount (sats): 21029955090998 Proven amount(sats): 21029955090997 INFO:root:IMPORTANT! Call this script with --reconsider to bring your bitcoin node back to tip when satisfied with the results WARNING: More claimed 21029955090998 than proven 21029955090997 --- validate_reserves.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/validate_reserves.py b/validate_reserves.py index d153a2e..94faad1 100755 --- a/validate_reserves.py +++ b/validate_reserves.py @@ -3,6 +3,7 @@ import argparse import copy from collections import Counter +import decimal import json import logging import math @@ -37,7 +38,7 @@ def wrapper(method, params=[], **kwargs): r = requests.post(self.bitcoind, json=data, **kwargs) logging.debug(r.text) r.raise_for_status() - result = r.json() + result = r.json(parse_float=decimal.Decimal) if result["error"] is not None: raise JsonRPCException(result["error"]) return result["result"]