Use MoneyRange(txout.nValue) to get rid of excessive checking.
[novacoin.git] / src / key.cpp
index 5319680..072199b 100644 (file)
@@ -370,7 +370,7 @@ CPubKey CKey::GetPubKey() const
 bool CKey::Sign(uint256 hash, std::vector<unsigned char>& vchSig)
 {
     vchSig.clear();
-    auto sig = ECDSA_do_sign((unsigned char*)&hash, sizeof(hash), pkey);
+    auto sig = ECDSA_do_sign(hash.begin(), hash.size(), pkey);
     if (sig==NULL)
         return false;
     auto group = EC_KEY_get0_group(pkey);
@@ -708,7 +708,9 @@ void CMalleablePubKey::GetVariant(CPubKey &R, CPubKey &vchPubKeyVariant)
     bnHash.setuint160(Hash160(vchLr));
 
     CPoint pointH;
-    pointH.setPubKey(pubKeyH);
+    if (!pointH.setPubKey(pubKeyH)) {
+        throw key_error("CMalleablePubKey::GetVariant() : Unable to decode H value");
+    }
 
     CPoint P;
     // Calculate P = Hash(L*r)*G + H
@@ -719,7 +721,9 @@ void CMalleablePubKey::GetVariant(CPubKey &R, CPubKey &vchPubKeyVariant)
     }
 
     std::vector<unsigned char> vchResult;
-    P.getBytes(vchResult);
+    if (!P.getBytes(vchResult)) {
+        throw key_error("CMalleablePubKey::GetVariant() : Unable to convert P value");
+    }
 
     vchPubKeyVariant = CPubKey(vchResult);
 }