Stake Reward Fix

Stake Reward Fix

--- src/main.cpp
+++ src/main.cpp
@@ -1411,10 +1411,10 @@
                      * control when a manditory wallet update is required. */
                     if (nTime >= RESET_PRIMERATES && nTime < END_PRIME_PHASE_ONE) {
                         if (nStakeReward > GetProofOfStakeReward(nCoinAge, nTime, 100) - GetMinFee() + MIN_TX_FEE)
-                            return DoS(100, error("ConnectInputs() : %s stake reward exceeded", GetHash().ToString().substr(0,10).c_str()));
+                            return DoS(100, error("ConnectInputs() : %s stake reward exceeded - Inside terms", GetHash().ToString().substr(0,10).c_str()));
                     } else {
                         if (nStakeReward > GetProofOfStakeReward(nCoinAge, nTime, primeNodeRate) - GetMinFee() + MIN_TX_FEE)
-                            return DoS(100, error("ConnectInputs() : %s stake reward exceeded", GetHash().ToString().substr(0,10).c_str()));
+                            return DoS(100, error("ConnectInputs() : %s stake reward exceeded goto else,Stake Reward = %lld , an returned from fnc %lld", GetHash().ToString().substr(0,10).c_str(),nStakeReward,GetProofOfStakeReward(nCoinAge, nTime, primeNodeRate)));
                     }
                 }
             }
@@ -1424,7 +1424,7 @@
                     return DoS(100, error("ConnectInputs() : credit doesn't meet requirement for orion controller = %lld while you only have %lld", MINIMUM_FOR_ORION, GetValueOut()));
                 }
                 if(nStakeReward > GetProofOfStakeReward(nCoinAge, nTime, 0) - GetMinFee() + MIN_TX_FEE){
-                    return DoS(100, error("ConnectInputs() : %s stake reward exceeded", GetHash().ToString().substr(0,10).c_str()));
+                    return DoS(100, error("ConnectInputs() : %s stake reward exceeded - OK Values are,Stake Reward = %lld , an returned from fnc %lld", GetHash().ToString().substr(0,10).c_str(),nStakeReward,GetProofOfStakeReward(nCoinAge, nTime, primeNodeRate)));
                 }
             }
         }


Catch LevelDB errors during flush

Catch LevelDB errors during flush

--- src/main.cpp
+++ src/main.cpp
@@ -1807,6 +1807,7 @@
 bool static FlushStateToDisk(CValidationState &state, FlushStateMode mode) {
     LOCK(cs_main);
     static int64_t nLastWrite = 0;
+    try {
     if ((mode == FLUSH_STATE_ALWAYS) ||
         ((mode == FLUSH_STATE_PERIODIC || mode == FLUSH_STATE_IF_NEEDED) && pcoinsTip->GetCacheSize() > nCoinCacheSize) ||
         (mode == FLUSH_STATE_PERIODIC && GetTimeMicros() > nLastWrite + DATABASE_WRITE_INTERVAL * 1000000)) {
@@ -1845,6 +1846,9 @@
             g_signals.SetBestChain(chainActive.GetLocator());
         }
         nLastWrite = GetTimeMicros();
+    }
+    } catch (const std::runtime_error& e) {
+        return state.Abort(std::string("System error while flushing: ") + e.what());
     }
     return true;
 }


added translation file paths for windows in main.cpp

--- src/main.cpp
+++ src/main.cpp
@@ -46,8 +46,12 @@

      //NobleNote translations
      QTranslator translator;
+    #ifdef Q_OS_WIN32
+     translator.load(":noblenote_" + QLocale::system().name());
+    #else
      QString tmp = "/usr/share/noblenote/translations/noblenote_";
      translator.load(tmp + QLocale::system().name());
+    #endif
      app.installTranslator(&translator);

      app.setQuitOnLastWindowClosed(false);


Additional CheckMRCRewards integrity checks

--- src/main.cpp
+++ src/main.cpp
@@ -1344,6 +1344,9 @@
     // to mempool, so failure of this method is really a problem with the staking node.
     bool CheckMRCRewards(CAmount& mrc_rewards, CAmount& mrc_staker_fees, CAmount& mrc_fees) const
     {
+        // For convenience
+        const CTransaction& coinstake = m_block.vtx[1];
+
         unsigned int mrc_outputs = 0;
         unsigned int mrc_output_limit = GetMRCOutputLimit(m_block.nVersion, false);
         unsigned int mrc_claimed_outputs = m_claim.m_mrc_tx_map.size();
@@ -1389,9 +1392,53 @@
                                                                __func__));
                                     }

