mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-02-04 06:12:07 +01:00
rpc: return warnings as an array instead of just a single one
The RPC documentation for `getblockchaininfo`, `getmininginfo` and `getnetworkinfo` states that "warnings" returns "any network and blockchain warnings". In practice, only a single warning is returned. Fix that by returning all warnings as an array. As a side benefit, cleans up the GetWarnings() logic.
This commit is contained in:
@@ -47,7 +47,6 @@
|
||||
#include <validation.h>
|
||||
#include <validationinterface.h>
|
||||
#include <versionbits.h>
|
||||
#include <warnings.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -1260,7 +1259,14 @@ RPCHelpMan getblockchaininfo()
|
||||
{RPCResult::Type::NUM, "pruneheight", /*optional=*/true, "height of the last block pruned, plus one (only present if pruning is enabled)"},
|
||||
{RPCResult::Type::BOOL, "automatic_pruning", /*optional=*/true, "whether automatic pruning is enabled (only present if pruning is enabled)"},
|
||||
{RPCResult::Type::NUM, "prune_target_size", /*optional=*/true, "the target size used by pruning (only present if automatic pruning is enabled)"},
|
||||
{RPCResult::Type::STR, "warnings", "any network and blockchain warnings"},
|
||||
(IsDeprecatedRPCEnabled("warnings") ?
|
||||
RPCResult{RPCResult::Type::STR, "warnings", "any network and blockchain warnings (DEPRECATED)"} :
|
||||
RPCResult{RPCResult::Type::ARR, "warnings", "any network and blockchain warnings (run with `-deprecatedrpc=warnings` to return the latest warning as a single string)",
|
||||
{
|
||||
{RPCResult::Type::STR, "", "warning"},
|
||||
}
|
||||
}
|
||||
),
|
||||
}},
|
||||
RPCExamples{
|
||||
HelpExampleCli("getblockchaininfo", "")
|
||||
@@ -1298,7 +1304,7 @@ RPCHelpMan getblockchaininfo()
|
||||
}
|
||||
}
|
||||
|
||||
obj.pushKV("warnings", GetWarnings(false).original);
|
||||
obj.pushKV("warnings", GetNodeWarnings(IsDeprecatedRPCEnabled("warnings")));
|
||||
return obj;
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user