From: svost Date: Mon, 30 Jan 2017 07:36:27 +0000 (+0300) Subject: Don't return an address for invalid pubkeys X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=commitdiff_plain;h=c86dddd612a960470b8bcefa47e05c270845b86d Don't return an address for invalid pubkeys --- diff --git a/src/script.cpp b/src/script.cpp index 0185075..c4f8d3b 100644 --- a/src/script.cpp +++ b/src/script.cpp @@ -1710,7 +1710,11 @@ bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet) if (whichType == TX_PUBKEY) { - addressRet = CPubKey(vSolutions[0]).GetID(); + CPubKey pubKey(vSolutions[0]); + if (!pubKey.IsValid()) + return false; + + addressRet = pubKey.GetID(); return true; } else if (whichType == TX_PUBKEYHASH) @@ -1819,9 +1823,16 @@ bool ExtractDestinations(const CScript& scriptPubKey, txnouttype& typeRet, vecto nRequiredRet = vSolutions.front()[0]; for (unsigned int i = 1; i < vSolutions.size()-1; i++) { - CTxDestination address = CPubKey(vSolutions[i]).GetID(); + CPubKey pubKey(vSolutions[i]); + if (!pubKey.IsValid()) + continue; + + CTxDestination address = pubKey.GetID(); addressRet.push_back(address); } + + if (addressRet.empty()) + return false; } else {