+                                    CAmount mrc_reward = mrc.m_research_subsidy - mrc.m_fee;
+
+                                    // From the signature verification above, we already know that the beacon's public key
+                                    // matches what is recorded in the beacon registry. We need to check that the actual
+                                    // output on the coinstake corresponding to the MRC is paid to the beacon's public key
+                                    // (address) and is the correct amount.
+                                    CAmount coinstake_mrc_reward = 0;
+
+                                    CScript mrc_beacon_script_public_key;
+                                    mrc_beacon_script_public_key.SetDestination(beacon->GetAddress().Get());
+
+                                    // Start at the first actual MRC output. The MRC outputs come last in the coinstake.
+                                    // We must exclude the other outputs, because it is possible, and allowed, for a
+                                    // sidestake to be specified by the staker that is the same address as the staker's
+                                    // beacon address, or some other person's beacon address. We do not want to intermix
+                                    // these.
+                                    //
+                                    // Find the matched output on the coinstake.
+                                    for (unsigned int i = coinstake.vout.size() - mrc_claimed_outputs;
+                                         i < coinstake.vout.size(); ++i) {
+                                        // If an output on the coinstake matches the public key on the beacon and the
+                                        // rewards match the output, then add the value to coinstake_mrc_reward. To detect
+                                        // possible duplicates slipped in, add up all outputs where the public key matches.
+                                        // By protocol there should be only one MRC output that matches the key.
+
+                                        if (mrc_beacon_script_public_key == coinstake.vout[i].scriptPubKey) {
+                                            LogPrintf("INFO: %s: coinstake output matched to MRC.", __func__);
+
+                                            coinstake_mrc_reward += coinstake.vout[i].nValue;
+                                        }
+                                    }
+
+                                    // If this doesn't match we have a problem with the correlation between the coinstake
+                                    // and the claim in the MRC area.
+                                    if (coinstake_mrc_reward != mrc_reward) {
+                                        return m_block.DoS(10, error(
+                                                               "ConnectBlock[%s]: The rewards in an MRC, %s, do not "
+                                                               "correspond to the value of the corresponding output "
+                                                               "on the coinstake, %s.",
+                                                               __func__,
+                                                               FormatMoney(mrc_reward),
+                                                               FormatMoney(coinstake_mrc_reward)));
+                                    }
+
                                     // The net reward paid to the MRC beacon address is the requested research subsidy
                                     // (reward) minus the fees for the MRC. Accumulate to mrc_rewards
-                                    mrc_rewards += mrc.m_research_subsidy - mrc.m_fee;
+                                    mrc_rewards += mrc_reward;

                                     mrc_fees += mrc.m_fee;
                                     mrc_staker_fees += mrc.m_fee - mrc.m_fee * foundation_fee_fraction.GetNumerator()


Don't wipe the sigcache in TestBlockValidity

coming from btc@69d373ff

--- src/main.cpp
+++ src/main.cpp
@@ -2418,7 +2418,8 @@
             if (fCLTVIsActivated)
                 flags |= SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY;

-            if (!CheckInputs(tx, state, view, fScriptChecks, flags, false, nScriptCheckThreads ? &vChecks : NULL))
+            bool fCacheResults = fJustCheck; /* Don't cache results if we're actually connecting blocks (still consult the cache, though) */
+            if (!CheckInputs(tx, state, view, fScriptChecks, flags, fCacheResults, nScriptCheckThreads ? &vChecks : NULL))
                 return false;
             control.Add(vChecks);
         }


Worked on fixing bugs

Worked on fixing bugs

--- src/main.cpp
+++ src/main.cpp
@@ -42,6 +42,9 @@
       line = line.substr(1, line.size() - 1);
     }

+    // adding a space to the end makes parsing easier
+    line += ' ';
+
     if (std::cin.fail())
     {
       printf("\nGoodbye!\n");
@@ -60,6 +63,11 @@
     // syntax error flag
     bool se = false;

+    if (line.size() > 0 && isConn(line[0]))
+    {
+      se = true;
+    }
+
     // handle the input
     for(unsigned i = 0; i < line.size() && !se; ++i)
     {
@@ -77,6 +85,7 @@
         }
         else
         {
+          printf("Oh no! Recieved a word with no length\n");
           break;
         }

@@ -95,13 +104,14 @@
         {
           se = true;
         }
-        else if (con) // it's a valid connector connector
+        else if (con)
         {
           handleCon(cmds, cmd, line, mode, i, se);
         }
         else
         {
           mode = GETWORD;
+          begin = i;
         }
       }
     }
@@ -112,6 +122,8 @@
       printf("Syntax error detected\n");
       continue;
     }
+
+    cmds.push_back(cmd);

     for(unsigned i = 0; i < cmds.size(); ++i)
     {


Fix #17

Fix #17

--- src/main.cpp
+++ src/main.cpp
@@ -50,7 +50,7 @@
     return EXIT_SUCCESS;
   }

