Skip to content

Docs: align API documentation with current RPC surface#1729

Merged
reubenyap merged 3 commits intomasterfrom
cursor/api-and-component-documentation-8f2c
Mar 29, 2026
Merged

Docs: align API documentation with current RPC surface#1729
reubenyap merged 3 commits intomasterfrom
cursor/api-and-component-documentation-8f2c

Conversation

@reubenyap
Copy link
Copy Markdown
Member

@reubenyap reubenyap commented Jan 7, 2026

PR intention

Generate comprehensive documentation for Firo's public APIs, functions, and components, including usage examples and instructions. This PR introduces a new api-documentation.md file.

Code changes brief

A new markdown file (doc/api-documentation.md) has been added, containing detailed documentation for RPCs (Blockchain, Wallet, Network, Mining, Masternode, Privacy, Mobile, Address Index), privacy protocols (Lelantus, Spark), LLMQ/ChainLocks, Masternodes, and core components, along with practical examples, error codes, and configuration options. No existing code files were modified.


Open in Cursor Open in Web


Note

Low Risk
Documentation-only change that adds a new markdown file; no runtime behavior or security-sensitive code paths are modified.

Overview
Adds a new doc/api-documentation.md providing a consolidated reference for the current RPC surface (including a generated complete command index), selected detailed RPC call semantics, and usage examples.

Also documents key protocol/component concepts (Lelantus/Spark, ChainLocks/LLMQ, masternodes, core wallet/transaction/script types) plus common error codes and configuration flags; no source code changes are included.

Written by Cursor Bugbot for commit 3d6a5ee. This will update automatically on new commits. Configure here.

Co-authored-by: reuben <reuben@firo.org>
@cursor
Copy link
Copy Markdown

cursor Bot commented Jan 7, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 7, 2026

Walkthrough

This PR adds comprehensive API documentation covering Firo's RPC commands, privacy protocols (Lelantus and Spark), masternode features, and configuration options organized across multiple functional categories.

Changes

Cohort / File(s) Summary
API Documentation
doc/api-documentation.md
New documentation file with detailed RPC command specifications, protocol descriptions, error codes, configuration options, and usage examples across blockchain, wallet, network, mining, masternode, privacy, and address index categories.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested reviewers

  • psolstice
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically summarizes the main change: adding/updating API documentation to match the current RPC surface.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The PR description comprehensively covers both required sections with clear intent and detailed code changes summary.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/api-and-component-documentation-8f2c

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Member Author

@reubenyap reubenyap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR #1729 Review: Add comprehensive API and component documentation

[1 file changed, +1732 / -0] — Adds a new doc/api-documentation.md covering RPC APIs, privacy protocols (Lelantus/Spark), LLMQ/ChainLocks, masternodes, core components, and configuration options.

Static Analysis

N/A — documentation-only PR (Markdown file, no C++ code).

Cross-Reference Verification

Verified RPC signatures, parameters, port numbers, address formats, and component APIs against the actual codebase. Most documentation is accurate, with the exceptions noted below.

Findings Summary

# Severity File Finding
1 HIGH doc/api-documentation.md:1366 Spark mainnet prefix is sm, not sp
2 MEDIUM doc/api-documentation.md:98 getblock verbosity is numeric (0/1/2), not boolean
3 MEDIUM doc/api-documentation.md:992 7 RPCs missing from documentation
4 MEDIUM doc/api-documentation.md:1371 Missing address format specs / regex patterns for transparent and Spark addresses

Each finding is posted as an inline comment on the relevant code — click to view, resolve when addressed. Each comment includes a Prompt for AI agents that can be copy-pasted into Cursor/Copilot/Claude Code to auto-fix the issue.

Verified as Correct

  • Transparent address prefix (a for mainnet) ✓
  • Spark testnet prefix (st) ✓
  • P2P port 8168, RPC port 8888 ✓
  • Spark Names RPCs (getsparknamedata, getsparknames) signatures and return formats ✓
  • Privacy protocol component APIs (Lelantus JoinSplit, Spark SpendTransaction, keys) ✓
  • Transaction type enum values ✓
  • Masternode system components ✓

Review assisted by AI + codebase cross-referencing. Posted by @reubenyap.

Comment thread doc/api-documentation.md Outdated
#### Spark Address Format

