LCOV - code coverage report
Current view: top level - src - httprpc.cpp (source / functions) Coverage Total Hit
Test: total_coverage.info Lines: 88.6 % 202 179
Test Date: 2024-08-28 05:13:07 Functions: 100.0 % 11 11
Branches: 50.8 % 378 192

             Branch data     Line data    Source code
       1                 :             : // Copyright (c) 2015-2022 The Bitcoin Core developers
       2                 :             : // Distributed under the MIT software license, see the accompanying
       3                 :             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       4                 :             : 
       5                 :             : #include <httprpc.h>
       6                 :             : 
       7                 :             : #include <common/args.h>
       8                 :             : #include <crypto/hmac_sha256.h>
       9                 :             : #include <httpserver.h>
      10                 :             : #include <logging.h>
      11                 :             : #include <netaddress.h>
      12                 :             : #include <rpc/protocol.h>
      13                 :             : #include <rpc/server.h>
      14                 :             : #include <util/fs.h>
      15                 :             : #include <util/fs_helpers.h>
      16                 :             : #include <util/strencodings.h>
      17                 :             : #include <util/string.h>
      18                 :             : #include <walletinitinterface.h>
      19                 :             : 
      20                 :             : #include <algorithm>
      21                 :             : #include <iterator>
      22                 :             : #include <map>
      23                 :             : #include <memory>
      24                 :             : #include <optional>
      25                 :             : #include <set>
      26                 :             : #include <string>
      27                 :             : #include <vector>
      28                 :             : 
      29                 :             : using util::SplitString;
      30                 :             : using util::TrimStringView;
      31                 :             : 
      32                 :             : /** WWW-Authenticate to present with 401 Unauthorized response */
      33                 :             : static const char* WWW_AUTH_HEADER_DATA = "Basic realm=\"jsonrpc\"";
      34                 :             : 
      35                 :             : /** Simple one-shot callback timer to be used by the RPC mechanism to e.g.
      36                 :             :  * re-lock the wallet.
      37                 :             :  */
      38                 :             : class HTTPRPCTimer : public RPCTimerBase
      39                 :             : {
      40                 :             : public:
      41                 :          80 :     HTTPRPCTimer(struct event_base* eventBase, std::function<void()>& func, int64_t millis) :
      42         [ +  - ]:          80 :         ev(eventBase, false, func)
      43                 :             :     {
      44                 :          80 :         struct timeval tv;
      45                 :          80 :         tv.tv_sec = millis/1000;
      46                 :          80 :         tv.tv_usec = (millis%1000)*1000;
      47         [ +  - ]:          80 :         ev.trigger(&tv);
      48                 :          80 :     }
      49                 :             : private:
      50                 :             :     HTTPEvent ev;
      51                 :             : };
      52                 :             : 
      53                 :             : class HTTPRPCTimerInterface : public RPCTimerInterface
      54                 :             : {
      55                 :             : public:
      56                 :        1169 :     explicit HTTPRPCTimerInterface(struct event_base* _base) : base(_base)
      57                 :             :     {
      58                 :             :     }
      59                 :          80 :     const char* Name() override
      60                 :             :     {
      61                 :          80 :         return "HTTP";
      62                 :             :     }
      63                 :          80 :     RPCTimerBase* NewTimer(std::function<void()>& func, int64_t millis) override
      64                 :             :     {
      65         [ +  - ]:          80 :         return new HTTPRPCTimer(base, func, millis);
      66                 :             :     }
      67                 :             : private:
      68                 :             :     struct event_base* base;
      69                 :             : };
      70                 :             : 
      71                 :             : 
      72                 :             : /* Pre-base64-encoded authentication token */
      73                 :             : static std::string strRPCUserColonPass;
      74                 :             : /* Stored RPC timer interface (for unregistration) */
      75                 :             : static std::unique_ptr<HTTPRPCTimerInterface> httpRPCTimerInterface;
      76                 :             : /* List of -rpcauth values */
      77                 :             : static std::vector<std::vector<std::string>> g_rpcauth;
      78                 :             : /* RPC Auth Whitelist */
      79                 :             : static std::map<std::string, std::set<std::string>> g_rpc_whitelist;
      80                 :             : static bool g_rpc_whitelist_default = false;
      81                 :             : 
      82                 :           6 : static void JSONErrorReply(HTTPRequest* req, UniValue objError, const JSONRPCRequest& jreq)
      83                 :             : {
      84                 :             :     // Sending HTTP errors is a legacy JSON-RPC behavior.
      85                 :           6 :     Assume(jreq.m_json_version != JSONRPCVersion::V2);
      86                 :             : 
      87                 :             :     // Send error reply from json-rpc error object
      88                 :           6 :     int nStatus = HTTP_INTERNAL_SERVER_ERROR;
      89                 :           6 :     int code = objError.find_value("code").getInt<int>();
      90                 :             : 
      91         [ +  + ]:           6 :     if (code == RPC_INVALID_REQUEST)
      92                 :             :         nStatus = HTTP_BAD_REQUEST;
      93         [ +  + ]:           4 :     else if (code == RPC_METHOD_NOT_FOUND)
      94                 :           1 :         nStatus = HTTP_NOT_FOUND;
      95                 :             : 
      96   [ +  -  +  -  :          12 :     std::string strReply = JSONRPCReplyObj(NullUniValue, std::move(objError), jreq.id, jreq.m_json_version).write() + "\n";
                   +  - ]
      97                 :             : 
      98   [ +  -  +  -  :          12 :     req->WriteHeader("Content-Type", "application/json");
                   +  - ]
      99         [ +  - ]:           6 :     req->WriteReply(nStatus, strReply);
     100                 :           6 : }
     101                 :             : 
     102                 :             : //This function checks username and password against -rpcauth
     103                 :             : //entries from config file.
     104                 :          32 : static bool multiUserAuthorized(std::string strUserPass)
     105                 :             : {
     106         [ +  - ]:          32 :     if (strUserPass.find(':') == std::string::npos) {
     107                 :             :         return false;
     108                 :             :     }
     109                 :          32 :     std::string strUser = strUserPass.substr(0, strUserPass.find(':'));
     110         [ +  - ]:          32 :     std::string strPass = strUserPass.substr(strUserPass.find(':') + 1);
     111                 :             : 
     112         [ +  + ]:          92 :     for (const auto& vFields : g_rpcauth) {
     113         [ +  - ]:          73 :         std::string strName = vFields[0];
     114         [ +  + ]:          73 :         if (!TimingResistantEqual(strName, strUser)) {
     115                 :          57 :             continue;
     116                 :             :         }
     117                 :             : 
     118         [ +  - ]:          16 :         std::string strSalt = vFields[1];
     119         [ +  - ]:          16 :         std::string strHash = vFields[2];
     120                 :             : 
     121                 :          16 :         static const unsigned int KEY_SIZE = 32;
     122                 :          16 :         unsigned char out[KEY_SIZE];
     123                 :             : 
     124   [ +  -  +  -  :          16 :         CHMAC_SHA256(reinterpret_cast<const unsigned char*>(strSalt.data()), strSalt.size()).Write(reinterpret_cast<const unsigned char*>(strPass.data()), strPass.size()).Finalize(out);
                   +  - ]
     125         [ +  - ]:          16 :         std::vector<unsigned char> hexvec(out, out+KEY_SIZE);
     126         [ +  - ]:          16 :         std::string strHashFromPass = HexStr(hexvec);
     127                 :             : 
     128         [ +  + ]:          16 :         if (TimingResistantEqual(strHashFromPass, strHash)) {
     129                 :          13 :             return true;
     130                 :             :         }
     131                 :          73 :     }
     132                 :             :     return false;
     133                 :          32 : }
     134                 :             : 
     135                 :      187770 : static bool RPCAuthorized(const std::string& strAuth, std::string& strAuthUsernameOut)
     136                 :             : {
     137         [ +  - ]:      187770 :     if (strRPCUserColonPass.empty()) // Belt-and-suspenders measure if InitRPCAuthentication was not called
     138                 :             :         return false;
     139         [ +  + ]:      187770 :     if (strAuth.substr(0, 6) != "Basic ")
     140                 :             :         return false;
     141                 :      187768 :     std::string_view strUserPass64 = TrimStringView(std::string_view{strAuth}.substr(6));
     142                 :      187768 :     auto userpass_data = DecodeBase64(strUserPass64);
     143         [ +  - ]:      187768 :     std::string strUserPass;
     144         [ +  - ]:      187768 :     if (!userpass_data) return false;
     145         [ +  - ]:      187768 :     strUserPass.assign(userpass_data->begin(), userpass_data->end());
     146                 :             : 
     147         [ +  - ]:      187768 :     if (strUserPass.find(':') != std::string::npos)
     148         [ +  - ]:      187768 :         strAuthUsernameOut = strUserPass.substr(0, strUserPass.find(':'));
     149                 :             : 
     150                 :             :     //Check if authorized under single-user field
     151         [ +  + ]:      187768 :     if (TimingResistantEqual(strUserPass, strRPCUserColonPass)) {
     152                 :             :         return true;
     153                 :             :     }
     154   [ +  -  +  - ]:          32 :     return multiUserAuthorized(strUserPass);
     155                 :      187768 : }
     156                 :             : 
     157                 :      187770 : static bool HTTPReq_JSONRPC(const std::any& context, HTTPRequest* req)
     158                 :             : {
     159                 :             :     // JSONRPC handles only POST
     160         [ -  + ]:      187770 :     if (req->GetRequestMethod() != HTTPRequest::POST) {
     161                 :           0 :         req->WriteReply(HTTP_BAD_METHOD, "JSONRPC server handles only POST requests");
     162                 :           0 :         return false;
     163                 :             :     }
     164                 :             :     // Check authorization
     165         [ +  - ]:      187770 :     std::pair<bool, std::string> authHeader = req->GetHeader("authorization");
     166         [ -  + ]:      187770 :     if (!authHeader.first) {
     167   [ #  #  #  #  :           0 :         req->WriteHeader("WWW-Authenticate", WWW_AUTH_HEADER_DATA);
                   #  # ]
     168         [ #  # ]:           0 :         req->WriteReply(HTTP_UNAUTHORIZED);
     169                 :             :         return false;
     170                 :             :     }
     171                 :             : 
     172                 :      187770 :     JSONRPCRequest jreq;
     173         [ +  - ]:      187770 :     jreq.context = context;
     174   [ +  -  +  - ]:      187770 :     jreq.peerAddr = req->GetPeer().ToStringAddrPort();
     175   [ +  -  +  + ]:      187770 :     if (!RPCAuthorized(authHeader.second, jreq.authUser)) {
     176         [ +  - ]:          21 :         LogPrintf("ThreadRPCServer incorrect password attempt from %s\n", jreq.peerAddr);
     177                 :             : 
     178                 :             :         /* Deter brute-forcing
     179                 :             :            If this results in a DoS the user really
     180                 :             :            shouldn't have their RPC port exposed. */
     181         [ +  - ]:          21 :         UninterruptibleSleep(std::chrono::milliseconds{250});
     182                 :             : 
     183   [ +  -  +  -  :          42 :         req->WriteHeader("WWW-Authenticate", WWW_AUTH_HEADER_DATA);
                   +  - ]
     184         [ +  - ]:          21 :         req->WriteReply(HTTP_UNAUTHORIZED);
     185                 :             :         return false;
     186                 :             :     }
     187                 :             : 
     188                 :      187749 :     try {
     189                 :             :         // Parse request
     190         [ +  - ]:      187749 :         UniValue valRequest;
     191   [ +  -  +  -  :      187749 :         if (!valRequest.read(req->ReadBody()))
                   +  + ]
     192   [ +  -  +  - ]:           4 :             throw JSONRPCError(RPC_PARSE_ERROR, "Parse error");
     193                 :             : 
     194                 :             :         // Set the URI
     195         [ +  - ]:      187747 :         jreq.URI = req->GetURI();
     196                 :             : 
     197                 :      187747 :         UniValue reply;
     198                 :      187747 :         bool user_has_whitelist = g_rpc_whitelist.count(jreq.authUser);
     199   [ +  +  -  + ]:      187747 :         if (!user_has_whitelist && g_rpc_whitelist_default) {
     200         [ #  # ]:           0 :             LogPrintf("RPC User %s not allowed to call any methods\n", jreq.authUser);
     201         [ #  # ]:           0 :             req->WriteReply(HTTP_FORBIDDEN);
     202                 :             :             return false;
     203                 :             : 
     204                 :             :         // singleton request
     205         [ +  + ]:      187747 :         } else if (valRequest.isObject()) {
     206         [ +  + ]:      187566 :             jreq.parse(valRequest);
     207   [ +  +  +  -  :      187564 :             if (user_has_whitelist && !g_rpc_whitelist[jreq.authUser].count(jreq.strMethod)) {
                   +  + ]
     208         [ +  - ]:           5 :                 LogPrintf("RPC User %s not allowed to call method %s\n", jreq.authUser, jreq.strMethod);
     209         [ +  - ]:           5 :                 req->WriteReply(HTTP_FORBIDDEN);
     210                 :             :                 return false;
     211                 :             :             }
     212                 :             : 
     213                 :             :             // Legacy 1.0/1.1 behavior is for failed requests to throw
     214                 :             :             // exceptions which return HTTP errors and RPC errors to the client.
     215                 :             :             // 2.0 behavior is to catch exceptions and return HTTP success with
     216                 :             :             // RPC errors, as long as there is not an actual HTTP server error.
     217                 :      187559 :             const bool catch_errors{jreq.m_json_version == JSONRPCVersion::V2};
     218         [ +  + ]:      187559 :             reply = JSONRPCExec(jreq, catch_errors);
     219                 :             : 
     220         [ +  + ]:      187557 :             if (jreq.IsNotification()) {
     221                 :             :                 // Even though we do execute notifications, we do not respond to them
     222         [ +  - ]:           2 :                 req->WriteReply(HTTP_NO_CONTENT);
     223                 :             :                 return true;
     224                 :             :             }
     225                 :             : 
     226                 :             :         // array of requests
     227         [ +  - ]:         181 :         } else if (valRequest.isArray()) {
     228                 :             :             // Check authorization for each request's method
     229         [ -  + ]:         181 :             if (user_has_whitelist) {
     230         [ #  # ]:           0 :                 for (unsigned int reqIdx = 0; reqIdx < valRequest.size(); reqIdx++) {
     231   [ #  #  #  # ]:           0 :                     if (!valRequest[reqIdx].isObject()) {
     232   [ #  #  #  # ]:           0 :                         throw JSONRPCError(RPC_INVALID_REQUEST, "Invalid Request object");
     233                 :             :                     } else {
     234   [ #  #  #  # ]:           0 :                         const UniValue& request = valRequest[reqIdx].get_obj();
     235                 :             :                         // Parse method
     236   [ #  #  #  #  :           0 :                         std::string strMethod = request.find_value("method").get_str();
                   #  # ]
     237   [ #  #  #  # ]:           0 :                         if (!g_rpc_whitelist[jreq.authUser].count(strMethod)) {
     238         [ #  # ]:           0 :                             LogPrintf("RPC User %s not allowed to call method %s\n", jreq.authUser, strMethod);
     239         [ #  # ]:           0 :                             req->WriteReply(HTTP_FORBIDDEN);
     240                 :           0 :                             return false;
     241                 :             :                         }
     242                 :           0 :                     }
     243                 :             :                 }
     244                 :             :             }
     245                 :             : 
     246                 :             :             // Execute each request
     247                 :         181 :             reply = UniValue::VARR;
     248         [ +  + ]:       13560 :             for (size_t i{0}; i < valRequest.size(); ++i) {
     249                 :             :                 // Batches never throw HTTP errors, they are always just included
     250                 :             :                 // in "HTTP OK" responses. Notifications never get any response.
     251         [ +  - ]:       13379 :                 UniValue response;
     252                 :       13379 :                 try {
     253   [ +  -  +  + ]:       13379 :                     jreq.parse(valRequest[i]);
     254         [ +  - ]:       13367 :                     response = JSONRPCExec(jreq, /*catch_errors=*/true);
     255      [ -  +  - ]:          12 :                 } catch (UniValue& e) {
     256   [ +  -  +  -  :          12 :                     response = JSONRPCReplyObj(NullUniValue, std::move(e), jreq.id, jreq.m_json_version);
                   +  - ]
     257                 :          12 :                 } catch (const std::exception& e) {
     258   [ -  -  -  -  :           0 :                     response = JSONRPCReplyObj(NullUniValue, JSONRPCError(RPC_PARSE_ERROR, e.what()), jreq.id, jreq.m_json_version);
          -  -  -  -  -  
                      - ]
     259                 :           0 :                 }
     260         [ +  + ]:       13379 :                 if (!jreq.IsNotification()) {
     261         [ +  - ]:       13374 :                     reply.push_back(std::move(response));
     262                 :             :                 }
     263                 :       13379 :             }
     264                 :             :             // Return no response for an all-notification batch, but only if the
     265                 :             :             // batch request is non-empty. Technically according to the JSON-RPC
     266                 :             :             // 2.0 spec, an empty batch request should also return no response,
     267                 :             :             // However, if the batch request is empty, it means the request did
     268                 :             :             // not contain any JSON-RPC version numbers, so returning an empty
     269                 :             :             // response could break backwards compatibility with old RPC clients
     270                 :             :             // relying on previous behavior. Return an empty array instead of an
     271                 :             :             // empty response in this case to favor being backwards compatible
     272                 :             :             // over complying with the JSON-RPC 2.0 spec in this case.
     273   [ +  +  +  + ]:         181 :             if (reply.size() == 0 && valRequest.size() > 0) {
     274         [ +  - ]:           1 :                 req->WriteReply(HTTP_NO_CONTENT);
     275                 :             :                 return true;
     276                 :             :             }
     277                 :             :         }
     278                 :             :         else
     279   [ #  #  #  # ]:           0 :             throw JSONRPCError(RPC_PARSE_ERROR, "Top-level object parse error");
     280                 :             : 
     281   [ +  -  +  -  :      375470 :         req->WriteHeader("Content-Type", "application/json");
                   +  - ]
     282   [ +  -  +  - ]:      563205 :         req->WriteReply(HTTP_OK, reply.write() + "\n");
     283      [ -  +  - ]:      187759 :     } catch (UniValue& e) {
     284         [ +  - ]:           6 :         JSONErrorReply(req, std::move(e), jreq);
     285                 :           6 :         return false;
     286                 :           6 :     } catch (const std::exception& e) {
     287   [ -  -  -  -  :           0 :         JSONErrorReply(req, JSONRPCError(RPC_PARSE_ERROR, e.what()), jreq);
                   -  - ]
     288                 :           0 :         return false;
     289                 :           0 :     }
     290                 :      187735 :     return true;
     291                 :      375540 : }
     292                 :             : 
     293                 :        1175 : static bool InitRPCAuthentication()
     294                 :             : {
     295   [ +  -  +  -  :        1175 :     if (gArgs.GetArg("-rpcpassword", "") == "")
                   +  + ]
     296                 :             :     {
     297                 :        1174 :         LogInfo("Using random cookie authentication.\n");
     298                 :             : 
     299                 :        1174 :         std::optional<fs::perms> cookie_perms{std::nullopt};
     300         [ +  - ]:        1174 :         auto cookie_perms_arg{gArgs.GetArg("-rpccookieperms")};
     301         [ +  + ]:        1174 :         if (cookie_perms_arg) {
     302         [ +  - ]:           3 :             auto perm_opt = InterpretPermString(*cookie_perms_arg);
     303         [ -  + ]:           3 :             if (!perm_opt) {
     304         [ #  # ]:           0 :                 LogInfo("Invalid -rpccookieperms=%s; must be one of 'owner', 'group', or 'all'.\n", *cookie_perms_arg);
     305                 :             :                 return false;
     306                 :             :             }
     307                 :           3 :             cookie_perms = *perm_opt;
     308                 :             :         }
     309                 :             : 
     310   [ +  -  +  + ]:        1174 :         if (!GenerateAuthCookie(&strRPCUserColonPass, cookie_perms)) {
     311                 :             :             return false;
     312                 :             :         }
     313                 :        1174 :     } else {
     314                 :           1 :         LogPrintf("Config options rpcuser and rpcpassword will soon be deprecated. Locally-run instances may remove rpcuser to use cookie-based auth, or may be replaced with rpcauth. Please see share/rpcauth for rpcauth auth generation.\n");
     315   [ +  -  +  -  :           2 :         strRPCUserColonPass = gArgs.GetArg("-rpcuser", "") + ":" + gArgs.GetArg("-rpcpassword", "");
          +  -  +  -  +  
                -  +  - ]
     316                 :             :     }
     317   [ +  -  +  -  :        1174 :     if (gArgs.GetArg("-rpcauth", "") != "") {
                   +  + ]
     318                 :           8 :         LogPrintf("Using rpcauth authentication.\n");
     319   [ +  -  +  + ]:          20 :         for (const std::string& rpcauth : gArgs.GetArgs("-rpcauth")) {
     320         [ +  - ]:          17 :             std::vector<std::string> fields{SplitString(rpcauth, ':')};
     321         [ +  - ]:          17 :             const std::vector<std::string> salt_hmac{SplitString(fields.back(), '$')};
     322   [ +  +  +  + ]:          17 :             if (fields.size() == 2 && salt_hmac.size() == 2) {
     323                 :          12 :                 fields.pop_back();
     324         [ +  - ]:          12 :                 fields.insert(fields.end(), salt_hmac.begin(), salt_hmac.end());
     325         [ +  - ]:          12 :                 g_rpcauth.push_back(fields);
     326                 :             :             } else {
     327         [ +  - ]:           5 :                 LogPrintf("Invalid -rpcauth argument.\n");
     328                 :           5 :                 return false;
     329                 :             :             }
     330                 :          20 :         }
     331                 :             :     }
     332                 :             : 
     333   [ +  -  +  -  :        1169 :     g_rpc_whitelist_default = gArgs.GetBoolArg("-rpcwhitelistdefault", gArgs.IsArgSet("-rpcwhitelist"));
                   +  - ]
     334   [ +  -  +  + ]:        1177 :     for (const std::string& strRPCWhitelist : gArgs.GetArgs("-rpcwhitelist")) {
     335                 :           8 :         auto pos = strRPCWhitelist.find(':');
     336         [ +  - ]:           8 :         std::string strUser = strRPCWhitelist.substr(0, pos);
     337                 :           8 :         bool intersect = g_rpc_whitelist.count(strUser);
     338         [ +  - ]:           8 :         std::set<std::string>& whitelist = g_rpc_whitelist[strUser];
     339         [ +  + ]:           8 :         if (pos != std::string::npos) {
     340         [ +  - ]:           7 :             std::string strWhitelist = strRPCWhitelist.substr(pos + 1);
     341         [ +  - ]:           7 :             std::vector<std::string> whitelist_split = SplitString(strWhitelist, ", ");
     342         [ +  - ]:           7 :             std::set<std::string> new_whitelist{
     343         [ +  - ]:           7 :                 std::make_move_iterator(whitelist_split.begin()),
     344         [ +  - ]:           7 :                 std::make_move_iterator(whitelist_split.end())};
     345         [ +  + ]:           7 :             if (intersect) {
     346         [ +  - ]:           1 :                 std::set<std::string> tmp_whitelist;
     347         [ +  - ]:           1 :                 std::set_intersection(new_whitelist.begin(), new_whitelist.end(),
     348                 :             :                        whitelist.begin(), whitelist.end(), std::inserter(tmp_whitelist, tmp_whitelist.end()));
     349                 :           1 :                 new_whitelist = std::move(tmp_whitelist);
     350                 :           1 :             }
     351                 :           7 :             whitelist = std::move(new_whitelist);
     352                 :           7 :         }
     353                 :           8 :     }
     354                 :             : 
     355                 :        1169 :     return true;
     356                 :             : }
     357                 :             : 
     358                 :        1175 : bool StartHTTPRPC(const std::any& context)
     359                 :             : {
     360         [ +  - ]:        1175 :     LogPrint(BCLog::RPC, "Starting HTTP RPC server\n");
     361         [ +  + ]:        1175 :     if (!InitRPCAuthentication())
     362                 :             :         return false;
     363                 :             : 
     364   [ +  -  +  - ]:      578509 :     auto handle_rpc = [context](HTTPRequest* req, const std::string&) { return HTTPReq_JSONRPC(context, req); };
     365   [ +  -  +  -  :        2338 :     RegisterHTTPHandler("/", true, handle_rpc);
                   +  - ]
     366   [ +  -  +  - ]:        1169 :     if (g_wallet_init_interface.HasWalletSupport()) {
     367   [ +  -  +  -  :        2338 :         RegisterHTTPHandler("/wallet/", false, handle_rpc);
                   +  - ]
     368                 :             :     }
     369         [ +  - ]:        1169 :     struct event_base* eventBase = EventBase();
     370         [ -  + ]:        1169 :     assert(eventBase);
     371         [ +  - ]:        2338 :     httpRPCTimerInterface = std::make_unique<HTTPRPCTimerInterface>(eventBase);
     372         [ +  - ]:        1169 :     RPCSetTimerInterface(httpRPCTimerInterface.get());
     373                 :        1169 :     return true;
     374                 :        1169 : }
     375                 :             : 
     376                 :        1200 : void InterruptHTTPRPC()
     377                 :             : {
     378         [ +  + ]:        1200 :     LogPrint(BCLog::RPC, "Interrupting HTTP RPC server\n");
     379                 :        1200 : }
     380                 :             : 
     381                 :        1200 : void StopHTTPRPC()
     382                 :             : {
     383         [ +  + ]:        1200 :     LogPrint(BCLog::RPC, "Stopping HTTP RPC server\n");
     384         [ +  - ]:        1200 :     UnregisterHTTPHandler("/", true);
     385         [ +  - ]:        1200 :     if (g_wallet_init_interface.HasWalletSupport()) {
     386         [ +  - ]:        2400 :         UnregisterHTTPHandler("/wallet/", false);
     387                 :             :     }
     388         [ +  + ]:        1200 :     if (httpRPCTimerInterface) {
     389                 :        1169 :         RPCUnsetTimerInterface(httpRPCTimerInterface.get());
     390         [ +  - ]:        1169 :         httpRPCTimerInterface.reset();
     391                 :             :     }
     392                 :        1200 : }
        

Generated by: LCOV version 2.0-1