-  if (logPath && strcmp(logPath, "-") == 0)
+  if (logPath && strcmp(logPath, "-") != 0)
     Log::setLogPath(std::string(logPath));

   Client::get().listenForDomains(port);


Revert "remove invalid/duplicate setuid from main from #128", because it makes DT not run on Mac.

This reverts commit ab18ba31de0c68827d52b996dadfdea306e38887.

Conflicts:
	src/main.cpp

--- src/main.cpp
+++ src/main.cpp
@@ -34,6 +34,7 @@
 #include "dfinstance.h"

 int main(int argc, char *argv[]) {
+    QCoreApplication::setSetuidAllowed(true);
     if(!DFInstance::authorize()){
         return 0;
     }


Forgot to take out test statement

Forgot to take out test statement

--- src/main.cpp
+++ src/main.cpp
@@ -180,9 +180,6 @@

                 if(pid == 0) {
-                    if(lastSuccess == false) {
-                        cout << "1" << endl;
-                    }
                     if((!(lastOR) && !(lastAND)) || (lastSuccess == false && lastOR == true) ||
                         (lastSuccess == true && lastAND == true)) {
                         if(execvp(arr[0], arr) == -1) {


added basic functionality for ()

added basic functionality for ()

--- src/main.cpp
+++ src/main.cpp
@@ -143,11 +143,11 @@
         trim(input);

         //testing parse.
-        //cout << "Testing parse" << endl;
+        cout << "Testing parse" << endl;

         //parse
         parseInput(input,parseIn);
-        //display_vector(parseIn);
+        display_vector(parseIn);

         //create them commands.
         create_commands(parseIn,comVector,0);
@@ -156,8 +156,11 @@
         *execRes = true;
         //cout << "initialize to true: " << *execRes << endl;

+        for(unsigned int i = 0; i < comVector.size(); ++i)
+            comVector.at(i)->display();
+
         //execute that stuff you know?
-        execute_commands(comVector,*execRes);
+//        execute_commands(comVector,*execRes);

         //clear vectors.
         parseIn.clear();
@@ -606,28 +609,64 @@
             c.push_back(new Normal(xcom));
             xcom.clear();
         }
-/*        else if(m == "(")
-        {
+        else if(m == "(")
+        {
+            //new string vector(forwards).
             vector<string> smalls;
+
+            //new command vector.
             vector<Command*> bigs;

-            //copy.
-            for(unsigned int j = i; j < s.size(); ++j)
-            {
-                smalls.push_back(s.at(j));
-                if(s.at(i) == "m")
+            //new string vector(backwards).
+            vector<string> copyTemp;
+
+            //flag to know when to start copying.
+            bool copyFlag = false;
+
+            //new index of vector starting point.
+            int hold;
+
+            //copy string into vector.
+            for(unsigned int j = s.size() -1; j > i; --j)
+            {
+                //start pushing!
+                if(copyFlag)
+                    copyTemp.push_back(s.at(j));
+
+                //godd to go.
+                if(s.at(j) == ")")
                 {
-                    i = j;
-                    break;
+                    copyFlag = true;
+                    hold = j;
                 }
             }
-
+
+            //since backward make forwards.
+            for(unsigned int k = 0; k < copyTemp.size(); ++k)
+                smalls.push_back(copyTemp.at(copyTemp.size() - 1 - k));
+
+            //testing.
+            //cout << "new vector" << endl;
+            //display_vector(smalls);
+
+            //recursively make new commands.
             create_commands(smalls,bigs,flagNum + 1);
-            c.push_back(new Pcommand(bigs));
-        }
-        else if(m == ")" && flagNum != 0)
-        {
-            return;
+
+            //add to vector.
+            c.push_back(new Multi(bigs));
+
+            //test new commands.
+            //cout << "new command vector" << endl;
+            //for(unsigned int j = 0; j < bigs.size(); ++j)
+            //    bigs.at(j)->display();
+
+            //new index to start from.
+            i = hold;
+        }
+        else if(m == ")")
+        {
+            if(flagNum != 0)
+                return;
         }
         else if(m == "[")
         {
@@ -636,9 +675,12 @@
         else if(m == "]")
         {

-        }*/
+        }
         else
-            xcom.push_back(s.at(i));
+        {
+            if(m != "[" || m != "]" || m != "(" || m != ")")
+                xcom.push_back(s.at(i));
+        }
     }

     //push into command vector if the command has something in it.
@@ -660,10 +702,10 @@
     //start the process.
     for(unsigned int i = 0; i < v.size(); ++i)
     {
-        //if(v.at(i)->type() == 2)
-        //{
-        //    execute_commands(v.at(i)->grab_vector(),result);
-        //}
+        if(v.at(i)->type() == 2)
+        {
+            execute_commands(v.at(i)->grab_vector(),result);
+        }
         if(i == 0)
         {
             execute(v.at(i)->get_vector(),result);