Merge pull request #363 from svost/c++11
[novacoin.git] / src / key.cpp
index e1a6014..3c4762e 100644 (file)
@@ -165,6 +165,10 @@ const unsigned char vchMaxModHalfOrder[32] = {
 
 const unsigned char *vchZero = NULL;
 
+CScriptID::CScriptID(const CScript& in) : uint160(Hash160(in.begin(), in.end()))
+{
+}
+
 void CKey::SetCompressedPubKey(bool fCompressed)
 {
     EC_KEY_set_conv_form(pkey, fCompressed ? POINT_CONVERSION_COMPRESSED : POINT_CONVERSION_UNCOMPRESSED);
@@ -708,7 +712,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 +725,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);
 }