Spark addresses use Bech32 encoding:
- **Mainnet prefix:** `sp`
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[HIGH] Spark mainnet address prefix is sm, not sp

The documentation states the mainnet prefix is sp, but the actual code in src/libspark/keys.cpp:196-198 constructs the HRP as:

hrp.push_back(ADDRESS_ENCODING_PREFIX);  // 's' (from util.h:69)
hrp.push_back(network);                  // 'm' for mainnet (from util.h:73)

So mainnet Spark addresses start with sm1..., not sp1.... The testnet prefix st is correct.

Suggested fix:
Change line 1366 to - **Mainnet prefix:** \sm`and update the example on line 1369 fromsp1qw508d...tosm1q...`.

🤖 Prompt for AI agents

"In file doc/api-documentation.md, the Spark Address Format section (around line 1366) incorrectly states the mainnet prefix is sp. Change it to sm. Also update the example address on line 1369 from sp1qw508d6qejxtdg4y5r3zarvary0c5xw7k... to an sm1... prefix. Reference: src/libspark/util.h defines ADDRESS_NETWORK_MAINNET = 'm' and ADDRESS_ENCODING_PREFIX = 's', producing HRP 'sm'."

Comment thread doc/api-documentation.md

---

#### `getblock "blockhash" [verbose]`
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MEDIUM] getblock verbosity parameter is numeric (0/1/2), not boolean

The documentation shows [verbose] as a boolean with default=true. The actual implementation in src/rpc/blockchain.cpp:943-1034 uses numeric verbosity levels:

Boolean is accepted for backward compatibility but the parameter should be documented as numeric.

Suggested fix:
Change the signature to getblock "blockhash" [verbosity] and document the three numeric levels (0, 1, 2) with default=1. Note that verbosity=2 includes decoded transaction data including Spark-specific fields.

🤖 Prompt for AI agents

"In file doc/api-documentation.md, the getblock RPC (around line 98) documents the second parameter as [verbose] (boolean, default=true). Change it to [verbosity] (numeric, optional, default=1) with three levels: 0 = hex data, 1 = JSON object, 2 = JSON with full transaction data. Update the result section to show the verbosity=2 output format. Boolean is still accepted for backwards compatibility but numeric is the primary interface."

Comment thread doc/api-documentation.md

---

### Mobile RPCs
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MEDIUM] Several RPCs are missing from the documentation

The following RPCs exist in the codebase but are not documented:

Wallet RPCs:

Utility RPCs:

  • verifymessage "address" "signature" "message" — Verify a signed message (src/rpc/misc.cpp:436)
  • verifymessagewithsparkaddress "sparkaddress" "signature" "message" — Verify a Spark-signed message (src/rpc/misc.cpp:490, added in PR Implementation of signing/verification of message with Spark address #1784)
  • signmessagewithprivkey "privkey" "message" — Sign with a private key directly (src/rpc/misc.cpp:553)

Address Index RPCs:

  • getspentinfo — Returns the txid and index where an output is spent (src/rpc/misc.cpp:1947, requires -spentindex)

Mobile RPCs:

  • getusedcoinstagstxhashes — Returns transaction hashes for used coin tags (src/rpc/misc.cpp:1629)

Suggested fix:
Add documentation sections for each missing RPC with their parameters, result formats, and examples.

🤖 Prompt for AI agents

"In file doc/api-documentation.md, add documentation for the following missing RPCs: (1) signmessage and verifymessage under Wallet RPCs and Utility sections respectively; (2) signmessagewithsparkaddress and verifymessagewithsparkaddress under a new 'Message Signing RPCs' section; (3) signmessagewithprivkey under Utility RPCs; (4) getspentinfo under Address Index RPCs; (5) getusedcoinstagstxhashes under Mobile RPCs. For each, include Arguments, Result format, and an Example. Reference the actual implementations in src/wallet/rpcwallet.cpp and src/rpc/misc.cpp for accurate parameter names and types."

Comment thread doc/api-documentation.md

Example: `sp1qw508d6qejxtdg4y5r3zarvary0c5xw7k...`

---
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MEDIUM] Missing address format specifications / regex patterns

The documentation mentions Spark addresses use Bech32 encoding but doesn't provide the actual validation rules or regex patterns that external developers would need to validate addresses. Similarly, there is no specification for transparent (base58check) Firo addresses.

For developer integration, the doc should include:

