Skip to content

Commit 8cc9845

Browse files
committed
wallet, rpc: Use OUTPUT_TYPES to describe the output types instead of hardcoding them
1 parent dff208b commit 8cc9845

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

src/outputtype.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ const std::string& FormatOutputType(OutputType type)
4646
assert(false);
4747
}
4848

49+
std::string FormatAllOutputTypes()
50+
{
51+
return util::Join(OUTPUT_TYPES, ", ", [](const auto& i) { return "\"" + FormatOutputType(i) + "\""; });
52+
}
53+
4954
CTxDestination AddAndGetDestinationForScript(FlatSigningProvider& keystore, const CScript& script, OutputType type)
5055
{
5156
// Add script to keystore

src/outputtype.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ static constexpr auto OUTPUT_TYPES = std::array{
3131

3232
std::optional<OutputType> ParseOutputType(const std::string& str);
3333
const std::string& FormatOutputType(OutputType type);
34+
std::string FormatAllOutputTypes();
3435

3536
/**
3637
* Get a destination of the requested type (if possible) to the specified script.

src/wallet/rpc/addresses.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ RPCHelpMan getnewaddress()
2727
"so payments received with the address will be associated with 'label'.\n",
2828
{
2929
{"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."},
30-
{"address_type", RPCArg::Type::STR, RPCArg::DefaultHint{"set by -addresstype"}, "The address type to use. Options are \"legacy\", \"p2sh-segwit\", \"bech32\", and \"bech32m\"."},
30+
{"address_type", RPCArg::Type::STR, RPCArg::DefaultHint{"set by -addresstype"}, "The address type to use. Options are " + FormatAllOutputTypes() + "."},
3131
},
3232
RPCResult{
3333
RPCResult::Type::STR, "address", "The new bitcoin address"
@@ -219,7 +219,7 @@ RPCHelpMan keypoolrefill()
219219
{
220220
return RPCHelpMan{"keypoolrefill",
221221
"Refills each descriptor keypool in the wallet up to the specified number of new keys.\n"
222-
"By default, descriptor wallets have 4 active ranged descriptors (\"legacy\", \"p2sh-segwit\", \"bech32\", and \"bech32m\"), each with " + util::ToString(DEFAULT_KEYPOOL_SIZE) + " entries.\n" +
222+
"By default, descriptor wallets have 4 active ranged descriptors (" + FormatAllOutputTypes() + "), each with " + util::ToString(DEFAULT_KEYPOOL_SIZE) + " entries.\n" +
223223
HELP_REQUIRING_PASSPHRASE,
224224
{
225225
{"newsize", RPCArg::Type::NUM, RPCArg::DefaultHint{strprintf("%u, or as set by -keypool", DEFAULT_KEYPOOL_SIZE)}, "The new keypool size"},

0 commit comments

Comments
 (0)