| 25 | } |
| 26 | |
| 27 | bool 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 | |
| 67 | UniValue ExternalSigner::DisplayAddress(const std::string& descriptor) const |
| 68 | { |
nothing calls this directly
no test coverage detected