aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/util.cpp
diff options
context:
space:
mode:
authorLuke Dashjr <luke-jr+git@utopios.org>2020-02-17 01:53:13 +0000
committerLuke Dashjr <luke-jr+git@utopios.org>2020-02-21 19:10:04 +0000
commitc31bc5bcfddf440e9a1713f7ba2ca2bf9cfa8e2e (patch)
tree7d04a6ac6765a3591963d9420d68d2c64620cbd3 /src/rpc/util.cpp
parentcea91a1e40e12029140ebfba969ce3ef2965029c (diff)
downloadbitcoin-c31bc5bcfddf440e9a1713f7ba2ca2bf9cfa8e2e.tar.xz
Consolidate service flag bit-to-name conversion to a shared serviceFlagToStr function
Side effect: this results in the RPC showing unknown service bits as "UNKNOWN[n]" like the GUI. Note that there is no common mask-to-vector<string> function because both GUI and RPC would need to iterate through it to convert to their desired target formats.
Diffstat (limited to 'src/rpc/util.cpp')
-rw-r--r--src/rpc/util.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp
index 78586c22f9..c0bc5c1f3f 100644
--- a/src/rpc/util.cpp
+++ b/src/rpc/util.cpp
@@ -736,18 +736,15 @@ std::vector<CScript> EvalDescriptorStringOrObject(const UniValue& scanobject, Fl
UniValue GetServicesNames(ServiceFlags services)
{
+ const uint64_t services_n = services;
UniValue servicesNames(UniValue::VARR);
- if (services & NODE_NETWORK)
- servicesNames.push_back("NETWORK");
- if (services & NODE_GETUTXO)
- servicesNames.push_back("GETUTXO");
- if (services & NODE_BLOOM)
- servicesNames.push_back("BLOOM");
- if (services & NODE_WITNESS)
- servicesNames.push_back("WITNESS");
- if (services & NODE_NETWORK_LIMITED)
- servicesNames.push_back("NETWORK_LIMITED");
+ for (int i = 0; i < 64; ++i) {
+ const uint64_t mask = 1ull << i;
+ if (services_n & mask) {
+ servicesNames.push_back(serviceFlagToStr(mask, i));
+ }
+ }
return servicesNames;
}