mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
rpc: add "warnings" field to RPCs {create,load,unload,restore}wallet
This new "warnings" field is a JSON array of strings intended to replace the "warning" string field in these four RPCs, to better handle returning multiple warning messages and for consistency with other wallet RPCs.
This commit is contained in:
@@ -1175,8 +1175,25 @@ UniValue GetServicesNames(ServiceFlags services)
|
||||
return servicesNames;
|
||||
}
|
||||
|
||||
/** Convert a vector of bilingual strings to a UniValue::VARR containing their original untranslated values. */
|
||||
[[nodiscard]] static UniValue BilingualStringsToUniValue(const std::vector<bilingual_str>& bilingual_strings)
|
||||
{
|
||||
CHECK_NONFATAL(!bilingual_strings.empty());
|
||||
UniValue result{UniValue::VARR};
|
||||
for (const auto& s : bilingual_strings) {
|
||||
result.push_back(s.original);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void PushWarnings(const UniValue& warnings, UniValue& obj)
|
||||
{
|
||||
if (warnings.empty()) return;
|
||||
obj.pushKV("warnings", warnings);
|
||||
}
|
||||
|
||||
void PushWarnings(const std::vector<bilingual_str>& warnings, UniValue& obj)
|
||||
{
|
||||
if (warnings.empty()) return;
|
||||
obj.pushKV("warnings", BilingualStringsToUniValue(warnings));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user