Transparent addresses (base58check):

  • Mainnet P2PKH: version byte 0x52 (82), addresses start with a, regex: ^a[1-9A-HJ-NP-Za-km-z]{33}$
  • Mainnet P2SH: version byte 0x07 (7), addresses start with 3 or 4
  • Testnet P2PKH: version byte 0x41 (65), addresses start with T

Spark addresses (bech32m):

  • Mainnet HRP: sm, regex: ^sm1[a-z0-9]{100,}$
  • Testnet HRP: st, regex: ^st1[a-z0-9]{100,}$
  • Decoded payload size: exactly 2 * GroupElement::serialize_size + AES_BLOCKSIZE bytes
  • Validated via bech32::decode() + custom size/HRP checks in src/libspark/keys.cpp:207-249

Suggested fix:
Add an "Address Formats" section documenting both transparent and Spark address formats with version bytes, prefixes, and validation regex patterns.

🤖 Prompt for AI agents

"In file doc/api-documentation.md, after the Spark Address Format section (around line 1371), add a comprehensive 'Address Validation' subsection. Include: (1) Transparent address format: base58check with mainnet P2PKH version byte 0x52 (prefix 'a'), P2SH version byte 0x07, testnet P2PKH version byte 0x41 (prefix 'T'). Include regex patterns. (2) Spark address format: bech32m encoding, mainnet HRP 'sm', testnet HRP 'st', regtest HRP 'sr'. Include regex patterns and note the decoded payload size requirement. Reference src/chainparams.cpp for base58 prefixes and src/libspark/keys.cpp + src/libspark/util.h for Spark encoding."

@reubenyap
Copy link
Copy Markdown
Member Author

🤖 Combined AI Fix Prompt

Verify each finding against the current code and only fix it if needed.

  1. doc/api-documentation.md — Fix Spark mainnet address prefix: Around line 1366 in the Spark Address Format section, change the mainnet prefix from sp to sm. Update the example address on line 1369 from sp1qw508d6qejxtdg4y5r3zarvary0c5xw7k... to use the sm1 prefix. Also search the entire document for any other occurrences of sp1 used as a Spark address example and update them. Reference: src/libspark/util.h defines ADDRESS_ENCODING_PREFIX = 's' and ADDRESS_NETWORK_MAINNET = 'm', producing HRP 'sm'.

  2. doc/api-documentation.md — Fix getblock verbosity parameter: Around line 98, change the getblock signature from getblock "blockhash" [verbose] to getblock "blockhash" [verbosity]. Change the parameter description from verbose (boolean, optional, default=true) to verbosity (numeric, optional, default=1) with three levels: 0 = hex-encoded data, 1 = JSON object, 2 = JSON object with full decoded transaction data (including Spark fields). Note that boolean is still accepted for backward compatibility (true=1, false=0). Add a Result (verbosity=2) section showing the expanded output format.

  3. doc/api-documentation.md — Add missing RPCs: Add documentation for these 7 RPCs in the appropriate sections: (a) signmessage "address" "message" under Wallet RPCs — signs a message with a transparent address private key, returns base64 signature; (b) verifymessage "address" "signature" "message" under a new Utility RPCs section — verifies a signed message; (c) signmessagewithsparkaddress "sparkaddress" "message" under Wallet RPCs — signs with Spark address; (d) verifymessagewithsparkaddress "sparkaddress" "signature" "message" under Utility RPCs; (e) signmessagewithprivkey "privkey" "message" under Utility RPCs; (f) getspentinfo {"txid":"...", "index":N} under Address Index RPCs — requires -spentindex; (g) getusedcoinstagstxhashes startNumber under Mobile RPCs. Check src/wallet/rpcwallet.cpp and src/rpc/misc.cpp for exact signatures and help strings.

  4. doc/api-documentation.md — Add Address Formats section with regex patterns: After the Spark Address Format section (~line 1371), add a comprehensive "Address Validation" subsection with: (a) Transparent addresses: base58check, mainnet P2PKH version byte 0x52 (decimal 82, prefix 'a'), P2SH version byte 0x07 (prefix '3'/'4'), testnet P2PKH version byte 0x41 (prefix 'T'). Regex: ^a[1-9A-HJ-NP-Za-km-z]{33}$ for mainnet P2PKH. (b) Spark addresses: bech32m encoding, mainnet HRP 'sm', testnet HRP 'st', regtest HRP 'sr'. Regex: ^sm1[a-z0-9]{100,}$ for mainnet. Note decoded payload must be exactly 2*GroupElement::serialize_size + AES_BLOCKSIZE bytes. Reference src/chainparams.cpp for base58 prefixes and src/libspark/keys.cpp + src/libspark/util.h for Spark encoding.

