diff options
| author | Nsable-sh <nsable-sh@noreply.git.bitflash.network> | 2026-08-11 14:13:26 -0300 |
|---|---|---|
| committer | Nsable-sh <nsable-sh@noreply.git.bitflash.network> | 2026-08-11 14:13:26 -0300 |
| commit | 1839347459759fb3b23cc747ec4368b724fee008 (patch) | |
| tree | e5f6f7e13b6dd9eb260d7c75bafa19d873435c5c /scripts/verify-fair-launch.py | |
| parent | a83fae37099cb102beb5a4c174a4abe6ef3f24a4 (diff) | |
tools: harden chain audit scripts
Diffstat (limited to 'scripts/verify-fair-launch.py')
| -rw-r--r-- | scripts/verify-fair-launch.py | 346 |
1 files changed, 30 insertions, 316 deletions
diff --git a/scripts/verify-fair-launch.py b/scripts/verify-fair-launch.py index ce396fb..c33c8be 100644 --- a/scripts/verify-fair-launch.py +++ b/scripts/verify-fair-launch.py | |||
| @@ -1,299 +1,12 @@ | |||
| 1 | #!/usr/bin/env python3 | 1 | #!/usr/bin/env python3 |
| 2 | """Produce a deterministic Bitflash fair-launch audit report. | 2 | """Produce a deterministic Bitflash fair-launch audit report.""" |
| 3 | |||
| 4 | This verifier is intentionally self-contained. It parses Bitflash block files | ||
| 5 | directly, without Berkeley DB, without the node binary, and without network | ||
| 6 | access. The canonical JSON output is stable for the same inputs and can be | ||
| 7 | timestamped later with OpenTimestamps or any other external notary. | ||
| 8 | """ | ||
| 9 | 3 | ||
| 10 | import argparse | 4 | import argparse |
| 11 | import datetime as _dt | ||
| 12 | import hashlib | 5 | import hashlib |
| 13 | import json | ||
| 14 | import os | ||
| 15 | import struct | ||
| 16 | import sys | 6 | import sys |
| 17 | from pathlib import Path | 7 | from pathlib import Path |
| 18 | 8 | ||
| 19 | 9 | import bitflash_chain as chain | |
| 20 | MAGIC = bytes([0xBF, 0x20, 0x5C, 0xFD]) | ||
| 21 | COIN = 100_000_000 | ||
| 22 | GENESIS_HASH = "5bd7cb255d814e48cebcdfb72da4dc87b34bd774227f8ceb546c5640f4bdc169" | ||
| 23 | GENESIS_MERKLE = "1a45b4482532abb29b10e234d3f13132230525a339ecea91658ffa675a5b1325" | ||
| 24 | GENESIS_TIME = 1_753_315_200 | ||
| 25 | GENESIS_BITS = 0x1F0FFFFF | ||
| 26 | GENESIS_NONCE = 3141 | ||
| 27 | GENESIS_TEXT = "Bitflash 24/Jul/2026 Fair launch: one CPU one vote, no premine" | ||
| 28 | |||
| 29 | |||
| 30 | class ParseError(Exception): | ||
| 31 | pass | ||
| 32 | |||
| 33 | |||
| 34 | class Reader: | ||
| 35 | def __init__(self, data): | ||
| 36 | self.data = data | ||
| 37 | self.pos = 0 | ||
| 38 | |||
| 39 | def take(self, n): | ||
| 40 | if self.pos + n > len(self.data): | ||
| 41 | raise ParseError("unexpected end of data") | ||
| 42 | out = self.data[self.pos:self.pos + n] | ||
| 43 | self.pos += n | ||
| 44 | return out | ||
| 45 | |||
| 46 | def u8(self): | ||
| 47 | return self.take(1)[0] | ||
| 48 | |||
| 49 | def u32(self): | ||
| 50 | return struct.unpack("<I", self.take(4))[0] | ||
| 51 | |||
| 52 | def i32(self): | ||
| 53 | return struct.unpack("<i", self.take(4))[0] | ||
| 54 | |||
| 55 | def i64(self): | ||
| 56 | return struct.unpack("<q", self.take(8))[0] | ||
| 57 | |||
| 58 | |||
| 59 | def sha256d(data): | ||
| 60 | return hashlib.sha256(hashlib.sha256(data).digest()).digest() | ||
| 61 | |||
| 62 | |||
| 63 | def hash_hex(serialized): | ||
| 64 | return sha256d(serialized)[::-1].hex() | ||
| 65 | |||
| 66 | |||
| 67 | def compact_size(r): | ||
| 68 | first = r.u8() | ||
| 69 | if first < 253: | ||
| 70 | return first | ||
| 71 | if first == 253: | ||
| 72 | return struct.unpack("<H", r.take(2))[0] | ||
| 73 | if first == 254: | ||
| 74 | return r.u32() | ||
| 75 | return struct.unpack("<Q", r.take(8))[0] | ||
| 76 | |||
| 77 | |||
| 78 | def read_varbytes(r): | ||
| 79 | return r.take(compact_size(r)) | ||
| 80 | |||
| 81 | |||
| 82 | def ser_compact_size(n): | ||
| 83 | if n < 253: | ||
| 84 | return bytes([n]) | ||
| 85 | if n <= 0xFFFF: | ||
| 86 | return b"\xfd" + struct.pack("<H", n) | ||
| 87 | if n <= 0xFFFFFFFF: | ||
| 88 | return b"\xfe" + struct.pack("<I", n) | ||
| 89 | return b"\xff" + struct.pack("<Q", n) | ||
| 90 | |||
| 91 | |||
| 92 | def ser_varbytes(b): | ||
| 93 | return ser_compact_size(len(b)) + b | ||
| 94 | |||
| 95 | |||
| 96 | def ser_tx(tx): | ||
| 97 | out = bytearray() | ||
| 98 | out += struct.pack("<i", tx["version"]) | ||
| 99 | out += ser_compact_size(len(tx["vin"])) | ||
| 100 | for txin in tx["vin"]: | ||
| 101 | out += bytes.fromhex(txin["prevout_hash"])[::-1] | ||
| 102 | out += struct.pack("<I", txin["prevout_n"]) | ||
| 103 | out += ser_varbytes(bytes.fromhex(txin["script_sig_hex"])) | ||
| 104 | out += struct.pack("<I", txin["sequence"]) | ||
| 105 | out += ser_compact_size(len(tx["vout"])) | ||
| 106 | for txout in tx["vout"]: | ||
| 107 | out += struct.pack("<q", txout["value_satoshis"]) | ||
| 108 | out += ser_varbytes(bytes.fromhex(txout["script_pub_key_hex"])) | ||
| 109 | out += struct.pack("<I", tx["lock_time"]) | ||
| 110 | return bytes(out) | ||
| 111 | |||
| 112 | |||
| 113 | def parse_tx(r): | ||
| 114 | start = r.pos | ||
| 115 | tx = {"version": r.i32(), "vin": [], "vout": [], "lock_time": 0} | ||
| 116 | for _ in range(compact_size(r)): | ||
| 117 | prev_hash = r.take(32)[::-1].hex() | ||
| 118 | prev_n = r.u32() | ||
| 119 | script = read_varbytes(r).hex() | ||
| 120 | sequence = r.u32() | ||
| 121 | tx["vin"].append({ | ||
| 122 | "prevout_hash": prev_hash, | ||
| 123 | "prevout_n": prev_n, | ||
| 124 | "script_sig_hex": script, | ||
| 125 | "sequence": sequence, | ||
| 126 | }) | ||
| 127 | for _ in range(compact_size(r)): | ||
| 128 | value = r.i64() | ||
| 129 | script = read_varbytes(r).hex() | ||
| 130 | tx["vout"].append({ | ||
| 131 | "value_satoshis": value, | ||
| 132 | "value_btf": format_money(value), | ||
| 133 | "script_pub_key_hex": script, | ||
| 134 | }) | ||
| 135 | tx["lock_time"] = r.u32() | ||
| 136 | raw = r.data[start:r.pos] | ||
| 137 | tx["txid"] = hash_hex(raw) | ||
| 138 | return tx | ||
| 139 | |||
| 140 | |||
| 141 | def merkle_root(txids): | ||
| 142 | if not txids: | ||
| 143 | return "0" * 64 | ||
| 144 | layer = [bytes.fromhex(x)[::-1] for x in txids] | ||
| 145 | while len(layer) > 1: | ||
| 146 | nxt = [] | ||
| 147 | for i in range(0, len(layer), 2): | ||
| 148 | left = layer[i] | ||
| 149 | right = layer[i + 1] if i + 1 < len(layer) else left | ||
| 150 | nxt.append(sha256d(left + right)) | ||
| 151 | layer = nxt | ||
| 152 | return layer[0][::-1].hex() | ||
| 153 | |||
| 154 | |||
| 155 | def parse_block(payload, file_name="", offset=0): | ||
| 156 | r = Reader(payload) | ||
| 157 | header = r.take(80) | ||
| 158 | version, = struct.unpack("<i", header[0:4]) | ||
| 159 | prev = header[4:36][::-1].hex() | ||
| 160 | merkle = header[36:68][::-1].hex() | ||
| 161 | ntime, bits, nonce = struct.unpack("<III", header[68:80]) | ||
| 162 | txs = [parse_tx(r) for _ in range(compact_size(r))] | ||
| 163 | if r.pos != len(payload): | ||
| 164 | raise ParseError("trailing bytes inside block") | ||
| 165 | txids = [tx["txid"] for tx in txs] | ||
| 166 | return { | ||
| 167 | "hash": hash_hex(header), | ||
| 168 | "version": version, | ||
| 169 | "previous_hash": prev, | ||
| 170 | "merkle_root": merkle, | ||
| 171 | "computed_merkle_root": merkle_root(txids), | ||
| 172 | "time": ntime, | ||
| 173 | "time_utc": utc(ntime), | ||
| 174 | "bits": "0x%08x" % bits, | ||
| 175 | "nonce": nonce, | ||
| 176 | "tx_count": len(txs), | ||
| 177 | "transactions": txs, | ||
| 178 | "source_file": file_name, | ||
| 179 | "source_offset": offset, | ||
| 180 | } | ||
| 181 | |||
| 182 | |||
| 183 | def iter_block_files(datadir): | ||
| 184 | for path in sorted(Path(datadir).glob("blk*.dat")): | ||
| 185 | yield path | ||
| 186 | |||
| 187 | |||
| 188 | def read_blocks(datadir, limit): | ||
| 189 | blocks = [] | ||
| 190 | for path in iter_block_files(datadir): | ||
| 191 | data = path.read_bytes() | ||
| 192 | pos = 0 | ||
| 193 | while True: | ||
| 194 | idx = data.find(MAGIC, pos) | ||
| 195 | if idx < 0: | ||
| 196 | break | ||
| 197 | if idx + 8 > len(data): | ||
| 198 | break | ||
| 199 | size = struct.unpack("<I", data[idx + 4:idx + 8])[0] | ||
| 200 | start = idx + 8 | ||
| 201 | end = start + size | ||
| 202 | if end > len(data): | ||
| 203 | break | ||
| 204 | blocks.append(parse_block(data[start:end], path.name, start)) | ||
| 205 | if limit and len(blocks) >= limit: | ||
| 206 | return blocks | ||
| 207 | pos = end | ||
| 208 | return blocks | ||
| 209 | |||
| 210 | |||
| 211 | def genesis_transaction(): | ||
| 212 | script_sig = ( | ||
| 213 | bytes.fromhex("04ffff001d") | ||
| 214 | + b"\x01\x04" | ||
| 215 | + bytes([len(GENESIS_TEXT)]) | ||
| 216 | + GENESIS_TEXT.encode("ascii") | ||
| 217 | ) | ||
| 218 | pubkey_num = bytes.fromhex( | ||
| 219 | "5f1df16b2b704c8a578d0bbaf74d385cde12c11ee50455f3c438ef4c3fbcf649" | ||
| 220 | "b6de611feae06279a60939e028a8d65c10b73071a6f16719274855feb0fd8a6704" | ||
| 221 | ) | ||
| 222 | # The genesis source uses CScript << CBigNum("0x..."), and CBigNum::getvch() | ||
| 223 | # returns the minimal little-endian script number representation. | ||
| 224 | script_pub_key = bytes([65]) + pubkey_num[::-1] + b"\xac" | ||
| 225 | tx = { | ||
| 226 | "version": 1, | ||
| 227 | "vin": [{ | ||
| 228 | "prevout_hash": "0" * 64, | ||
| 229 | "prevout_n": 0xFFFFFFFF, | ||
| 230 | "script_sig_hex": script_sig.hex(), | ||
| 231 | "sequence": 0xFFFFFFFF, | ||
| 232 | }], | ||
| 233 | "vout": [{ | ||
| 234 | "value_satoshis": 50 * COIN, | ||
| 235 | "value_btf": format_money(50 * COIN), | ||
| 236 | "script_pub_key_hex": script_pub_key.hex(), | ||
| 237 | }], | ||
| 238 | "lock_time": 0, | ||
| 239 | } | ||
| 240 | tx["txid"] = hash_hex(ser_tx(tx)) | ||
| 241 | return tx | ||
| 242 | |||
| 243 | |||
| 244 | def reconstructed_genesis(): | ||
| 245 | tx = genesis_transaction() | ||
| 246 | header = ( | ||
| 247 | struct.pack("<i", 1) | ||
| 248 | + bytes(32) | ||
| 249 | + bytes.fromhex(tx["txid"])[::-1] | ||
| 250 | + struct.pack("<III", GENESIS_TIME, GENESIS_BITS, GENESIS_NONCE) | ||
| 251 | ) | ||
| 252 | return { | ||
| 253 | "hash": hash_hex(header), | ||
| 254 | "version": 1, | ||
| 255 | "previous_hash": "0" * 64, | ||
| 256 | "merkle_root": tx["txid"], | ||
| 257 | "computed_merkle_root": tx["txid"], | ||
| 258 | "time": GENESIS_TIME, | ||
| 259 | "time_utc": utc(GENESIS_TIME), | ||
| 260 | "bits": "0x%08x" % GENESIS_BITS, | ||
| 261 | "nonce": GENESIS_NONCE, | ||
| 262 | "tx_count": 1, | ||
| 263 | "transactions": [tx], | ||
| 264 | "source_file": "reconstructed-from-source-constants", | ||
| 265 | "source_offset": 0, | ||
| 266 | } | ||
| 267 | |||
| 268 | |||
| 269 | def format_money(value): | ||
| 270 | sign = "-" if value < 0 else "" | ||
| 271 | value = abs(value) | ||
| 272 | return "%s%d.%08d" % (sign, value // COIN, value % COIN) | ||
| 273 | |||
| 274 | |||
| 275 | def utc(ts): | ||
| 276 | return _dt.datetime.fromtimestamp(ts, _dt.timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ") | ||
| 277 | |||
| 278 | |||
| 279 | def default_datadir(): | ||
| 280 | if os.name == "nt" and os.environ.get("APPDATA"): | ||
| 281 | return os.path.join(os.environ["APPDATA"], "Bitflash") | ||
| 282 | if os.environ.get("HOME"): | ||
| 283 | return os.path.join(os.environ["HOME"], ".bitflash") | ||
| 284 | return "." | ||
| 285 | |||
| 286 | |||
| 287 | def is_coinbase(tx): | ||
| 288 | return ( | ||
| 289 | len(tx["vin"]) == 1 | ||
| 290 | and tx["vin"][0]["prevout_hash"] == "0" * 64 | ||
| 291 | and tx["vin"][0]["prevout_n"] == 0xFFFFFFFF | ||
| 292 | ) | ||
| 293 | |||
| 294 | |||
| 295 | def canonical_bytes(report): | ||
| 296 | return (json.dumps(report, sort_keys=True, separators=(",", ":"), ensure_ascii=True) + "\n").encode("ascii") | ||
| 297 | 10 | ||
| 298 | 11 | ||
| 299 | def build_report(blocks, source_mode): | 12 | def build_report(blocks, source_mode): |
| @@ -307,7 +20,7 @@ def build_report(blocks, source_mode): | |||
| 307 | if not block["transactions"]: | 20 | if not block["transactions"]: |
| 308 | continue | 21 | continue |
| 309 | cb = block["transactions"][0] | 22 | cb = block["transactions"][0] |
| 310 | if is_coinbase(cb): | 23 | if chain.is_coinbase(cb): |
| 311 | amount = sum(out["value_satoshis"] for out in cb["vout"]) | 24 | amount = sum(out["value_satoshis"] for out in cb["vout"]) |
| 312 | total_mined += amount | 25 | total_mined += amount |
| 313 | coinbase_outputs.append({ | 26 | coinbase_outputs.append({ |
| @@ -315,18 +28,18 @@ def build_report(blocks, source_mode): | |||
| 315 | "block_hash": block["hash"], | 28 | "block_hash": block["hash"], |
| 316 | "coinbase_txid": cb["txid"], | 29 | "coinbase_txid": cb["txid"], |
| 317 | "value_satoshis": amount, | 30 | "value_satoshis": amount, |
| 318 | "value_btf": format_money(amount), | 31 | "value_btf": chain.format_money(amount), |
| 319 | "outputs": cb["vout"], | 32 | "outputs": cb["vout"], |
| 320 | }) | 33 | }) |
| 321 | non_coinbase_txs += sum(1 for tx in block["transactions"] if not is_coinbase(tx)) | 34 | non_coinbase_txs += sum(1 for tx in block["transactions"] if not chain.is_coinbase(tx)) |
| 322 | 35 | ||
| 323 | checks = { | 36 | checks = { |
| 324 | "genesis_hash_matches_source": genesis["hash"] == GENESIS_HASH, | 37 | "genesis_hash_matches_source": genesis["hash"] == chain.GENESIS_HASH, |
| 325 | "genesis_merkle_matches_source": genesis["merkle_root"] == GENESIS_MERKLE, | 38 | "genesis_merkle_matches_source": genesis["merkle_root"] == chain.GENESIS_MERKLE, |
| 326 | "computed_merkle_matches_header": genesis["computed_merkle_root"] == genesis["merkle_root"], | 39 | "computed_merkle_matches_header": genesis["computed_merkle_root"] == genesis["merkle_root"], |
| 327 | "genesis_has_single_transaction": genesis["tx_count"] == 1, | 40 | "genesis_has_single_transaction": genesis["tx_count"] == 1, |
| 328 | "genesis_transaction_is_coinbase": bool(genesis["transactions"] and is_coinbase(genesis["transactions"][0])), | 41 | "genesis_transaction_is_coinbase": bool(genesis["transactions"] and chain.is_coinbase(genesis["transactions"][0])), |
| 329 | "genesis_supply_is_50_btf": sum(out["value_satoshis"] for out in launch_outputs) == 50 * COIN, | 42 | "genesis_supply_is_50_btf": sum(out["value_satoshis"] for out in launch_outputs) == 50 * chain.COIN, |
| 330 | } | 43 | } |
| 331 | 44 | ||
| 332 | report = { | 45 | report = { |
| @@ -336,17 +49,17 @@ def build_report(blocks, source_mode): | |||
| 336 | "chain": { | 49 | "chain": { |
| 337 | "name": "Bitflash", | 50 | "name": "Bitflash", |
| 338 | "ticker": "BTF", | 51 | "ticker": "BTF", |
| 339 | "message_start_hex": MAGIC.hex(), | 52 | "message_start_hex": chain.MAGIC.hex(), |
| 340 | "coin": COIN, | 53 | "coin": chain.COIN, |
| 341 | }, | 54 | }, |
| 342 | "source_constants": { | 55 | "source_constants": { |
| 343 | "genesis_hash": GENESIS_HASH, | 56 | "genesis_hash": chain.GENESIS_HASH, |
| 344 | "genesis_merkle_root": GENESIS_MERKLE, | 57 | "genesis_merkle_root": chain.GENESIS_MERKLE, |
| 345 | "genesis_time": GENESIS_TIME, | 58 | "genesis_time": chain.GENESIS_TIME, |
| 346 | "genesis_time_utc": utc(GENESIS_TIME), | 59 | "genesis_time_utc": chain.utc(chain.GENESIS_TIME), |
| 347 | "genesis_bits": "0x%08x" % GENESIS_BITS, | 60 | "genesis_bits": "0x%08x" % chain.GENESIS_BITS, |
| 348 | "genesis_nonce": GENESIS_NONCE, | 61 | "genesis_nonce": chain.GENESIS_NONCE, |
| 349 | "genesis_message": GENESIS_TEXT, | 62 | "genesis_message": chain.GENESIS_TEXT, |
| 350 | }, | 63 | }, |
| 351 | "scanned": { | 64 | "scanned": { |
| 352 | "block_count": len(blocks), | 65 | "block_count": len(blocks), |
| @@ -354,7 +67,7 @@ def build_report(blocks, source_mode): | |||
| 354 | "last_height": len(blocks) - 1, | 67 | "last_height": len(blocks) - 1, |
| 355 | "non_coinbase_transactions": non_coinbase_txs, | 68 | "non_coinbase_transactions": non_coinbase_txs, |
| 356 | "total_coinbase_satoshis": total_mined, | 69 | "total_coinbase_satoshis": total_mined, |
| 357 | "total_coinbase_btf": format_money(total_mined), | 70 | "total_coinbase_btf": chain.format_money(total_mined), |
| 358 | }, | 71 | }, |
| 359 | "genesis": { | 72 | "genesis": { |
| 360 | "hash": genesis["hash"], | 73 | "hash": genesis["hash"], |
| @@ -381,7 +94,7 @@ def build_report(blocks, source_mode): | |||
| 381 | ], | 94 | ], |
| 382 | }, | 95 | }, |
| 383 | } | 96 | } |
| 384 | report["attestation_payload_sha256"] = hashlib.sha256(canonical_bytes(report)).hexdigest() | 97 | report["attestation_payload_sha256"] = hashlib.sha256(chain.canonical_bytes(report)).hexdigest() |
| 385 | return report | 98 | return report |
| 386 | 99 | ||
| 387 | 100 | ||
| @@ -397,7 +110,7 @@ def print_text(report): | |||
| 397 | print(" merkle: %s" % report["genesis"]["merkle_root"]) | 110 | print(" merkle: %s" % report["genesis"]["merkle_root"]) |
| 398 | print(" time: %s" % report["genesis"]["time_utc"]) | 111 | print(" time: %s" % report["genesis"]["time_utc"]) |
| 399 | print(" txs: %d" % report["genesis"]["tx_count"]) | 112 | print(" txs: %d" % report["genesis"]["tx_count"]) |
| 400 | print(" supply: %s BTF" % format_money(sum(o["value_satoshis"] for o in report["genesis"]["outputs"]))) | 113 | print(" supply: %s BTF" % chain.format_money(sum(o["value_satoshis"] for o in report["genesis"]["outputs"]))) |
| 401 | print() | 114 | print() |
| 402 | print("Scanned") | 115 | print("Scanned") |
| 403 | print(" blocks: %d" % report["scanned"]["block_count"]) | 116 | print(" blocks: %d" % report["scanned"]["block_count"]) |
| @@ -417,7 +130,7 @@ def print_text(report): | |||
| 417 | 130 | ||
| 418 | def main(argv): | 131 | def main(argv): |
| 419 | ap = argparse.ArgumentParser(description=__doc__) | 132 | ap = argparse.ArgumentParser(description=__doc__) |
| 420 | ap.add_argument("--datadir", default=default_datadir(), help="Bitflash data directory") | 133 | ap.add_argument("--datadir", default=chain.default_datadir(), help="Bitflash data directory") |
| 421 | ap.add_argument("--max-blocks", type=int, default=100, help="number of blocks to scan from blk*.dat") | 134 | ap.add_argument("--max-blocks", type=int, default=100, help="number of blocks to scan from blk*.dat") |
| 422 | ap.add_argument("--json", action="store_true", help="print canonical JSON") | 135 | ap.add_argument("--json", action="store_true", help="print canonical JSON") |
| 423 | ap.add_argument("--out", help="write canonical JSON to this path") | 136 | ap.add_argument("--out", help="write canonical JSON to this path") |
| @@ -426,18 +139,19 @@ def main(argv): | |||
| 426 | args = ap.parse_args(argv) | 139 | args = ap.parse_args(argv) |
| 427 | 140 | ||
| 428 | if args.reconstruct_genesis: | 141 | if args.reconstruct_genesis: |
| 429 | blocks = [reconstructed_genesis()] | 142 | blocks = [chain.reconstructed_genesis()] |
| 430 | source_mode = "reconstructed-genesis" | 143 | source_mode = "reconstructed-genesis" |
| 431 | datadir = "" | ||
| 432 | else: | 144 | else: |
| 433 | datadir = Path(args.datadir) | 145 | blocks = chain.read_blocks(args.datadir, args.max_blocks) |
| 434 | blocks = read_blocks(datadir, args.max_blocks) | ||
| 435 | if not blocks: | 146 | if not blocks: |
| 436 | raise SystemExit("no Bitflash blocks found in %s; use --reconstruct-genesis for a source-only check" % datadir) | 147 | raise SystemExit("no Bitflash blocks found in %s; use --reconstruct-genesis for a source-only check" % args.datadir) |
| 437 | source_mode = "local-block-files" | 148 | source_mode = "local-block-files" |
| 438 | 149 | ||
| 439 | report = build_report(blocks, source_mode) | 150 | try: |
| 440 | data = canonical_bytes(report) | 151 | report = build_report(blocks, source_mode) |
| 152 | except chain.ParseError as e: | ||
| 153 | raise SystemExit(str(e)) | ||
| 154 | data = chain.canonical_bytes(report) | ||
| 441 | 155 | ||
| 442 | if args.out: | 156 | if args.out: |
| 443 | Path(args.out).write_bytes(data) | 157 | Path(args.out).write_bytes(data) |