aboutsummaryrefslogtreecommitdiff
path: root/src/rpc
diff options
context:
space:
mode:
Diffstat (limited to 'src/rpc')
-rw-r--r--src/rpc/blockchain.cpp4
-rw-r--r--src/rpc/mining.cpp3
-rw-r--r--src/rpc/net.cpp3
-rw-r--r--src/rpc/util.cpp19
-rw-r--r--src/rpc/util.h2
5 files changed, 9 insertions, 22 deletions
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
index 46b0ae161f..e785678614 100644
--- a/src/rpc/blockchain.cpp
+++ b/src/rpc/blockchain.cpp
@@ -29,6 +29,7 @@
#include <node/context.h>
#include <node/transaction.h>
#include <node/utxo_snapshot.h>
+#include <node/warnings.h>
#include <primitives/transaction.h>
#include <rpc/server.h>
#include <rpc/server_util.h>
@@ -1308,7 +1309,8 @@ RPCHelpMan getblockchaininfo()
}
}
- obj.pushKV("warnings", GetNodeWarnings(IsDeprecatedRPCEnabled("warnings")));
+ NodeContext& node = EnsureAnyNodeContext(request.context);
+ obj.pushKV("warnings", node::GetWarningsForRpc(*CHECK_NONFATAL(node.warnings), IsDeprecatedRPCEnabled("warnings")));
return obj;
},
};
diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp
index 6412fb35ec..0f6853ef37 100644
--- a/src/rpc/mining.cpp
+++ b/src/rpc/mining.cpp
@@ -20,6 +20,7 @@
#include <net.h>
#include <node/context.h>
#include <node/miner.h>
+#include <node/warnings.h>
#include <pow.h>
#include <rpc/blockchain.h>
#include <rpc/mining.h>
@@ -454,7 +455,7 @@ static RPCHelpMan getmininginfo()
obj.pushKV("networkhashps", getnetworkhashps().HandleRequest(request));
obj.pushKV("pooledtx", (uint64_t)mempool.size());
obj.pushKV("chain", chainman.GetParams().GetChainTypeString());
- obj.pushKV("warnings", GetNodeWarnings(IsDeprecatedRPCEnabled("warnings")));
+ obj.pushKV("warnings", node::GetWarningsForRpc(*CHECK_NONFATAL(node.warnings), IsDeprecatedRPCEnabled("warnings")));
return obj;
},
};
diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp
index 1cc55f891a..1119a3e668 100644
--- a/src/rpc/net.cpp
+++ b/src/rpc/net.cpp
@@ -16,6 +16,7 @@
#include <netbase.h>
#include <node/context.h>
#include <node/protocol_version.h>
+#include <node/warnings.h>
#include <policy/settings.h>
#include <protocol.h>
#include <rpc/blockchain.h>
@@ -715,7 +716,7 @@ static RPCHelpMan getnetworkinfo()
}
}
obj.pushKV("localaddresses", std::move(localAddresses));
- obj.pushKV("warnings", GetNodeWarnings(IsDeprecatedRPCEnabled("warnings")));
+ obj.pushKV("warnings", node::GetWarningsForRpc(*CHECK_NONFATAL(node.warnings), IsDeprecatedRPCEnabled("warnings")));
return obj;
},
};
diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp
index bb1aef63f4..4df4466c49 100644
--- a/src/rpc/util.cpp
+++ b/src/rpc/util.cpp
@@ -5,17 +5,17 @@
#include <config/bitcoin-config.h> // IWYU pragma: keep
#include <clientversion.h>
-#include <core_io.h>
#include <common/args.h>
#include <common/messages.h>
#include <common/types.h>
#include <consensus/amount.h>
-#include <script/interpreter.h>
+#include <core_io.h>
#include <key_io.h>
#include <node/types.h>
#include <outputtype.h>
#include <rpc/util.h>
#include <script/descriptor.h>
+#include <script/interpreter.h>
#include <script/signingprovider.h>
#include <script/solver.h>
#include <tinyformat.h>
@@ -25,7 +25,6 @@
#include <util/strencodings.h>
#include <util/string.h>
#include <util/translation.h>
-#include <warnings.h>
#include <algorithm>
#include <iterator>
@@ -1382,17 +1381,3 @@ void PushWarnings(const std::vector<bilingual_str>& warnings, UniValue& obj)
if (warnings.empty()) return;
obj.pushKV("warnings", BilingualStringsToUniValue(warnings));
}
-
-UniValue GetNodeWarnings(bool use_deprecated)
-{
- if (use_deprecated) {
- const auto all_warnings{GetWarnings()};
- return all_warnings.empty() ? "" : all_warnings.back().original;
- }
-
- UniValue warnings{UniValue::VARR};
- for (auto&& warning : GetWarnings()) {
- warnings.push_back(std::move(warning.original));
- }
- return warnings;
-}
diff --git a/src/rpc/util.h b/src/rpc/util.h
index ca6ca6007b..23024376e0 100644
--- a/src/rpc/util.h
+++ b/src/rpc/util.h
@@ -503,6 +503,4 @@ private:
void PushWarnings(const UniValue& warnings, UniValue& obj);
void PushWarnings(const std::vector<bilingual_str>& warnings, UniValue& obj);
-UniValue GetNodeWarnings(bool use_deprecated);
-
#endif // BITCOIN_RPC_UTIL_H