LCOV - code coverage report
Current view: top level - src/rpc - external_signer.cpp (source / functions) Hit Total Coverage
Test: fuzz_coverage.info Lines: 0 4 0.0 %
Date: 2023-09-26 12:08:55 Functions: 0 4 0.0 %

          Line data    Source code
       1             : // Copyright (c) 2018-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 <common/args.h>
       6             : #include <common/system.h>
       7             : #include <external_signer.h>
       8             : #include <rpc/protocol.h>
       9             : #include <rpc/server.h>
      10             : #include <rpc/util.h>
      11             : #include <util/strencodings.h>
      12             : 
      13             : #include <string>
      14             : #include <vector>
      15             : 
      16             : #ifdef ENABLE_EXTERNAL_SIGNER
      17           0 : 
      18           0 : static RPCHelpMan enumeratesigners()
      19             : {
      20             :     return RPCHelpMan{"enumeratesigners",
      21             :         "Returns a list of external signers from -signer.",
      22             :         {},
      23             :         RPCResult{
      24             :             RPCResult::Type::OBJ, "", "",
      25             :             {
      26             :                 {RPCResult::Type::ARR, "signers", /*optional=*/false, "",
      27           0 :                 {
      28             :                     {RPCResult::Type::OBJ, "", "",
      29             :                     {
      30             :                         {RPCResult::Type::STR_HEX, "fingerprint", "Master key fingerprint"},
      31             :                         {RPCResult::Type::STR, "name", "Device name"},
      32             :                     }},
      33             :                 },
      34             :                 }
      35             :             }
      36             :         },
      37             :         RPCExamples{
      38             :             HelpExampleCli("enumeratesigners", "")
      39             :             + HelpExampleRpc("enumeratesigners", "")
      40             :         },
      41             :         [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
      42             :         {
      43             :             const std::string command = gArgs.GetArg("-signer", "");
      44             :             if (command == "") throw JSONRPCError(RPC_MISC_ERROR, "Error: restart bitcoind with -signer=<cmd>");
      45             :             const std::string chain = gArgs.GetChainTypeString();
      46             :             UniValue signers_res = UniValue::VARR;
      47             :             try {
      48             :                 std::vector<ExternalSigner> signers;
      49             :                 ExternalSigner::Enumerate(command, signers, chain);
      50             :                 for (const ExternalSigner& signer : signers) {
      51             :                     UniValue signer_res = UniValue::VOBJ;
      52             :                     signer_res.pushKV("fingerprint", signer.m_fingerprint);
      53             :                     signer_res.pushKV("name", signer.m_name);
      54             :                     signers_res.push_back(signer_res);
      55             :                 }
      56             :             } catch (const std::exception& e) {
      57             :                 throw JSONRPCError(RPC_MISC_ERROR, e.what());
      58             :             }
      59             :             UniValue result(UniValue::VOBJ);
      60             :             result.pushKV("signers", signers_res);
      61             :             return result;
      62             :         }
      63             :     };
      64             : }
      65             : 
      66             : void RegisterSignerRPCCommands(CRPCTable& t)
      67             : {
      68             :     static const CRPCCommand commands[]{
      69             :         {"signer", &enumeratesigners},
      70             :     };
      71             :     for (const auto& c : commands) {
      72             :         t.appendCommand(c.name, &c);
      73             :     }
      74           0 : }
      75             : 
      76             : #endif // ENABLE_EXTERNAL_SIGNER

Generated by: LCOV version 1.14