Skip to content

Commit 0ee9a00

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#23652: doc: Document optional RPC result fields
fab6c43 doc: Document optional result fields in validateaddress (MarcoFalke) faee265 doc: Document optional result fields in getpeerinfo (MarcoFalke) Pull request description: ACKs for top commit: shaavan: ACK fab6c43 Tree-SHA512: 78458d0c4deb9253fbfe37fa5736a7db14eb0478bcc4adeba10ba6945e83d8eac92048293f50c054ea612609939151b4a2e1226c06f6067901f3d58c127c7e18
2 parents 8b4d53e + fab6c43 commit 0ee9a00

File tree

2 files changed

+100
-98
lines changed

2 files changed

+100
-98
lines changed

src/rpc/misc.cpp

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -36,32 +36,33 @@
3636

3737
static RPCHelpMan validateaddress()
3838
{
39-
return RPCHelpMan{"validateaddress",
40-
"\nReturn information about the given bitcoin address.\n",
41-
{
42-
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The bitcoin address to validate"},
43-
},
44-
RPCResult{
45-
RPCResult::Type::OBJ, "", "",
39+
return RPCHelpMan{
40+
"validateaddress",
41+
"\nReturn information about the given bitcoin address.\n",
42+
{
43+
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The bitcoin address to validate"},
44+
},
45+
RPCResult{
46+
RPCResult::Type::OBJ, "", "",
47+
{
48+
{RPCResult::Type::BOOL, "isvalid", "If the address is valid or not"},
49+
{RPCResult::Type::STR, "address", /* optional */ true, "The bitcoin address validated"},
50+
{RPCResult::Type::STR_HEX, "scriptPubKey", /* optional */ true, "The hex-encoded scriptPubKey generated by the address"},
51+
{RPCResult::Type::BOOL, "isscript", /* optional */ true, "If the key is a script"},
52+
{RPCResult::Type::BOOL, "iswitness", /* optional */ true, "If the address is a witness address"},
53+
{RPCResult::Type::NUM, "witness_version", /* optional */ true, "The version number of the witness program"},
54+
{RPCResult::Type::STR_HEX, "witness_program", /* optional */ true, "The hex value of the witness program"},
55+
{RPCResult::Type::STR, "error", /* optional */ true, "Error message, if any"},
56+
{RPCResult::Type::ARR, "error_locations", /*optional=*/true, "Indices of likely error locations in address, if known (e.g. Bech32 errors)",
4657
{
47-
{RPCResult::Type::BOOL, "isvalid", "If the address is valid or not"},
48-
{RPCResult::Type::STR, "address", /* optional */ true, "The bitcoin address validated"},
49-
{RPCResult::Type::STR_HEX, "scriptPubKey", /* optional */ true, "The hex-encoded scriptPubKey generated by the address"},
50-
{RPCResult::Type::BOOL, "isscript", /* optional */ true, "If the key is a script"},
51-
{RPCResult::Type::BOOL, "iswitness", /* optional */ true, "If the address is a witness address"},
52-
{RPCResult::Type::NUM, "witness_version", /* optional */ true, "The version number of the witness program"},
53-
{RPCResult::Type::STR_HEX, "witness_program", /* optional */ true, "The hex value of the witness program"},
54-
{RPCResult::Type::STR, "error", /* optional */ true, "Error message, if any"},
55-
{RPCResult::Type::ARR, "error_locations", "Indices of likely error locations in address, if known (e.g. Bech32 errors)",
56-
{
57-
{RPCResult::Type::NUM, "index", "index of a potential error"},
58-
}},
59-
}
60-
},
61-
RPCExamples{
62-
HelpExampleCli("validateaddress", "\"" + EXAMPLE_ADDRESS[0] + "\"") +
63-
HelpExampleRpc("validateaddress", "\"" + EXAMPLE_ADDRESS[0] + "\"")
64-
},
58+
{RPCResult::Type::NUM, "index", "index of a potential error"},
59+
}},
60+
}
61+
},
62+
RPCExamples{
63+
HelpExampleCli("validateaddress", "\"" + EXAMPLE_ADDRESS[0] + "\"") +
64+
HelpExampleRpc("validateaddress", "\"" + EXAMPLE_ADDRESS[0] + "\"")
65+
},
6566
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
6667
{
6768
std::string error_msg;

src/rpc/net.cpp

Lines changed: 74 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -106,82 +106,83 @@ static RPCHelpMan ping()
106106

107107
static RPCHelpMan getpeerinfo()
108108
{
109-
return RPCHelpMan{"getpeerinfo",
110-
"\nReturns data about each connected network node as a json array of objects.\n",
111-
{},
112-
RPCResult{
113-
RPCResult::Type::ARR, "", "",
109+
return RPCHelpMan{
110+
"getpeerinfo",
111+
"\nReturns data about each connected network node as a json array of objects.\n",
112+
{},
113+
RPCResult{
114+
RPCResult::Type::ARR, "", "",
115+
{
116+
{RPCResult::Type::OBJ, "", "",
117+
{
114118
{
115-
{RPCResult::Type::OBJ, "", "",
116-
{
117-
{
118-
{RPCResult::Type::NUM, "id", "Peer index"},
119-
{RPCResult::Type::STR, "addr", "(host:port) The IP address and port of the peer"},
120-
{RPCResult::Type::STR, "addrbind", /* optional */ true, "(ip:port) Bind address of the connection to the peer"},
121-
{RPCResult::Type::STR, "addrlocal", /* optional */ true, "(ip:port) Local address as reported by the peer"},
122-
{RPCResult::Type::STR, "network", "Network (" + Join(GetNetworkNames(/* append_unroutable */ true), ", ") + ")"},
123-
{RPCResult::Type::NUM, "mapped_as", /* optional */ true, "The AS in the BGP route to the peer used for diversifying\n"
124-
"peer selection (only available if the asmap config flag is set)"},
125-
{RPCResult::Type::STR_HEX, "services", "The services offered"},
126-
{RPCResult::Type::ARR, "servicesnames", "the services offered, in human-readable form",
127-
{
128-
{RPCResult::Type::STR, "SERVICE_NAME", "the service name if it is recognised"}
129-
}},
130-
{RPCResult::Type::BOOL, "relaytxes", "Whether peer has asked us to relay transactions to it"},
131-
{RPCResult::Type::NUM_TIME, "lastsend", "The " + UNIX_EPOCH_TIME + " of the last send"},
132-
{RPCResult::Type::NUM_TIME, "lastrecv", "The " + UNIX_EPOCH_TIME + " of the last receive"},
133-
{RPCResult::Type::NUM_TIME, "last_transaction", "The " + UNIX_EPOCH_TIME + " of the last valid transaction received from this peer"},
134-
{RPCResult::Type::NUM_TIME, "last_block", "The " + UNIX_EPOCH_TIME + " of the last block received from this peer"},
135-
{RPCResult::Type::NUM, "bytessent", "The total bytes sent"},
136-
{RPCResult::Type::NUM, "bytesrecv", "The total bytes received"},
137-
{RPCResult::Type::NUM_TIME, "conntime", "The " + UNIX_EPOCH_TIME + " of the connection"},
138-
{RPCResult::Type::NUM, "timeoffset", "The time offset in seconds"},
139-
{RPCResult::Type::NUM, "pingtime", /* optional */ true, "ping time (if available)"},
140-
{RPCResult::Type::NUM, "minping", /* optional */ true, "minimum observed ping time (if any at all)"},
141-
{RPCResult::Type::NUM, "pingwait", /* optional */ true, "ping wait (if non-zero)"},
142-
{RPCResult::Type::NUM, "version", "The peer version, such as 70001"},
143-
{RPCResult::Type::STR, "subver", "The string version"},
144-
{RPCResult::Type::BOOL, "inbound", "Inbound (true) or Outbound (false)"},
145-
{RPCResult::Type::BOOL, "bip152_hb_to", "Whether we selected peer as (compact blocks) high-bandwidth peer"},
146-
{RPCResult::Type::BOOL, "bip152_hb_from", "Whether peer selected us as (compact blocks) high-bandwidth peer"},
147-
{RPCResult::Type::NUM, "startingheight", "The starting height (block) of the peer"},
148-
{RPCResult::Type::NUM, "synced_headers", "The last header we have in common with this peer"},
149-
{RPCResult::Type::NUM, "synced_blocks", "The last block we have in common with this peer"},
150-
{RPCResult::Type::ARR, "inflight", "",
151-
{
152-
{RPCResult::Type::NUM, "n", "The heights of blocks we're currently asking from this peer"},
153-
}},
154-
{RPCResult::Type::BOOL, "addr_relay_enabled", "Whether we participate in address relay with this peer"},
155-
{RPCResult::Type::NUM, "addr_processed", "The total number of addresses processed, excluding those dropped due to rate limiting"},
156-
{RPCResult::Type::NUM, "addr_rate_limited", "The total number of addresses dropped due to rate limiting"},
157-
{RPCResult::Type::ARR, "permissions", "Any special permissions that have been granted to this peer",
158-
{
159-
{RPCResult::Type::STR, "permission_type", Join(NET_PERMISSIONS_DOC, ",\n") + ".\n"},
160-
}},
161-
{RPCResult::Type::NUM, "minfeefilter", "The minimum fee rate for transactions this peer accepts"},
162-
{RPCResult::Type::OBJ_DYN, "bytessent_per_msg", "",
163-
{
164-
{RPCResult::Type::NUM, "msg", "The total bytes sent aggregated by message type\n"
165-
"When a message type is not listed in this json object, the bytes sent are 0.\n"
166-
"Only known message types can appear as keys in the object."}
167-
}},
168-
{RPCResult::Type::OBJ_DYN, "bytesrecv_per_msg", "",
169-
{
170-
{RPCResult::Type::NUM, "msg", "The total bytes received aggregated by message type\n"
171-
"When a message type is not listed in this json object, the bytes received are 0.\n"
172-
"Only known message types can appear as keys in the object and all bytes received\n"
173-
"of unknown message types are listed under '"+NET_MESSAGE_COMMAND_OTHER+"'."}
174-
}},
175-
{RPCResult::Type::STR, "connection_type", "Type of connection: \n" + Join(CONNECTION_TYPE_DOC, ",\n") + ".\n"
176-
"Please note this output is unlikely to be stable in upcoming releases as we iterate to\n"
177-
"best capture connection behaviors."},
178-
}},
119+
{RPCResult::Type::NUM, "id", "Peer index"},
120+
{RPCResult::Type::STR, "addr", "(host:port) The IP address and port of the peer"},
121+
{RPCResult::Type::STR, "addrbind", /* optional */ true, "(ip:port) Bind address of the connection to the peer"},
122+
{RPCResult::Type::STR, "addrlocal", /* optional */ true, "(ip:port) Local address as reported by the peer"},
123+
{RPCResult::Type::STR, "network", "Network (" + Join(GetNetworkNames(/* append_unroutable */ true), ", ") + ")"},
124+
{RPCResult::Type::NUM, "mapped_as", /* optional */ true, "The AS in the BGP route to the peer used for diversifying\n"
125+
"peer selection (only available if the asmap config flag is set)"},
126+
{RPCResult::Type::STR_HEX, "services", "The services offered"},
127+
{RPCResult::Type::ARR, "servicesnames", "the services offered, in human-readable form",
128+
{
129+
{RPCResult::Type::STR, "SERVICE_NAME", "the service name if it is recognised"}
179130
}},
180-
},
181-
RPCExamples{
182-
HelpExampleCli("getpeerinfo", "")
131+
{RPCResult::Type::BOOL, "relaytxes", "Whether peer has asked us to relay transactions to it"},
132+
{RPCResult::Type::NUM_TIME, "lastsend", "The " + UNIX_EPOCH_TIME + " of the last send"},
133+
{RPCResult::Type::NUM_TIME, "lastrecv", "The " + UNIX_EPOCH_TIME + " of the last receive"},
134+
{RPCResult::Type::NUM_TIME, "last_transaction", "The " + UNIX_EPOCH_TIME + " of the last valid transaction received from this peer"},
135+
{RPCResult::Type::NUM_TIME, "last_block", "The " + UNIX_EPOCH_TIME + " of the last block received from this peer"},
136+
{RPCResult::Type::NUM, "bytessent", "The total bytes sent"},
137+
{RPCResult::Type::NUM, "bytesrecv", "The total bytes received"},
138+
{RPCResult::Type::NUM_TIME, "conntime", "The " + UNIX_EPOCH_TIME + " of the connection"},
139+
{RPCResult::Type::NUM, "timeoffset", "The time offset in seconds"},
140+
{RPCResult::Type::NUM, "pingtime", /* optional */ true, "ping time (if available)"},
141+
{RPCResult::Type::NUM, "minping", /* optional */ true, "minimum observed ping time (if any at all)"},
142+
{RPCResult::Type::NUM, "pingwait", /* optional */ true, "ping wait (if non-zero)"},
143+
{RPCResult::Type::NUM, "version", "The peer version, such as 70001"},
144+
{RPCResult::Type::STR, "subver", "The string version"},
145+
{RPCResult::Type::BOOL, "inbound", "Inbound (true) or Outbound (false)"},
146+
{RPCResult::Type::BOOL, "bip152_hb_to", "Whether we selected peer as (compact blocks) high-bandwidth peer"},
147+
{RPCResult::Type::BOOL, "bip152_hb_from", "Whether peer selected us as (compact blocks) high-bandwidth peer"},
148+
{RPCResult::Type::NUM, "startingheight", /*optional=*/true, "The starting height (block) of the peer"},
149+
{RPCResult::Type::NUM, "synced_headers", /*optional=*/true, "The last header we have in common with this peer"},
150+
{RPCResult::Type::NUM, "synced_blocks", /*optional=*/true, "The last block we have in common with this peer"},
151+
{RPCResult::Type::ARR, "inflight", /*optional=*/true, "",
152+
{
153+
{RPCResult::Type::NUM, "n", "The heights of blocks we're currently asking from this peer"},
154+
}},
155+
{RPCResult::Type::BOOL, "addr_relay_enabled", /*optional=*/true, "Whether we participate in address relay with this peer"},
156+
{RPCResult::Type::NUM, "addr_processed", /*optional=*/true, "The total number of addresses processed, excluding those dropped due to rate limiting"},
157+
{RPCResult::Type::NUM, "addr_rate_limited", /*optional=*/true, "The total number of addresses dropped due to rate limiting"},
158+
{RPCResult::Type::ARR, "permissions", "Any special permissions that have been granted to this peer",
159+
{
160+
{RPCResult::Type::STR, "permission_type", Join(NET_PERMISSIONS_DOC, ",\n") + ".\n"},
161+
}},
162+
{RPCResult::Type::NUM, "minfeefilter", "The minimum fee rate for transactions this peer accepts"},
163+
{RPCResult::Type::OBJ_DYN, "bytessent_per_msg", "",
164+
{
165+
{RPCResult::Type::NUM, "msg", "The total bytes sent aggregated by message type\n"
166+
"When a message type is not listed in this json object, the bytes sent are 0.\n"
167+
"Only known message types can appear as keys in the object."}
168+
}},
169+
{RPCResult::Type::OBJ_DYN, "bytesrecv_per_msg", "",
170+
{
171+
{RPCResult::Type::NUM, "msg", "The total bytes received aggregated by message type\n"
172+
"When a message type is not listed in this json object, the bytes received are 0.\n"
173+
"Only known message types can appear as keys in the object and all bytes received\n"
174+
"of unknown message types are listed under '"+NET_MESSAGE_COMMAND_OTHER+"'."}
175+
}},
176+
{RPCResult::Type::STR, "connection_type", "Type of connection: \n" + Join(CONNECTION_TYPE_DOC, ",\n") + ".\n"
177+
"Please note this output is unlikely to be stable in upcoming releases as we iterate to\n"
178+
"best capture connection behaviors."},
179+
}},
180+
}},
181+
},
182+
RPCExamples{
183+
HelpExampleCli("getpeerinfo", "")
183184
+ HelpExampleRpc("getpeerinfo", "")
184-
},
185+
},
185186
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
186187
{
187188
NodeContext& node = EnsureAnyNodeContext(request.context);

0 commit comments

Comments
 (0)