MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / Enumerate

Method Enumerate

src/external_signer.cpp:27–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25}
26
27bool ExternalSigner::Enumerate(const std::string& command, std::vector<ExternalSigner>& signers, const std::string& chain)
28{
29 // Call <command> enumerate
30 std::vector<std::string> cmd_args = Cat(subprocess::util::split(command), {"enumerate"});
31
32 const UniValue result = RunCommandParseJSON(cmd_args, "");
33 if (!result.isArray()) {
34 throw std::runtime_error(strprintf("'%s' received invalid response, expected array of signers", command));
35 }
36 for (const UniValue& signer : result.getValues()) {
37 // Check for error
38 const UniValue& error = signer.find_value("error");
39 if (!error.isNull()) {
40 if (!error.isStr()) {
41 throw std::runtime_error(strprintf("'%s' error", command));
42 }
43 throw std::runtime_error(strprintf("'%s' error: %s", command, error.getValStr()));
44 }
45 // Check if fingerprint is present
46 const UniValue& fingerprint = signer.find_value("fingerprint");
47 if (fingerprint.isNull()) {
48 throw std::runtime_error(strprintf("'%s' received invalid response, missing signer fingerprint", command));
49 }
50 const std::string& fingerprintStr{fingerprint.get_str()};
51 // Skip duplicate signer
52 bool duplicate = false;
53 for (const ExternalSigner& signer : signers) {
54 if (signer.m_fingerprint.compare(fingerprintStr) == 0) duplicate = true;
55 }
56 if (duplicate) continue;
57 std::string name;
58 const UniValue& model_field = signer.find_value("model");
59 if (model_field.isStr() && model_field.getValStr() != "") {
60 name += model_field.getValStr();
61 }
62 signers.emplace_back(subprocess::util::split(command), chain, fingerprintStr, name);
63 }
64 return true;
65}
66
67UniValue ExternalSigner::DisplayAddress(const std::string& descriptor) const
68{

Callers

nothing calls this directly

Calls 8

CatFunction · 0.85
splitFunction · 0.85
RunCommandParseJSONFunction · 0.85
isArrayMethod · 0.80
isNullMethod · 0.80
isStrMethod · 0.80
compareMethod · 0.80
emplace_backMethod · 0.45

Tested by

no test coverage detected