PPCoin: RPC 'makekeypair' limits loop to avoid hang
[novacoin.git] / src / bitcoinrpc.cpp
index e68f1fe..70b608a 100644 (file)
@@ -307,7 +307,7 @@ Value getinfo(const Array& params, bool fHelp)
             "Returns an object containing various state info.");
 
     Object obj;
-    obj.push_back(Pair("version",       (int)VERSION));
+    obj.push_back(Pair("version",       FormatFullVersion()));
     obj.push_back(Pair("balance",       ValueFromAmount(pwalletMain->GetBalance())));
     obj.push_back(Pair("newmint",       ValueFromAmount(pwalletMain->GetNewMint())));
     obj.push_back(Pair("stake",         ValueFromAmount(pwalletMain->GetStake())));
@@ -1923,10 +1923,15 @@ Value makekeypair(const Array& params, bool fHelp)
         strPrefix = params[0].get_str();
  
     CKey key;
+    int nCount = 0;
     do
     {
         key.MakeNewKey();
-    } while (strPrefix != HexStr(key.GetPubKey()).substr(0, strPrefix.size()));
+        nCount++;
+    } while (nCount < 10000 && strPrefix != HexStr(key.GetPubKey()).substr(0, strPrefix.size()));
+
+    if (strPrefix != HexStr(key.GetPubKey()).substr(0, strPrefix.size()))
+        return Value::null;
 
     CPrivKey vchPrivKey = key.GetPrivKey();
     Object result;