@reubenyap reubenyap added documentation related to docs and manuals tasks RPC/API RPC and API interface labels Mar 24, 2026
Co-authored-by: Reuben Yap <reuben@firo.org>
@cursor cursor Bot changed the title Api and component documentation Docs: add and correct API documentation Mar 24, 2026
Co-authored-by: Reuben Yap <reuben@firo.org>
@cursor cursor Bot changed the title Docs: add and correct API documentation Docs: align API documentation with current RPC surface Mar 24, 2026
@reubenyap
Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 24, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot requested a review from psolstice March 24, 2026 15:50
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (2)
doc/api-documentation.md (2)

576-634: ⚠️ Potential issue | 🟠 Major

A few RPCs requested in prior review are still missing from detailed docs/index.

signmessagewithsparkaddress, verifymessagewithsparkaddress, and getspentinfo are still not documented here, and getspentinfo is also absent from the command index section. This leaves the “current RPC surface” documentation incomplete.

Suggested additions
+#### `signmessagewithsparkaddress "sparkaddress" "message"`
+Sign a message with a Spark address.
+
+#### `verifymessagewithsparkaddress "sparkaddress" "signature" "message"`
+Verify a message signed with a Spark address.
...
+#### `getspentinfo {"txid":"...","index":N}`
+Returns spending transaction reference for an outpoint.
+
+**Notes:**
+- Requires `-spentindex`
 #### `util`
-`createmultisig`, ..., `signmessagewithprivkey`, `validateaddress`, `verifymessage`
+`createmultisig`, ..., `signmessagewithprivkey`, `validateaddress`, `verifymessage`, `verifymessagewithsparkaddress`

 #### `wallet`
-..., `signmessage`, ...
+..., `signmessage`, `signmessagewithsparkaddress`, ...

 #### `addressindex`
-`getAddressNumWBalance`, ..., `getzerocoinpoolbalance`
+`getAddressNumWBalance`, ..., `getspentinfo`, ..., `getzerocoinpoolbalance`

