diff options
Diffstat (limited to 'src/rpc')
-rw-r--r-- | src/rpc/output_script.cpp | 2 | ||||
-rw-r--r-- | src/rpc/util.cpp | 6 | ||||
-rw-r--r-- | src/rpc/util.h | 8 |
3 files changed, 15 insertions, 1 deletions
diff --git a/src/rpc/output_script.cpp b/src/rpc/output_script.cpp index bb04f58424..990ec3ab0c 100644 --- a/src/rpc/output_script.cpp +++ b/src/rpc/output_script.cpp @@ -162,7 +162,7 @@ static RPCHelpMan createmultisig() // Only warns if the user has explicitly chosen an address type we cannot generate warnings.push_back("Unable to make chosen address type, please ensure no uncompressed public keys are present."); } - if (!warnings.empty()) result.pushKV("warnings", warnings); + PushWarnings(warnings, result); return result; }, diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp index ee9e3544a4..f01944cd0b 100644 --- a/src/rpc/util.cpp +++ b/src/rpc/util.cpp @@ -1174,3 +1174,9 @@ UniValue GetServicesNames(ServiceFlags services) return servicesNames; } + +void PushWarnings(const UniValue& warnings, UniValue& obj) +{ + if (warnings.empty()) return; + obj.pushKV("warnings", warnings); +} diff --git a/src/rpc/util.h b/src/rpc/util.h index e3783c8f76..15c73068b9 100644 --- a/src/rpc/util.h +++ b/src/rpc/util.h @@ -381,4 +381,12 @@ private: const RPCExamples m_examples; }; +/** + * Push warning messages to an RPC "warnings" field as a JSON array of strings. + * + * @param[in] warnings Warning messages to push. + * @param[out] obj UniValue object to push the warnings array object to. + */ +void PushWarnings(const UniValue& warnings, UniValue& obj); + #endif // BITCOIN_RPC_UTIL_H |