OpenViSTAI · Agents · Blockchain · Crypto
Menu
OPENVIST RECIPES

List Bitcoin Core RPC method names from saved reference text

Python

Read a user-supplied local copy of the Bitcoin developer reference and print the distinct RPC method names explicitly named in its RPC API Reference section.

Python code excerpt: List Bitcoin Core RPC method names from saved reference text. Version 0.1.0. Read the full recipe for code, sources and recorded test scope.

The Bitcoin developer documentation lists named RPCs, including blockchain and control RPCs. This offline recipe extracts names from a saved text copy; it does not query Bitcoin Core, validate RPC behavior, or test a node.

Before you start

  • Python 3.12 was used for the recorded GitHub Actions fixture tests. The example uses only the Python standard library; compatibility with other Python versions was not established by those tests.
  • A local UTF-8 text fixture with the exact markers `RPC API Reference` and `Network Status`, and method entries directly before `Argument #` or `Result`. These are parser input requirements, not a guaranteed export format of the linked websites. No Bitcoin node, credentials, packages, or network access are needed.

Build and check

  1. Prepare a local UTF-8 fixture using method names documented in the official RPC reference. Include the exact section markers and entry format described below; an arbitrary saved web page is not guaranteed to match this parser.
  2. Save the example as `list_rpc_names.py`.
  3. Run `python list_rpc_names.py reference.txt`, replacing the argument with the path to the saved text.
  4. Review the printed, alphabetically sorted, distinct method names; they are extracted from this file only, not verified against a running service.

Limits to understand

  • This is a bounded offline text extraction, not an RPC client or a test of Bitcoin Core.
  • The parser requires the two exact section markers in a prepared local fixture. It has not been validated against an unmodified text export of the current reference website.
  • Names are inferred from text immediately preceding `Argument #` or `Result`; unusual formatting or unrelated matching text can affect results.
  • The recipe does not interpret method arguments, return values, or version availability. The supplied documents do not establish an exact Bitcoin Core version requirement.
INSPECT THE SCRIPT

Inspect, copy and run the documented checks.

This browser preview builds code locally. It does not contact an API or run the code.

Default example ready.

Python example
# SPDX-License-Identifier: MIT
# Copyright (c) 2026 OpenViST contributors
import argparse
import pathlib
import re
import sys


def main():
    parser = argparse.ArgumentParser(
        description="List RPC method names from a saved Bitcoin developer reference text file."
    )
    parser.add_argument("reference", help="Path to a UTF-8 text copy of the reference")
    args = parser.parse_args()

    try:
        text = pathlib.Path(args.reference).read_text(encoding="utf-8")
    except (OSError, UnicodeError) as exc:
        print(f"error: cannot read reference file: {exc}", file=sys.stderr)
        return 2

    if not text.strip():
        print("error: reference file is empty", file=sys.stderr)
        return 2

    start_marker = "RPC API Reference"
    end_marker = "Network Status"
    start = text.find(start_marker)
    if start < 0:
        print(f"error: missing section marker {start_marker!r}", file=sys.stderr)
        return 2
    end = text.find(end_marker, start + len(start_marker))
    if end < 0:
        print(f"error: missing section boundary {end_marker!r}", file=sys.stderr)
        return 2

    section = text[start + len(start_marker):end]
    # The reference presents method names directly before “Argument” or “Result”.
    names = re.findall(r"(?<![A-Za-z0-9_])([a-z][a-z0-9]+)(?=\s+Argument\s+#|\s+Result\b)", section)
    distinct_names = sorted(set(names))
    if not distinct_names:
        print("error: no RPC method names found in the selected section", file=sys.stderr)
        return 2

    for name in distinct_names:
        print(name)
    return 0


if __name__ == "__main__":
    sys.exit(main())
What to verify after running
  • Use a synthetic text fixture containing both section markers and entries such as `getblock Argument #1` and `getdifficulty Result`; check that each distinct extracted name prints once, in alphabetical order.
  • Try a fixture with the section markers but no matching method entries; confirm the program reports the no-methods error to stderr and exits with status 2.
  • Try an empty file and a nonexistent path; confirm each reports an error and exits with status 2.
  • Remove either required section marker from a nonempty fixture; confirm the corresponding missing-marker or missing-boundary error appears, with no partial output.
  • Check that stdout contains only extracted names and that no remote service is contacted or modified.

Request or format preview

Illustrative preview. No provider response, price or balance is fetched.

Change a setting to inspect the preview.

Official sources and related profiles

    Code license: MIT. Keep the license notice with your copy.

    Example version 0.1.0 · Documentation reviewed 2026-10-09.

    Executed 6 synthetic local fixture cases in isolated CPython on GitHub Actions, without network access. Declared exit codes, output assertions and input integrity checks passed. Live services, installed third-party packages and production behavior remain outside scope. Editorial approval is still required.