mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-12 04:42:36 -03:00
Merge bitcoin/bitcoin#24339: rpc: Improve RPC help by explicitly mentioning output types
c821ab8be8
Use `GetAllOutputTypes` in `getblock` RPC function (Kiminuo)d970a85d33
Move `GetAllOutputTypes` function from `rpc/rawtransaction.cpp` to `rpc/util.{h|cpp}` (Kiminuo) Pull request description: This PR attempts to replicate0ccf9b2e55/src/rpc/rawtransaction.cpp (L547)
to one other place (at the moment) so that users have better idea what RPC methods can actually return. I created this PR as a follow-up to the idea mentioned here https://github.com/bitcoin/bitcoin/pull/23320#discussion_r732458112 (resolved). ACKs for top commit: kristapsk: re-ACKc821ab8be8
Tree-SHA512: 5ff66a41ad7c43ec769f4a99933d2d070feea7c617286d94b6f9bfa1a2547a42211915778210a89074ad4b14d99f34852cc6871efed5e6f1e2ffedd40d669386
This commit is contained in:
commit
1337b93f50
4 changed files with 18 additions and 11 deletions
|
@ -1037,7 +1037,7 @@ static RPCHelpMan getblock()
|
||||||
{RPCResult::Type::STR, "asm", "The asm"},
|
{RPCResult::Type::STR, "asm", "The asm"},
|
||||||
{RPCResult::Type::STR, "hex", "The hex"},
|
{RPCResult::Type::STR, "hex", "The hex"},
|
||||||
{RPCResult::Type::STR, "address", /* optional */ true, "The Bitcoin address (only if a well-defined address exists)"},
|
{RPCResult::Type::STR, "address", /* optional */ true, "The Bitcoin address (only if a well-defined address exists)"},
|
||||||
{RPCResult::Type::STR, "type", "The type, eg 'pubkeyhash'"},
|
{RPCResult::Type::STR, "type", "The type (one of: " + GetAllOutputTypes() + ")"},
|
||||||
}},
|
}},
|
||||||
}},
|
}},
|
||||||
}},
|
}},
|
||||||
|
|
|
@ -542,16 +542,6 @@ static RPCHelpMan decoderawtransaction()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string GetAllOutputTypes()
|
|
||||||
{
|
|
||||||
std::vector<std::string> ret;
|
|
||||||
using U = std::underlying_type<TxoutType>::type;
|
|
||||||
for (U i = (U)TxoutType::NONSTANDARD; i <= (U)TxoutType::WITNESS_UNKNOWN; ++i) {
|
|
||||||
ret.emplace_back(GetTxnOutputType(static_cast<TxoutType>(i)));
|
|
||||||
}
|
|
||||||
return Join(ret, ", ");
|
|
||||||
}
|
|
||||||
|
|
||||||
static RPCHelpMan decodescript()
|
static RPCHelpMan decodescript()
|
||||||
{
|
{
|
||||||
return RPCHelpMan{
|
return RPCHelpMan{
|
||||||
|
|
|
@ -21,6 +21,16 @@
|
||||||
const std::string UNIX_EPOCH_TIME = "UNIX epoch time";
|
const std::string UNIX_EPOCH_TIME = "UNIX epoch time";
|
||||||
const std::string EXAMPLE_ADDRESS[2] = {"bc1q09vm5lfy0j5reeulh4x5752q25uqqvz34hufdl", "bc1q02ad21edsxd23d32dfgqqsz4vv4nmtfzuklhy3"};
|
const std::string EXAMPLE_ADDRESS[2] = {"bc1q09vm5lfy0j5reeulh4x5752q25uqqvz34hufdl", "bc1q02ad21edsxd23d32dfgqqsz4vv4nmtfzuklhy3"};
|
||||||
|
|
||||||
|
std::string GetAllOutputTypes()
|
||||||
|
{
|
||||||
|
std::vector<std::string> ret;
|
||||||
|
using U = std::underlying_type<TxoutType>::type;
|
||||||
|
for (U i = (U)TxoutType::NONSTANDARD; i <= (U)TxoutType::WITNESS_UNKNOWN; ++i) {
|
||||||
|
ret.emplace_back(GetTxnOutputType(static_cast<TxoutType>(i)));
|
||||||
|
}
|
||||||
|
return Join(ret, ", ");
|
||||||
|
}
|
||||||
|
|
||||||
void RPCTypeCheck(const UniValue& params,
|
void RPCTypeCheck(const UniValue& params,
|
||||||
const std::list<UniValueType>& typesExpected,
|
const std::list<UniValueType>& typesExpected,
|
||||||
bool fAllowNull)
|
bool fAllowNull)
|
||||||
|
|
|
@ -39,6 +39,13 @@ class CPubKey;
|
||||||
class CScript;
|
class CScript;
|
||||||
struct Sections;
|
struct Sections;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all existing output types formatted for RPC help sections.
|
||||||
|
*
|
||||||
|
* @return Comma separated string representing output type names.
|
||||||
|
*/
|
||||||
|
std::string GetAllOutputTypes();
|
||||||
|
|
||||||
/** Wrapper for UniValue::VType, which includes typeAny:
|
/** Wrapper for UniValue::VType, which includes typeAny:
|
||||||
* Used to denote don't care type. */
|
* Used to denote don't care type. */
|
||||||
struct UniValueType {
|
struct UniValueType {
|
||||||
|
|
Loading…
Reference in a new issue