Skip to content

Commit

Permalink
rpc: Auto-format RPCResult
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoFalke committed Feb 25, 2020
1 parent fa7d050 commit fa6b061
Show file tree
Hide file tree
Showing 11 changed files with 1,473 additions and 1,205 deletions.
620 changes: 298 additions & 322 deletions src/rpc/blockchain.cpp

Large diffs are not rendered by default.

219 changes: 119 additions & 100 deletions src/rpc/mining.cpp

Large diffs are not rendered by default.

86 changes: 47 additions & 39 deletions src/rpc/misc.cpp
Expand Up @@ -33,15 +33,16 @@ static UniValue validateaddress(const JSONRPCRequest& request)
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The bitcoin address to validate"},
},
RPCResult{
"{\n"
" \"isvalid\" : true|false, (boolean) If the address is valid or not. If not, this is the only property returned.\n"
" \"address\" : \"address\", (string) The bitcoin address validated\n"
" \"scriptPubKey\" : \"hex\", (string) The hex-encoded scriptPubKey generated by the address\n"
" \"isscript\" : true|false, (boolean) If the key is a script\n"
" \"iswitness\" : true|false, (boolean) If the address is a witness address\n"
" \"witness_version\" : version (numeric, optional) The version number of the witness program\n"
" \"witness_program\" : \"hex\" (string, optional) The hex value of the witness program\n"
"}\n"
RPCResult::Type::OBJ, "", "",
{
{RPCResult::Type::BOOL, "isvalid", "If the address is valid or not. If not, this is the only property returned."},
{RPCResult::Type::STR, "address", "The bitcoin address validated"},
{RPCResult::Type::STR_HEX, "scriptPubKey", "The hex-encoded scriptPubKey generated by the address"},
{RPCResult::Type::BOOL, "isscript", "If the key is a script"},
{RPCResult::Type::BOOL, "iswitness", "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"},
}
},
RPCExamples{
HelpExampleCli("validateaddress", EXAMPLE_ADDRESS) +
Expand Down Expand Up @@ -82,11 +83,12 @@ static UniValue createmultisig(const JSONRPCRequest& request)
{"address_type", RPCArg::Type::STR, /* default */ "legacy", "The address type to use. Options are \"legacy\", \"p2sh-segwit\", and \"bech32\"."},
},
RPCResult{
"{\n"
" \"address\" : \"multisigaddress\", (string) The value of the new multisig address.\n"
" \"redeemScript\" : \"script\" (string) The string value of the hex-encoded redemption script.\n"
" \"descriptor\" : \"descriptor\" (string) The descriptor for this multisig\n"
"}\n"
RPCResult::Type::OBJ, "", "",
{
{RPCResult::Type::STR, "address", "The value of the new multisig address."},
{RPCResult::Type::STR_HEX, "redeemScript", "The string value of the hex-encoded redemption script."},
{RPCResult::Type::STR, "descriptor", "The descriptor for this multisig"},
}
},
RPCExamples{
"\nCreate a multisig address from 2 public keys\n"
Expand Down Expand Up @@ -141,13 +143,14 @@ UniValue getdescriptorinfo(const JSONRPCRequest& request)
{"descriptor", RPCArg::Type::STR, RPCArg::Optional::NO, "The descriptor."},
},
RPCResult{
"{\n"
" \"descriptor\" : \"desc\", (string) The descriptor in canonical form, without private keys\n"
" \"checksum\" : \"chksum\", (string) The checksum for the input descriptor\n"
" \"isrange\" : true|false, (boolean) Whether the descriptor is ranged\n"
" \"issolvable\" : true|false, (boolean) Whether the descriptor is solvable\n"
" \"hasprivatekeys\" : true|false, (boolean) Whether the input descriptor contained at least one private key\n"
"}\n"
RPCResult::Type::OBJ, "", "",
{
{RPCResult::Type::STR, "descriptor", "The descriptor in canonical form, without private keys"},
{RPCResult::Type::STR, "checksum", "The checksum for the input descriptor"},
{RPCResult::Type::BOOL, "isrange", "Whether the descriptor is ranged"},
{RPCResult::Type::BOOL, "issolvable", "Whether the descriptor is solvable"},
{RPCResult::Type::BOOL, "hasprivatekeys", "Whether the input descriptor contained at least one private key"},
}
},
RPCExamples{
"Analyse a descriptor\n" +
Expand Down Expand Up @@ -189,7 +192,10 @@ UniValue deriveaddresses(const JSONRPCRequest& request)
{"range", RPCArg::Type::RANGE, RPCArg::Optional::OMITTED_NAMED_ARG, "If a ranged descriptor is used, this specifies the end or the range (in [begin,end] notation) to derive."},
},
RPCResult{
"[ address ] (json array) the derived addresses\n"
RPCResult::Type::ARR, "", "",
{
{RPCResult::Type::STR, "address", "the derived addresses"},
}
},
RPCExamples{
"First three native segwit receive addresses\n" +
Expand Down Expand Up @@ -258,7 +264,7 @@ static UniValue verifymessage(const JSONRPCRequest& request)
{"message", RPCArg::Type::STR, RPCArg::Optional::NO, "The message that was signed."},
},
RPCResult{
"true|false (boolean) If the signature is verified or not.\n"
RPCResult::Type::BOOL, "", "If the signature is verified or not."
},
RPCExamples{
"\nUnlock the wallet for 30 seconds\n"
Expand Down Expand Up @@ -304,7 +310,7 @@ static UniValue signmessagewithprivkey(const JSONRPCRequest& request)
{"message", RPCArg::Type::STR, RPCArg::Optional::NO, "The message to create a signature of."},
},
RPCResult{
"\"signature\" (string) The signature of the message encoded in base 64\n"
RPCResult::Type::STR, "signature", "The signature of the message encoded in base 64"
},
RPCExamples{
"\nCreate the signature\n"
Expand Down Expand Up @@ -437,19 +443,21 @@ static UniValue getmemoryinfo(const JSONRPCRequest& request)
},
{
RPCResult{"mode \"stats\"",
"{\n"
" \"locked\" : { (json object) Information about locked memory manager\n"
" \"used\" : xxxxx, (numeric) Number of bytes used\n"
" \"free\" : xxxxx, (numeric) Number of bytes available in current arenas\n"
" \"total\" : xxxxxxx, (numeric) Total number of bytes managed\n"
" \"locked\" : xxxxxx, (numeric) Amount of bytes that succeeded locking. If this number is smaller than total, locking pages failed at some point and key data could be swapped to disk.\n"
" \"chunks_used\" : xxxxx, (numeric) Number allocated chunks\n"
" \"chunks_free\" : xxxxx, (numeric) Number unused chunks\n"
" }\n"
"}\n"
RPCResult::Type::OBJ, "", "",
{
{RPCResult::Type::OBJ, "locked", "Information about locked memory manager",
{
{RPCResult::Type::NUM, "used", "Number of bytes used"},
{RPCResult::Type::NUM, "free", "Number of bytes available in current arenas"},
{RPCResult::Type::NUM, "total", "Total number of bytes managed"},
{RPCResult::Type::NUM, "locked", "Amount of bytes that succeeded locking. If this number is smaller than total, locking pages failed at some point and key data could be swapped to disk."},
{RPCResult::Type::NUM, "chunks_used", "Number allocated chunks"},
{RPCResult::Type::NUM, "chunks_free", "Number unused chunks"},
}},
}
},
RPCResult{"mode \"mallocinfo\"",
"\"<malloc version=\"1\">...\"\n"
RPCResult::Type::STR, "", "\"<malloc version=\"1\">...\""
},
},
RPCExamples{
Expand Down Expand Up @@ -516,10 +524,10 @@ UniValue logging(const JSONRPCRequest& request)
}},
},
RPCResult{
"{ (json object where keys are the logging categories, and values indicates its status\n"
" \"category\" : true|false, (boolean) if being debug logged or not. false:inactive, true:active\n"
" ...\n"
"}\n"
RPCResult::Type::OBJ_DYN, "", "keys are the logging categories, and values indicates its status",
{
{RPCResult::Type::BOOL, "category", "if being debug logged or not. false:inactive, true:active"},
}
},
RPCExamples{
HelpExampleCli("logging", "\"[\\\"all\\\"]\" \"[\\\"http\\\"]\"")
Expand Down

0 comments on commit fa6b061

Please sign in to comment.