MCPcopy Create free account
hub / github.com/ElementsProject/elements / Enumerate

Method Enumerate

src/external_signer.cpp:24–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 7

RunCommandParseJSONFunction · 0.85
isArrayMethod · 0.80
isStrMethod · 0.80
compareMethod · 0.80
ExternalSignerClass · 0.70
isNullMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected