mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-21 09:32:39 +02:00
Merge bitcoin/bitcoin#23652: doc: Document optional RPC result fields
fab6c43b40
doc: Document optional result fields in validateaddress (MarcoFalke)faee2656a8
doc: Document optional result fields in getpeerinfo (MarcoFalke) Pull request description: ACKs for top commit: shaavan: ACKfab6c43b40
Tree-SHA512: 78458d0c4deb9253fbfe37fa5736a7db14eb0478bcc4adeba10ba6945e83d8eac92048293f50c054ea612609939151b4a2e1226c06f6067901f3d58c127c7e18
This commit is contained in:
commit
0ee9a00f90
@ -36,32 +36,33 @@
|
||||
|
||||
static RPCHelpMan validateaddress()
|
||||
{
|
||||
return RPCHelpMan{"validateaddress",
|
||||
"\nReturn information about the given bitcoin address.\n",
|
||||
{
|
||||
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The bitcoin address to validate"},
|
||||
},
|
||||
RPCResult{
|
||||
RPCResult::Type::OBJ, "", "",
|
||||
return RPCHelpMan{
|
||||
"validateaddress",
|
||||
"\nReturn information about the given bitcoin address.\n",
|
||||
{
|
||||
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The bitcoin address to validate"},
|
||||
},
|
||||
RPCResult{
|
||||
RPCResult::Type::OBJ, "", "",
|
||||
{
|
||||
{RPCResult::Type::BOOL, "isvalid", "If the address is valid or not"},
|
||||
{RPCResult::Type::STR, "address", /* optional */ true, "The bitcoin address validated"},
|
||||
{RPCResult::Type::STR_HEX, "scriptPubKey", /* optional */ true, "The hex-encoded scriptPubKey generated by the address"},
|
||||
{RPCResult::Type::BOOL, "isscript", /* optional */ true, "If the key is a script"},
|
||||
{RPCResult::Type::BOOL, "iswitness", /* optional */ true, "If the address is a witness address"},
|
||||
{RPCResult::Type::NUM, "witness_version", /* optional */ true, "The version number of the witness program"},
|
||||
{RPCResult::Type::STR_HEX, "witness_program", /* optional */ true, "The hex value of the witness program"},
|
||||
{RPCResult::Type::STR, "error", /* optional */ true, "Error message, if any"},
|
||||
{RPCResult::Type::ARR, "error_locations", /*optional=*/true, "Indices of likely error locations in address, if known (e.g. Bech32 errors)",
|
||||
{
|
||||
{RPCResult::Type::BOOL, "isvalid", "If the address is valid or not"},
|
||||
{RPCResult::Type::STR, "address", /* optional */ true, "The bitcoin address validated"},
|
||||
{RPCResult::Type::STR_HEX, "scriptPubKey", /* optional */ true, "The hex-encoded scriptPubKey generated by the address"},
|
||||
{RPCResult::Type::BOOL, "isscript", /* optional */ true, "If the key is a script"},
|
||||
{RPCResult::Type::BOOL, "iswitness", /* optional */ true, "If the address is a witness address"},
|
||||
{RPCResult::Type::NUM, "witness_version", /* optional */ true, "The version number of the witness program"},
|
||||
{RPCResult::Type::STR_HEX, "witness_program", /* optional */ true, "The hex value of the witness program"},
|
||||
{RPCResult::Type::STR, "error", /* optional */ true, "Error message, if any"},
|
||||
{RPCResult::Type::ARR, "error_locations", "Indices of likely error locations in address, if known (e.g. Bech32 errors)",
|
||||
{
|
||||
{RPCResult::Type::NUM, "index", "index of a potential error"},
|
||||
}},
|
||||
}
|
||||
},
|
||||
RPCExamples{
|
||||
HelpExampleCli("validateaddress", "\"" + EXAMPLE_ADDRESS[0] + "\"") +
|
||||
HelpExampleRpc("validateaddress", "\"" + EXAMPLE_ADDRESS[0] + "\"")
|
||||
},
|
||||
{RPCResult::Type::NUM, "index", "index of a potential error"},
|
||||
}},
|
||||
}
|
||||
},
|
||||
RPCExamples{
|
||||
HelpExampleCli("validateaddress", "\"" + EXAMPLE_ADDRESS[0] + "\"") +
|
||||
HelpExampleRpc("validateaddress", "\"" + EXAMPLE_ADDRESS[0] + "\"")
|
||||
},
|
||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||
{
|
||||
std::string error_msg;
|
||||
|
147
src/rpc/net.cpp
147
src/rpc/net.cpp
@ -106,82 +106,83 @@ static RPCHelpMan ping()
|
||||
|
||||
static RPCHelpMan getpeerinfo()
|
||||
{
|
||||
return RPCHelpMan{"getpeerinfo",
|
||||
"\nReturns data about each connected network node as a json array of objects.\n",
|
||||
{},
|
||||
RPCResult{
|
||||
RPCResult::Type::ARR, "", "",
|
||||
return RPCHelpMan{
|
||||
"getpeerinfo",
|
||||
"\nReturns data about each connected network node as a json array of objects.\n",
|
||||
{},
|
||||
RPCResult{
|
||||
RPCResult::Type::ARR, "", "",
|
||||
{
|
||||
{RPCResult::Type::OBJ, "", "",
|
||||
{
|
||||
{
|
||||
{RPCResult::Type::OBJ, "", "",
|
||||
{
|
||||
{
|
||||
{RPCResult::Type::NUM, "id", "Peer index"},
|
||||
{RPCResult::Type::STR, "addr", "(host:port) The IP address and port of the peer"},
|
||||
{RPCResult::Type::STR, "addrbind", /* optional */ true, "(ip:port) Bind address of the connection to the peer"},
|
||||
{RPCResult::Type::STR, "addrlocal", /* optional */ true, "(ip:port) Local address as reported by the peer"},
|
||||
{RPCResult::Type::STR, "network", "Network (" + Join(GetNetworkNames(/* append_unroutable */ true), ", ") + ")"},
|
||||
{RPCResult::Type::NUM, "mapped_as", /* optional */ true, "The AS in the BGP route to the peer used for diversifying\n"
|
||||
"peer selection (only available if the asmap config flag is set)"},
|
||||
{RPCResult::Type::STR_HEX, "services", "The services offered"},
|
||||
{RPCResult::Type::ARR, "servicesnames", "the services offered, in human-readable form",
|
||||
{
|
||||
{RPCResult::Type::STR, "SERVICE_NAME", "the service name if it is recognised"}
|
||||
}},
|
||||
{RPCResult::Type::BOOL, "relaytxes", "Whether peer has asked us to relay transactions to it"},
|
||||
{RPCResult::Type::NUM_TIME, "lastsend", "The " + UNIX_EPOCH_TIME + " of the last send"},
|
||||
{RPCResult::Type::NUM_TIME, "lastrecv", "The " + UNIX_EPOCH_TIME + " of the last receive"},
|
||||
{RPCResult::Type::NUM_TIME, "last_transaction", "The " + UNIX_EPOCH_TIME + " of the last valid transaction received from this peer"},
|
||||
{RPCResult::Type::NUM_TIME, "last_block", "The " + UNIX_EPOCH_TIME + " of the last block received from this peer"},
|
||||
{RPCResult::Type::NUM, "bytessent", "The total bytes sent"},
|
||||
{RPCResult::Type::NUM, "bytesrecv", "The total bytes received"},
|
||||
{RPCResult::Type::NUM_TIME, "conntime", "The " + UNIX_EPOCH_TIME + " of the connection"},
|
||||
{RPCResult::Type::NUM, "timeoffset", "The time offset in seconds"},
|
||||
{RPCResult::Type::NUM, "pingtime", /* optional */ true, "ping time (if available)"},
|
||||
{RPCResult::Type::NUM, "minping", /* optional */ true, "minimum observed ping time (if any at all)"},
|
||||
{RPCResult::Type::NUM, "pingwait", /* optional */ true, "ping wait (if non-zero)"},
|
||||
{RPCResult::Type::NUM, "version", "The peer version, such as 70001"},
|
||||
{RPCResult::Type::STR, "subver", "The string version"},
|
||||
{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, "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"},
|
||||
{RPCResult::Type::ARR, "inflight", "",
|
||||
{
|
||||
{RPCResult::Type::NUM, "n", "The heights of blocks we're currently asking from this peer"},
|
||||
}},
|
||||
{RPCResult::Type::BOOL, "addr_relay_enabled", "Whether we participate in address relay with this peer"},
|
||||
{RPCResult::Type::NUM, "addr_processed", "The total number of addresses processed, excluding those dropped due to rate limiting"},
|
||||
{RPCResult::Type::NUM, "addr_rate_limited", "The total number of addresses dropped due to rate limiting"},
|
||||
{RPCResult::Type::ARR, "permissions", "Any special permissions that have been granted to this peer",
|
||||
{
|
||||
{RPCResult::Type::STR, "permission_type", Join(NET_PERMISSIONS_DOC, ",\n") + ".\n"},
|
||||
}},
|
||||
{RPCResult::Type::NUM, "minfeefilter", "The minimum fee rate for transactions this peer accepts"},
|
||||
{RPCResult::Type::OBJ_DYN, "bytessent_per_msg", "",
|
||||
{
|
||||
{RPCResult::Type::NUM, "msg", "The total bytes sent aggregated by message type\n"
|
||||
"When a message type is not listed in this json object, the bytes sent are 0.\n"
|
||||
"Only known message types can appear as keys in the object."}
|
||||
}},
|
||||
{RPCResult::Type::OBJ_DYN, "bytesrecv_per_msg", "",
|
||||
{
|
||||
{RPCResult::Type::NUM, "msg", "The total bytes received aggregated by message type\n"
|
||||
"When a message type is not listed in this json object, the bytes received are 0.\n"
|
||||
"Only known message types can appear as keys in the object and all bytes received\n"
|
||||
"of unknown message types are listed under '"+NET_MESSAGE_COMMAND_OTHER+"'."}
|
||||
}},
|
||||
{RPCResult::Type::STR, "connection_type", "Type of connection: \n" + Join(CONNECTION_TYPE_DOC, ",\n") + ".\n"
|
||||
"Please note this output is unlikely to be stable in upcoming releases as we iterate to\n"
|
||||
"best capture connection behaviors."},
|
||||
}},
|
||||
{RPCResult::Type::NUM, "id", "Peer index"},
|
||||
{RPCResult::Type::STR, "addr", "(host:port) The IP address and port of the peer"},
|
||||
{RPCResult::Type::STR, "addrbind", /* optional */ true, "(ip:port) Bind address of the connection to the peer"},
|
||||
{RPCResult::Type::STR, "addrlocal", /* optional */ true, "(ip:port) Local address as reported by the peer"},
|
||||
{RPCResult::Type::STR, "network", "Network (" + Join(GetNetworkNames(/* append_unroutable */ true), ", ") + ")"},
|
||||
{RPCResult::Type::NUM, "mapped_as", /* optional */ true, "The AS in the BGP route to the peer used for diversifying\n"
|
||||
"peer selection (only available if the asmap config flag is set)"},
|
||||
{RPCResult::Type::STR_HEX, "services", "The services offered"},
|
||||
{RPCResult::Type::ARR, "servicesnames", "the services offered, in human-readable form",
|
||||
{
|
||||
{RPCResult::Type::STR, "SERVICE_NAME", "the service name if it is recognised"}
|
||||
}},
|
||||
},
|
||||
RPCExamples{
|
||||
HelpExampleCli("getpeerinfo", "")
|
||||
{RPCResult::Type::BOOL, "relaytxes", "Whether peer has asked us to relay transactions to it"},
|
||||
{RPCResult::Type::NUM_TIME, "lastsend", "The " + UNIX_EPOCH_TIME + " of the last send"},
|
||||
{RPCResult::Type::NUM_TIME, "lastrecv", "The " + UNIX_EPOCH_TIME + " of the last receive"},
|
||||
{RPCResult::Type::NUM_TIME, "last_transaction", "The " + UNIX_EPOCH_TIME + " of the last valid transaction received from this peer"},
|
||||
{RPCResult::Type::NUM_TIME, "last_block", "The " + UNIX_EPOCH_TIME + " of the last block received from this peer"},
|
||||
{RPCResult::Type::NUM, "bytessent", "The total bytes sent"},
|
||||
{RPCResult::Type::NUM, "bytesrecv", "The total bytes received"},
|
||||
{RPCResult::Type::NUM_TIME, "conntime", "The " + UNIX_EPOCH_TIME + " of the connection"},
|
||||
{RPCResult::Type::NUM, "timeoffset", "The time offset in seconds"},
|
||||
{RPCResult::Type::NUM, "pingtime", /* optional */ true, "ping time (if available)"},
|
||||
{RPCResult::Type::NUM, "minping", /* optional */ true, "minimum observed ping time (if any at all)"},
|
||||
{RPCResult::Type::NUM, "pingwait", /* optional */ true, "ping wait (if non-zero)"},
|
||||
{RPCResult::Type::NUM, "version", "The peer version, such as 70001"},
|
||||
{RPCResult::Type::STR, "subver", "The string version"},
|
||||
{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", /*optional=*/true, "The starting height (block) of the peer"},
|
||||
{RPCResult::Type::NUM, "synced_headers", /*optional=*/true, "The last header we have in common with this peer"},
|
||||
{RPCResult::Type::NUM, "synced_blocks", /*optional=*/true, "The last block we have in common with this peer"},
|
||||
{RPCResult::Type::ARR, "inflight", /*optional=*/true, "",
|
||||
{
|
||||
{RPCResult::Type::NUM, "n", "The heights of blocks we're currently asking from this peer"},
|
||||
}},
|
||||
{RPCResult::Type::BOOL, "addr_relay_enabled", /*optional=*/true, "Whether we participate in address relay with this peer"},
|
||||
{RPCResult::Type::NUM, "addr_processed", /*optional=*/true, "The total number of addresses processed, excluding those dropped due to rate limiting"},
|
||||
{RPCResult::Type::NUM, "addr_rate_limited", /*optional=*/true, "The total number of addresses dropped due to rate limiting"},
|
||||
{RPCResult::Type::ARR, "permissions", "Any special permissions that have been granted to this peer",
|
||||
{
|
||||
{RPCResult::Type::STR, "permission_type", Join(NET_PERMISSIONS_DOC, ",\n") + ".\n"},
|
||||
}},
|
||||
{RPCResult::Type::NUM, "minfeefilter", "The minimum fee rate for transactions this peer accepts"},
|
||||
{RPCResult::Type::OBJ_DYN, "bytessent_per_msg", "",
|
||||
{
|
||||
{RPCResult::Type::NUM, "msg", "The total bytes sent aggregated by message type\n"
|
||||
"When a message type is not listed in this json object, the bytes sent are 0.\n"
|
||||
"Only known message types can appear as keys in the object."}
|
||||
}},
|
||||
{RPCResult::Type::OBJ_DYN, "bytesrecv_per_msg", "",
|
||||
{
|
||||
{RPCResult::Type::NUM, "msg", "The total bytes received aggregated by message type\n"
|
||||
"When a message type is not listed in this json object, the bytes received are 0.\n"
|
||||
"Only known message types can appear as keys in the object and all bytes received\n"
|
||||
"of unknown message types are listed under '"+NET_MESSAGE_COMMAND_OTHER+"'."}
|
||||
}},
|
||||
{RPCResult::Type::STR, "connection_type", "Type of connection: \n" + Join(CONNECTION_TYPE_DOC, ",\n") + ".\n"
|
||||
"Please note this output is unlikely to be stable in upcoming releases as we iterate to\n"
|
||||
"best capture connection behaviors."},
|
||||
}},
|
||||
}},
|
||||
},
|
||||
RPCExamples{
|
||||
HelpExampleCli("getpeerinfo", "")
|
||||
+ HelpExampleRpc("getpeerinfo", "")
|
||||
},
|
||||
},
|
||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||
{
|
||||
NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||
|
Loading…
Reference in New Issue
Block a user