199 | @@ -200,9 +200,7 @@ static RPCHelpMan getpeerinfo()
200 | ServiceFlags services{fStateStats ? statestats.their_services : ServiceFlags::NODE_NONE};
201 | obj.pushKV("services", strprintf("%016x", services));
202 | obj.pushKV("servicesnames", GetServicesNames(services));
203 | - if (fStateStats) {
204 | - obj.pushKV("relaytxes", statestats.m_relay_txs);
205 | - }
206 | + obj.pushKV("relaytxes", fStateStats ? statestats.m_relay_txs : false);
But this is incorrect. The default doesn't matter here - the value that it had for the entire connection is what it should be during disconnection. That value is gone at this point. So either we can't send the field, or can't send the peer entirely. Sending "false" is wrong.
I think agree with the statement above, fStateStats is only true if the peer id exists in m_node_states and m_peer_map, so it seems like the node shouldn't exist in the return value at all.
I guess according to the comment at #26457#pullrequestreview-1181641835, there is the potential for a race condition, but seems awkward to replicate in the wild as any disconnection removes the nodes pointers and states entirely by the time the rpc is called.