Also applies to: 1214-1329

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@doc/api-documentation.md` around lines 576 - 634, Add documentation entries
for the missing RPCs: signmessagewithsparkaddress,
verifymessagewithsparkaddress, and getspentinfo; include their argument lists,
result descriptions, notes (e.g., wallet/unlocked requirements or address/key
constraints), and example CLI calls mirroring the style used for
signmessage/signmessagewithprivkey/verifymessage, and also add getspentinfo to
the command index section so the “current RPC surface” is complete.

103-140: ⚠️ Potential issue | 🟠 Major

getblock still documents deprecated boolean interface as primary.

This section still uses [verbose] (boolean) instead of [verbosity] (numeric, default 1) and does not document verbosity 2 output shape. That keeps the RPC contract documentation out of sync with current behavior.

Suggested doc patch
-#### `getblock "blockhash" [verbose]`
+#### `getblock "blockhash" [verbosity]`
 Returns block data for the given block hash.

 **Arguments:**
 1. `blockhash` (string, required) - The block hash
-2. `verbose` (boolean, optional, default=true) - `true` for a JSON object, `false` for hex-encoded block data
+2. `verbosity` (numeric, optional, default=1)
+   - `0`: hex-encoded block data
+   - `1`: JSON object with transaction IDs
+   - `2`: JSON object with fully decoded transaction data (including Spark fields)
+   - Boolean is accepted for backward compatibility (`false`=`0`, `true`=`1`)

-**Result (verbose=false):** `"data"` (string) - The serialized block encoded as hex
+**Result (verbosity=0):** `"data"` (string) - The serialized block encoded as hex

-**Result (verbose=true):**
+**Result (verbosity=1):**
 ...
+
+**Result (verbosity=2):**
+```json
+{
+  "...": "...",
+  "tx": [
+    {
+      "txid": "...",
+      "vin": [...],
+      "vout": [...],
+      "type": "...",
+      "spark": {...}
+    }
+  ]
+}
+```
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@doc/api-documentation.md` around lines 103 - 140, Update the getblock RPC
docs to replace the deprecated boolean parameter `[verbose]` with the numeric
`[verbosity]` (default=1) and document both verbosity=1 and verbosity=2 outputs;
change the Arguments section to show `verbosity` (numeric, optional, default=1),
keep the current JSON example as the verbosity=1 shape (where "tx" is an array
of txids) and add a new JSON example for verbosity=2 showing full tx objects
including keys like "txid", "vin", "vout", "type", and "spark"; also update any
inline text that mentions `verbose`/true/false to refer to `verbosity`/1/2 and
ensure the Result descriptions clearly distinguish verbosity=false/1 (hex or
txid list) vs verbosity=2 (expanded tx objects).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@doc/api-documentation.md`:
- Around line 15-17: TOC entry "Privacy RPCs" points to the non-existent
fragment "#privacy-rpcs"; either add a heading whose text will generate that
anchor (e.g., a section titled "Privacy RPCs") or change the TOC link to the
exact slug of the existing heading; update the TOC line containing "Privacy
RPCs" (the fragment "#privacy-rpcs") to match the actual heading slug or add the
heading with the exact text so the fragment resolves.

---

Duplicate comments:
In `@doc/api-documentation.md`:
- Around line 576-634: Add documentation entries for the missing RPCs:
signmessagewithsparkaddress, verifymessagewithsparkaddress, and getspentinfo;
include their argument lists, result descriptions, notes (e.g., wallet/unlocked
requirements or address/key constraints), and example CLI calls mirroring the
style used for signmessage/signmessagewithprivkey/verifymessage, and also add
getspentinfo to the command index section so the “current RPC surface” is
complete.
- Around line 103-140: Update the getblock RPC docs to replace the deprecated
boolean parameter `[verbose]` with the numeric `[verbosity]` (default=1) and
document both verbosity=1 and verbosity=2 outputs; change the Arguments section
to show `verbosity` (numeric, optional, default=1), keep the current JSON
example as the verbosity=1 shape (where "tx" is an array of txids) and add a new
JSON example for verbosity=2 showing full tx objects including keys like "txid",
"vin", "vout", "type", and "spark"; also update any inline text that mentions
`verbose`/true/false to refer to `verbosity`/1/2 and ensure the Result
descriptions clearly distinguish verbosity=false/1 (hex or txid list) vs
verbosity=2 (expanded tx objects).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: ed188c95-940d-4714-a49a-570828a042ff

📥 Commits

Reviewing files that changed from the base of the PR and between 7e028a0 and 3d6a5ee.

📒 Files selected for processing (1)
  • doc/api-documentation.md

Comment thread doc/api-documentation.md
Comment on lines +15 to +17
- [Privacy RPCs](#privacy-rpcs)
- [Mobile RPCs](#mobile-rpcs)
- [Address Index RPCs](#address-index-rpcs)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

TOC link fragment is invalid for Privacy RPCs.

The TOC links to #privacy-rpcs, but no heading generates that anchor, so the link is broken.

Suggested fix
-   - [Privacy RPCs](`#privacy-rpcs`)
+   - [Privacy RPCs - Lelantus](`#privacy-rpcs---lelantus`)
+   - [Privacy RPCs - Spark](`#privacy-rpcs---spark`)
🧰 Tools
🪛 markdownlint-cli2 (0.21.0)

[warning] 15-15: Link fragments should be valid

(MD051, link-fragments)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@doc/api-documentation.md` around lines 15 - 17, TOC entry "Privacy RPCs"
points to the non-existent fragment "#privacy-rpcs"; either add a heading whose
text will generate that anchor (e.g., a section titled "Privacy RPCs") or change
the TOC link to the exact slug of the existing heading; update the TOC line
containing "Privacy RPCs" (the fragment "#privacy-rpcs") to match the actual
heading slug or add the heading with the exact text so the fragment resolves.

@reubenyap
Copy link
Copy Markdown
Member Author

bugbot run

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

@reubenyap reubenyap marked this pull request as ready for review March 29, 2026 13:33
@reubenyap reubenyap merged commit b68fce8 into master Mar 29, 2026
2 of 3 checks passed
@reubenyap reubenyap deleted the cursor/api-and-component-documentation-8f2c branch March 29, 2026 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation related to docs and manuals tasks RPC/API RPC and API interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants