From d970a85d335202cc85f6604f794c43af6645673f Mon Sep 17 00:00:00 2001 From: Kiminuo Date: Mon, 14 Feb 2022 14:33:39 +0100 Subject: Move `GetAllOutputTypes` function from `rpc/rawtransaction.cpp` to `rpc/util.{h|cpp}` --- src/rpc/rawtransaction.cpp | 10 ---------- src/rpc/util.cpp | 10 ++++++++++ src/rpc/util.h | 7 +++++++ 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index ff0d8a4e0f..023ddbe73e 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -542,16 +542,6 @@ static RPCHelpMan decoderawtransaction() }; } -static std::string GetAllOutputTypes() -{ - std::vector ret; - using U = std::underlying_type::type; - for (U i = (U)TxoutType::NONSTANDARD; i <= (U)TxoutType::WITNESS_UNKNOWN; ++i) { - ret.emplace_back(GetTxnOutputType(static_cast(i))); - } - return Join(ret, ", "); -} - static RPCHelpMan decodescript() { return RPCHelpMan{ diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp index 5ef7e26ce8..7c859268be 100644 --- a/src/rpc/util.cpp +++ b/src/rpc/util.cpp @@ -21,6 +21,16 @@ const std::string UNIX_EPOCH_TIME = "UNIX epoch time"; const std::string EXAMPLE_ADDRESS[2] = {"bc1q09vm5lfy0j5reeulh4x5752q25uqqvz34hufdl", "bc1q02ad21edsxd23d32dfgqqsz4vv4nmtfzuklhy3"}; +std::string GetAllOutputTypes() +{ + std::vector ret; + using U = std::underlying_type::type; + for (U i = (U)TxoutType::NONSTANDARD; i <= (U)TxoutType::WITNESS_UNKNOWN; ++i) { + ret.emplace_back(GetTxnOutputType(static_cast(i))); + } + return Join(ret, ", "); +} + void RPCTypeCheck(const UniValue& params, const std::list& typesExpected, bool fAllowNull) diff --git a/src/rpc/util.h b/src/rpc/util.h index 25ebf78fa1..89d32d4193 100644 --- a/src/rpc/util.h +++ b/src/rpc/util.h @@ -39,6 +39,13 @@ class CPubKey; class CScript; 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: * Used to denote don't care type. */ struct UniValueType { -- cgit v1.2.3 From c821ab8be8dffb749853c05e05cb515c11e6328a Mon Sep 17 00:00:00 2001 From: Kiminuo Date: Mon, 14 Feb 2022 14:33:55 +0100 Subject: Use `GetAllOutputTypes` in `getblock` RPC function --- src/rpc/blockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 69204e346a..f18b800e23 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1037,7 +1037,7 @@ static RPCHelpMan getblock() {RPCResult::Type::STR, "asm", "The asm"}, {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, "type", "The type, eg 'pubkeyhash'"}, + {RPCResult::Type::STR, "type", "The type (one of: " + GetAllOutputTypes() + ")"}, }}, }}, }}, -- cgit v1.2.3