PPCoin: Add RPC command 'checkwallet'
[novacoin.git] / src / bitcoinrpc.cpp
index 2f76057..e9b9dfb 100644 (file)
@@ -1885,6 +1885,27 @@ Value reservebalance(const Array& params, bool fHelp)
 }
 
 
+// ppcoin: check wallet integrity
+Value checkwallet(const Array& params, bool fHelp)
+{
+    if (fHelp || params.size() > 0)
+        throw runtime_error(
+            "checkwallet\n"
+            "Check wallet for integrity.\n");
+
+    int nMismatchSpent;
+    int64 nBalanceInQuestion;
+    if (!pwalletMain->CheckSpentCoins(nMismatchSpent, nBalanceInQuestion))
+    {
+        Object result;
+        result.push_back(Pair("mismatched spent coins", nMismatchSpent));
+        result.push_back(Pair("amount in question", ValueFromAmount(nBalanceInQuestion)));
+        return result;
+    }
+    return Value::null;
+}
+
+
 
 
 
@@ -1938,6 +1959,7 @@ pair<string, rpcfn_type> pCallTable[] =
     make_pair("resetcheckpoint",        &resetcheckpoint),
     make_pair("getbranchpoint",         &getbranchpoint),
     make_pair("reservebalance",         &reservebalance),
+    make_pair("checkwallet",            &checkwallet),
 };
 map<string, rpcfn_type> mapCallTable(pCallTable, pCallTable + sizeof(pCallTable)/sizeof(pCallTable[0]));