refactor: move verbosity parsing to rpc/util

Provides a common way for rpcs to obtain
verbosity from an rpc parameter
This commit is contained in:
tdb3
2024-09-18 12:28:43 -04:00
parent 532491faf1
commit f511ff3654
4 changed files with 23 additions and 17 deletions

View File

@@ -81,6 +81,18 @@ void RPCTypeCheckObj(const UniValue& o,
}
}
int ParseVerbosity(const UniValue& arg, int default_verbosity)
{
if (!arg.isNull()) {
if (arg.isBool()) {
return arg.get_bool(); // true = 1
} else {
return arg.getInt<int>();
}
}
return default_verbosity;
}
CAmount AmountFromValue(const UniValue& value, int decimals)
{
if (!value.isNum() && !value.isStr())