rpc, net: deprecate `startingheight` field of `getpeerinfo` RPC
What changed, and why it matters
This change hides one piece of information—the 'startingheight' field—from the getpeerinfo RPC output unless the user explicitly enables it with a deprecation flag. It is a planned API cleanup, not a security fix. There is no vulnerability or exploit here.
No security action needed. Users or tools depending on getpeerinfo.startingheight should migrate before the field is removed in a future major release.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit deprecates the ‘startingheight’ field returned by Bitcoin Core’s getpeerinfo RPC. The field is now only emitted when -deprecatedrpc=startingheight is supplied. The underlying Peer::m_starting_height member is retained with a TODO to remove it in a future release. This is a backward-compatibility/API change, not a code correctness or security patch.
Changed components
src/rpc/net.cppsrc/net_processing.cpptest/functional/rpc_net.pyInspect captured patch +16 / −3
diff --git a/doc/release-notes-34197.md b/doc/release-notes-34197.md
new file mode 100644
index 00000000..377ca9cc
--- /dev/null
+++ b/doc/release-notes-34197.md
@@ -0,0 +1,7 @@
+Updated RPCs
+------------
+
+- The `getpeerinfo` RPC no longer returns the `startingheight` field unless
+ the configuration option `-deprecatedrpc=startingheight` is used. The
+ `startingheight` field will be fully removed in the next major release.
+ (#34197)
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index 6ec55256..3b926c6c 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -268,6 +268,7 @@ struct Peer {
bool m_outbound_version_message_sent GUARDED_BY(NetEventsInterface::g_msgproc_mutex){false};
/** This peer's reported block height when we connected */
+ // TODO: remove in v32.0, only show reported height once in "receive version message: ..." debug log
std::atomic<int> m_starting_height{-1};
/** The pong reply we're expecting, or 0 if no pong expected. */
diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp
index 826686f9..b07555e9 100644
--- a/src/rpc/net.cpp
+++ b/src/rpc/net.cpp
@@ -160,7 +160,7 @@ static RPCHelpMan getpeerinfo()
{RPCResult::Type::BOOL, "inbound", "Inbound (true) or Outbound (false)"},
{RPCResult::Type::BOOL, "bip152_hb_to", "Whether we selected peer as (compact blocks) high-bandwidth peer"},
{RPCResult::Type::BOOL, "bip152_hb_from", "Whether peer selected us as (compact blocks) high-bandwidth peer"},
- {RPCResult::Type::NUM, "startingheight", "The starting height (block) of the peer"},
+ {RPCResult::Type::NUM, "startingheight", /*optional=*/true, "(DEPRECATED, returned only if config option -deprecatedrpc=startingheight is passed) The starting height (block) of the peer"},
{RPCResult::Type::NUM, "presynced_headers", "The current height of header pre-synchronization with this peer, or -1 if no low-work sync is in progress"},
{RPCResult::Type::NUM, "synced_headers", "The last header we have in common with this peer"},
{RPCResult::Type::NUM, "synced_blocks", "The last block we have in common with this peer"},
@@ -267,7 +267,9 @@ static RPCHelpMan getpeerinfo()
obj.pushKV("inbound", stats.fInbound);
obj.pushKV("bip152_hb_to", stats.m_bip152_highbandwidth_to);
obj.pushKV("bip152_hb_from", stats.m_bip152_highbandwidth_from);
- obj.pushKV("startingheight", statestats.m_starting_height);
+ if (IsDeprecatedRPCEnabled("startingheight")) {
+ obj.pushKV("startingheight", statestats.m_starting_height);
+ }
obj.pushKV("presynced_headers", statestats.presync_height);
obj.pushKV("synced_headers", statestats.nSyncHeight);
obj.pushKV("synced_blocks", statestats.nCommonHeight);
diff --git a/test/functional/rpc_net.py b/test/functional/rpc_net.py
index 77d036c2..6438cabe 100755
--- a/test/functional/rpc_net.py
+++ b/test/functional/rpc_net.py
@@ -62,7 +62,10 @@ def seed_addrman(node):
class NetTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 2
- self.extra_args = [["-minrelaytxfee=0.00001000"], ["-minrelaytxfee=0.00000500"]]
+ self.extra_args = [
+ ["-minrelaytxfee=0.00001000", "-deprecatedrpc=startingheight"],
+ ["-minrelaytxfee=0.00000500"],
+ ]
# Specify a non-working proxy to make sure no actual connections to public IPs are attempted
for args in self.extra_args:
args.append("-proxy=127.0.0.1:1")
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.