rpc: expose RPC metadata for introspection
What changed, and why it matters
This commit adds small plumbing so that Bitcoin Core's RPC command metadata (descriptions, argument details, result formats) can be inspected by other code. It does not change any user-facing RPC behavior by itself; it merely exposes internal data structures that were already present. There is no obvious security bug in the diff.
No immediate security action required. Treat as a normal code-quality/feature commit. If this is part of a larger feature, review the follow-up commits that actually consume the exposed metadata to ensure introspected data is not leaked inappropriately or used to bypass validation.
Security signals we found
No memory safety issues visible in the diff
No authentication or authorization changes
No new externally reachable endpoints
No parsing of untrusted data added
Change is additive and read-only from a metadata perspective
Evidence from the diff
The patch stores the original RpcMethodFnType callable in CRPCCommand.metadata_fn and adds const getters (GetDescription, GetArgs, GetResults) to RPCHelpMan. Wallet interface registration copies metadata_fn into the registered command. This is an introspection/refactoring change: it exposes existing metadata for runtime inspection, likely to support future features such as automated RPC documentation or command discovery. No input parsing, authentication, consensus, or resource-handling logic is modified.
Changed components
src/rpc/server.hsrc/rpc/util.hsrc/wallet/interfaces.cppInspect captured patch +6 / −0
diff --git a/src/rpc/server.h b/src/rpc/server.h
index 1c739640..147c8cf6 100644
--- a/src/rpc/server.h
+++ b/src/rpc/server.h
@@ -63,6 +63,7 @@ public:
fn().GetArgNames(),
intptr_t(fn))
{
+ this->metadata_fn = fn;
}
std::string category;
@@ -79,6 +80,7 @@ public:
//! appended after other arguments, see transformNamedArguments for details.
std::vector<std::pair<std::string, bool>> argNames;
intptr_t unique_id;
+ RpcMethodFnType metadata_fn{nullptr};
};
/**
diff --git a/src/rpc/util.h b/src/rpc/util.h
index 9627e945..82ebea61 100644
--- a/src/rpc/util.h
+++ b/src/rpc/util.h
@@ -518,6 +518,9 @@ public:
bool IsValidNumArgs(size_t num_args) const;
//! Return list of arguments and whether they are named-only.
std::vector<std::pair<std::string, bool>> GetArgNames() const;
+ const std::string& GetDescription() const { return m_description; }
+ const std::vector<RPCArg>& GetArgs() const { return m_args; }
+ const RPCResults& GetResults() const { return m_results; }
const std::string m_name;
diff --git a/src/wallet/interfaces.cpp b/src/wallet/interfaces.cpp
index 4eee155c..a4cd056b 100644
--- a/src/wallet/interfaces.cpp
+++ b/src/wallet/interfaces.cpp
@@ -544,6 +544,7 @@ public:
wallet_request.context = &m_context;
return command.actor(wallet_request, result, last_handler);
}, command.argNames, command.unique_id);
+ m_rpc_commands.back().metadata_fn = command.metadata_fn;
m_rpc_handlers.emplace_back(m_context.chain->handleRpc(m_rpc_commands.back()));
}
}
Why this scored 19/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.