Skip to content

Commit b2dc6f8

Browse files
committed
docs: add readme
1 parent 53ad2e0 commit b2dc6f8

File tree

1 file changed

+177
-0
lines changed

1 file changed

+177
-0
lines changed

scripts/core-rpc-tools/README.md

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
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+
# Edit generate-rpc-change-summary.py to set your file paths
84+
85+
python3 generate-rpc-change-summary.py
86+
```
87+
88+
This generates:
89+
90+
* `rpc-changes-summary-22.1.3-to-23.0.0.md` - Comprehensive change summary
91+
92+
## Script Details
93+
94+
### dump-cli-help.sh
95+
96+
**Purpose**: Extracts help text for all RPC commands and subcommands from dash-cli.
97+
98+
**Usage**:
99+
100+
```bash
101+
./dump-cli-help.sh
102+
```
103+
104+
**Configuration via Environment Variables**:
105+
106+
```bash
107+
# Custom dash-cli path
108+
CLI="/path/to/dash-cli" ./dump-cli-help.sh
109+
110+
# Different network
111+
NET_ARGS="" ./dump-cli-help.sh # mainnet
112+
```
113+
114+
**How It Works**:
115+
116+
1. Runs `dash-cli help` to get the full command list
117+
2. Iterates through each command and captures `dash-cli help <command>`
118+
3. Detects "family" RPCs (commands with subcommands like `protx`, `bls`, `coinjoin`)
119+
4. For family RPCs, discovers and captures help for each subcommand
120+
5. Outputs both human-readable text and structured JSONL format
121+
6. Automatically extracts version from `dash-cli -version` and includes it in filenames
122+
123+
**Output Files**:
124+
125+
* **Text file** (`.txt`): Formatted for human reading, with headers and separators
126+
* **JSONL file** (`.jsonl`): One JSON object per line, structured for machine parsing
127+
* Metadata header with version, network, timestamp
128+
* One record per command/subcommand with:
129+
* `command`: Top-level command name
130+
* `subcommand`: Subcommand name (null for root commands)
131+
* `qualified`: Full command string (e.g., "protx register")
132+
* `signature_tail`: Argument signature from help list
133+
* `is_family`: Whether this is a family RPC with subcommands
134+
* `help_raw`: Complete help text
135+
* `help_sha256`: Hash for detecting changes
136+
137+
### generate-rpc-change-summary.py
138+
139+
**Purpose**: Compares two JSONL help dumps and generates a detailed change summary.
140+
141+
**Usage**:
142+
143+
```bash
144+
# Edit the script to set your input files
145+
nano generate-rpc-change-summary.py
146+
147+
# Then run
148+
python3 generate-rpc-change-summary.py
149+
```
150+
151+
**Configuration** (edit the `__main__` block at the bottom):
152+
153+
```python
154+
if __name__ == '__main__':
155+
old_file = 'dash-cli-help-<old_version>-<timestamp>.jsonl'
156+
new_file = 'dash-cli-help-<new_version>-<timestamp>.jsonl'
157+
158+
# ... rest of script
159+
```
160+
161+
## Output Files Reference
162+
163+
After running the complete workflow, you'll have these files:
164+
165+
| File | Purpose | Format |
166+
|------|---------|--------|
167+
| `dash-cli-help-{version}-{timestamp}.txt` | Human-readable help dump | Plain text with headers |
168+
| `dash-cli-help-{version}-{timestamp}.jsonl` | Machine-readable help dump | JSONL (one JSON per line) |
169+
| `rpc-changes-summary-{oldver}-to-{newver}.md` | Change summary report | Markdown |
170+
171+
**Recommended versioning**: Keep all JSONL files in version control to track historical changes:
172+
173+
```bash
174+
git add dash-cli-help-*.jsonl
175+
git add rpc-changes-summary-*.md
176+
git commit -m "feat: add RPC change analysis for <version>"
177+
```

0 commit comments

Comments
 (0)