From 8cc9845b8ddf4f93a02c622e7df8d1095dc1a640 Mon Sep 17 00:00:00 2001 From: w0xlt <94266259+w0xlt@users.noreply.github.com> Date: Wed, 18 Jun 2025 15:39:17 -0300 Subject: [PATCH] wallet, rpc: Use `OUTPUT_TYPES` to describe the output types instead of hardcoding them --- src/outputtype.cpp | 5 +++++ src/outputtype.h | 1 + src/wallet/rpc/addresses.cpp | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/outputtype.cpp b/src/outputtype.cpp index b4acc56c265..d4c2d95cfc1 100644 --- a/src/outputtype.cpp +++ b/src/outputtype.cpp @@ -46,6 +46,11 @@ const std::string& FormatOutputType(OutputType type) assert(false); } +std::string FormatAllOutputTypes() +{ + return util::Join(OUTPUT_TYPES, ", ", [](const auto& i) { return "\"" + FormatOutputType(i) + "\""; }); +} + CTxDestination AddAndGetDestinationForScript(FlatSigningProvider& keystore, const CScript& script, OutputType type) { // Add script to keystore diff --git a/src/outputtype.h b/src/outputtype.h index 7e625b0e9da..5a6f053918c 100644 --- a/src/outputtype.h +++ b/src/outputtype.h @@ -31,6 +31,7 @@ static constexpr auto OUTPUT_TYPES = std::array{ std::optional ParseOutputType(const std::string& str); const std::string& FormatOutputType(OutputType type); +std::string FormatAllOutputTypes(); /** * Get a destination of the requested type (if possible) to the specified script. diff --git a/src/wallet/rpc/addresses.cpp b/src/wallet/rpc/addresses.cpp index 39df2166bef..217f1ff8673 100644 --- a/src/wallet/rpc/addresses.cpp +++ b/src/wallet/rpc/addresses.cpp @@ -27,7 +27,7 @@ RPCHelpMan getnewaddress() "so payments received with the address will be associated with 'label'.\n", { {"label", RPCArg::Type::STR, RPCArg::Default{""}, "The label name for the address to be linked to. It can also be set to the empty string \"\" to represent the default label. The label does not need to exist, it will be created if there is no label by the given name."}, - {"address_type", RPCArg::Type::STR, RPCArg::DefaultHint{"set by -addresstype"}, "The address type to use. Options are \"legacy\", \"p2sh-segwit\", \"bech32\", and \"bech32m\"."}, + {"address_type", RPCArg::Type::STR, RPCArg::DefaultHint{"set by -addresstype"}, "The address type to use. Options are " + FormatAllOutputTypes() + "."}, }, RPCResult{ RPCResult::Type::STR, "address", "The new bitcoin address" @@ -219,7 +219,7 @@ RPCHelpMan keypoolrefill() { return RPCHelpMan{"keypoolrefill", "Refills each descriptor keypool in the wallet up to the specified number of new keys.\n" - "By default, descriptor wallets have 4 active ranged descriptors (\"legacy\", \"p2sh-segwit\", \"bech32\", and \"bech32m\"), each with " + util::ToString(DEFAULT_KEYPOOL_SIZE) + " entries.\n" + + "By default, descriptor wallets have 4 active ranged descriptors (" + FormatAllOutputTypes() + "), each with " + util::ToString(DEFAULT_KEYPOOL_SIZE) + " entries.\n" + HELP_REQUIRING_PASSPHRASE, { {"newsize", RPCArg::Type::NUM, RPCArg::DefaultHint{strprintf("%u, or as set by -keypool", DEFAULT_KEYPOOL_SIZE)}, "The new keypool size"},