Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/misc.cpp
Show First 20 Lines • Show All 306 Lines • ▼ Show 20 Lines | if (keys.size() > 16) { | ||||
"number"); | "number"); | ||||
} | } | ||||
std::vector<CPubKey> pubkeys; | std::vector<CPubKey> pubkeys; | ||||
pubkeys.resize(keys.size()); | pubkeys.resize(keys.size()); | ||||
for (size_t i = 0; i < keys.size(); i++) { | for (size_t i = 0; i < keys.size(); i++) { | ||||
const std::string &ks = keys[i].get_str(); | const std::string &ks = keys[i].get_str(); | ||||
#ifdef ENABLE_WALLET | #ifdef ENABLE_WALLET | ||||
// Case 1: Bitcoin address and we have full public key: | // Case 1: Bitcoin address and we have full public key: | ||||
CTxDestination dest = DecodeDestination(ks); | if (pwallet) { | ||||
if (pwallet && IsValidDestination(dest)) { | CTxDestination dest = DecodeDestination(ks, pwallet->chainParams); | ||||
if (IsValidDestination(dest)) { | |||||
const CKeyID *keyID = boost::get<CKeyID>(&dest); | const CKeyID *keyID = boost::get<CKeyID>(&dest); | ||||
if (!keyID) { | if (!keyID) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
strprintf("%s does not refer to a key", ks)); | strprintf("%s does not refer to a key", ks)); | ||||
} | } | ||||
CPubKey vchPubKey; | CPubKey vchPubKey; | ||||
if (!pwallet->GetPubKey(*keyID, vchPubKey)) { | if (!pwallet->GetPubKey(*keyID, vchPubKey)) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
strprintf("no full public key for address %s", ks)); | strprintf("no full public key for address %s", ks)); | ||||
} | } | ||||
if (!vchPubKey.IsFullyValid()) { | if (!vchPubKey.IsFullyValid()) { | ||||
throw std::runtime_error(" Invalid public key: " + ks); | throw std::runtime_error(" Invalid public key: " + ks); | ||||
} | } | ||||
pubkeys[i] = vchPubKey; | pubkeys[i] = vchPubKey; | ||||
continue; | continue; | ||||
} | } | ||||
} | |||||
#endif | #endif | ||||
// Case 2: hex public key | // Case 2: hex public key | ||||
if (IsHex(ks)) { | if (IsHex(ks)) { | ||||
CPubKey vchPubKey(ParseHex(ks)); | CPubKey vchPubKey(ParseHex(ks)); | ||||
if (!vchPubKey.IsFullyValid()) { | if (!vchPubKey.IsFullyValid()) { | ||||
throw std::runtime_error(" Invalid public key: " + ks); | throw std::runtime_error(" Invalid public key: " + ks); | ||||
} | } | ||||
pubkeys[i] = vchPubKey; | pubkeys[i] = vchPubKey; | ||||
▲ Show 20 Lines • Show All 311 Lines • Show Last 20 Lines |