|
| 1 | +# Dash Core RPC Documentation Tools |
| 2 | + |
| 3 | +This directory contains tools to assist with updating Dash Core RPC documentation when new versions are released. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +These scripts automate the process of: |
| 8 | + |
| 9 | +1. Extracting all RPC command help text from Dash Core |
| 10 | +2. Comparing RPC definitions between versions |
| 11 | +3. Generating human-readable change summaries |
| 12 | + |
| 13 | +This workflow helps documentation maintainers quickly identify what changed between Dash Core versions and update the RPC reference docs accordingly. |
| 14 | + |
| 15 | +## Prerequisites |
| 16 | + |
| 17 | +### Required Software |
| 18 | + |
| 19 | +* **dash-cli**: The Dash Core command-line interface (from your local Dash Core build or installation) |
| 20 | +* **Running Dash node**: A Dash node with RPC access (testnet, mainnet, or regtest) |
| 21 | +* **Python 3**: For running the comparison script |
| 22 | +* **jq**: For JSON processing (used by dump-cli-help.sh) |
| 23 | +* **Bash**: For running the shell script |
| 24 | + |
| 25 | +### Setup |
| 26 | + |
| 27 | +1. Ensure your Dash node is running and synced |
| 28 | +2. Verify dash-cli can connect to your node: |
| 29 | + |
| 30 | + ```bash |
| 31 | + dash-cli -testnet getblockchaininfo |
| 32 | + ``` |
| 33 | + |
| 34 | +3. Install jq if not already installed: |
| 35 | + |
| 36 | + ```bash |
| 37 | + # Ubuntu/Debian |
| 38 | + sudo apt-get install jq |
| 39 | + |
| 40 | + # macOS |
| 41 | + brew install jq |
| 42 | + ``` |
| 43 | + |
| 44 | +## Complete Workflow |
| 45 | + |
| 46 | +### Step 1: Dump RPC Help for the Old Version |
| 47 | + |
| 48 | +First, dump all RPC help text from the version you're upgrading FROM: |
| 49 | + |
| 50 | +```bash |
| 51 | +cd scripts/core-rpc-tools |
| 52 | + |
| 53 | +# Set path to your dash-cli for version 22.1.3 (example) |
| 54 | +CLI="$HOME/dashcore-22.1.3/bin/dash-cli" NET_ARGS="-testnet" ./dump-cli-help.sh |
| 55 | +``` |
| 56 | + |
| 57 | +This generates two files: |
| 58 | + |
| 59 | +* `dash-cli-help-22.1.3-<timestamp>.txt` - Human-readable text file |
| 60 | +* `dash-cli-help-22.1.3-<timestamp>.jsonl` - Machine-readable JSONL file |
| 61 | + |
| 62 | +### Step 2: Dump RPC Help for the New Version |
| 63 | + |
| 64 | +Switch to the new Dash Core version and dump its help: |
| 65 | + |
| 66 | +```bash |
| 67 | +# Restart your node with the new version |
| 68 | +# Then dump help again |
| 69 | +cd ~/code/dashpay-docs/scripts/core-rpc-tools |
| 70 | +CLI="$HOME/dashcore-23.0.0/bin/dash-cli" NET_ARGS="-testnet" ./dump-cli-help.sh |
| 71 | +``` |
| 72 | + |
| 73 | +This generates: |
| 74 | + |
| 75 | +* `dash-cli-help-23.0.0-<timestamp>.txt` |
| 76 | +* `dash-cli-help-23.0.0-<timestamp>.jsonl` |
| 77 | + |
| 78 | +### Step 3: Generate Change Summary |
| 79 | + |
| 80 | +Compare the two versions and generate a detailed change report: |
| 81 | + |
| 82 | +```bash |
| 83 | +# Pass the two JSONL files as command-line arguments |
| 84 | +python3 generate-rpc-change-summary.py \ |
| 85 | + dash-cli-help-22.1.3-<timestamp>.jsonl \ |
| 86 | + dash-cli-help-23.0.0-<timestamp>.jsonl |
| 87 | +``` |
| 88 | + |
| 89 | +This generates: |
| 90 | + |
| 91 | +* `rpc-changes-summary-22.1.3-to-23.0.0.md` - Comprehensive change summary |
| 92 | + |
| 93 | +## Script Details |
| 94 | + |
| 95 | +### dump-cli-help.sh |
| 96 | + |
| 97 | +**Purpose**: Extracts help text for all RPC commands and subcommands from dash-cli. |
| 98 | + |
| 99 | +**Usage**: |
| 100 | + |
| 101 | +```bash |
| 102 | +./dump-cli-help.sh |
| 103 | +``` |
| 104 | + |
| 105 | +**Configuration via Environment Variables**: |
| 106 | + |
| 107 | +```bash |
| 108 | +# Custom dash-cli path |
| 109 | +CLI="/path/to/dash-cli" ./dump-cli-help.sh |
| 110 | + |
| 111 | +# Different network |
| 112 | +NET_ARGS="" ./dump-cli-help.sh # mainnet |
| 113 | +``` |
| 114 | + |
| 115 | +**How It Works**: |
| 116 | + |
| 117 | +1. Runs `dash-cli help` to get the full command list |
| 118 | +2. Iterates through each command and captures `dash-cli help <command>` |
| 119 | +3. Detects "family" RPCs (commands with subcommands like `protx`, `bls`, `coinjoin`) |
| 120 | +4. For family RPCs, discovers and captures help for each subcommand |
| 121 | +5. Outputs both human-readable text and structured JSONL format |
| 122 | +6. Automatically extracts version from `dash-cli -version` and includes it in filenames |
| 123 | + |
| 124 | +**Output Files**: |
| 125 | + |
| 126 | +* **Text file** (`.txt`): Formatted for human reading, with headers and separators |
| 127 | +* **JSONL file** (`.jsonl`): One JSON object per line, structured for machine parsing |
| 128 | + * Metadata header with version, network, timestamp |
| 129 | + * One record per command/subcommand with: |
| 130 | + * `command`: Top-level command name |
| 131 | + * `subcommand`: Subcommand name (null for root commands) |
| 132 | + * `qualified`: Full command string (e.g., "protx register") |
| 133 | + * `signature_tail`: Argument signature from help list |
| 134 | + * `is_family`: Whether this is a family RPC with subcommands |
| 135 | + * `help_raw`: Complete help text |
| 136 | + * `help_sha256`: Hash for detecting changes |
| 137 | + |
| 138 | +### generate-rpc-change-summary.py |
| 139 | + |
| 140 | +**Purpose**: Compares two JSONL help dumps and generates a detailed change summary. |
| 141 | + |
| 142 | +**Usage**: |
| 143 | + |
| 144 | +```bash |
| 145 | +python3 generate-rpc-change-summary.py <old_version.jsonl> <new_version.jsonl> |
| 146 | +``` |
| 147 | + |
| 148 | +**Examples**: |
| 149 | + |
| 150 | +```bash |
| 151 | +# Compare version 22.1.3 to 23.0.0 |
| 152 | +python3 generate-rpc-change-summary.py \ |
| 153 | + dash-cli-help-22.1.3-20251104T214929Z.jsonl \ |
| 154 | + dash-cli-help-23.0.0-20251104T213450Z.jsonl |
| 155 | + |
| 156 | +# The script automatically extracts version info from the JSONL metadata |
| 157 | +# and creates an appropriately named output file |
| 158 | +``` |
| 159 | + |
| 160 | +## Output Files Reference |
| 161 | + |
| 162 | +After running the complete workflow, you'll have these files: |
| 163 | + |
| 164 | +| File | Purpose | Format | |
| 165 | +|------|---------|--------| |
| 166 | +| `dash-cli-help-{version}-{timestamp}.txt` | Human-readable help dump | Plain text with headers | |
| 167 | +| `dash-cli-help-{version}-{timestamp}.jsonl` | Machine-readable help dump | JSONL (one JSON per line) | |
| 168 | +| `rpc-changes-summary-{oldver}-to-{newver}.md` | Change summary report | Markdown | |
| 169 | + |
| 170 | +**Recommended versioning**: Keep all JSONL files in version control to track historical changes: |
| 171 | + |
| 172 | +```bash |
| 173 | +git add dash-cli-help-*.jsonl |
| 174 | +git add rpc-changes-summary-*.md |
| 175 | +git commit -m "feat: add RPC change analysis for <version>" |
| 176 | +``` |
0 commit comments