compare_blocks
Analyze and compare Bitcoin blockchain statistics between two specific block heights to identify differences in transaction data, mining details, and network metrics.
Instructions
Compare block statistics between two block heights side by side.
Args: height1: First block height height2: Second block height
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| height1 | Yes | ||
| height2 | Yes |
Output Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/bitcoin_mcp/server.py:900-931 (handler)The implementation of the compare_blocks tool, which takes two block heights, retrieves their statistics, and returns a side-by-side comparison including deltas for key metrics.
def compare_blocks(height1: int, height2: int) -> str: """Compare block statistics between two block heights side by side. Args: height1: First block height height2: Second block height """ try: stats1 = get_rpc().getblockstats(height1) stats2 = get_rpc().getblockstats(height2) except Exception as e: return json.dumps({"error": str(e)}) compare_keys = [ "total_fee", "avgfee", "medianfee", "maxfee", "minfee", "total_weight", "total_size", "txs", "subsidy", "avgfeerate", "mediantime", ] comparison = {} for key in compare_keys: v1 = stats1.get(key) v2 = stats2.get(key) if v1 is None and v2 is None: continue entry = {"block_1": v1, "block_2": v2} if isinstance(v1, (int, float)) and isinstance(v2, (int, float)): entry["delta"] = v2 - v1 comparison[key] = entry return json.dumps({ "height_1": height1, "height_2": height2, "comparison": comparison, })