aboutsummaryrefslogtreecommitdiff
path: root/src/rpc
diff options
context:
space:
mode:
authorJon Atack <jon@atack.com>2023-03-19 10:16:09 -0700
committerJon Atack <jon@atack.com>2023-04-10 10:41:35 -0700
commit079d8cdda8eeebe199fb6592fca2630c37662731 (patch)
treecd7f4d3bde3449e4d1919e3035b937e622141d14 /src/rpc
parentf73782a9032a462a71569e9424db9bf9eeababf3 (diff)
rpc: extract wallet "warnings" fields to a util helper
Diffstat (limited to 'src/rpc')
-rw-r--r--src/rpc/output_script.cpp2
-rw-r--r--src/rpc/util.cpp6
-rw-r--r--src/rpc/util.h8
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