From a1ac7ca8d3008372a5c21050e10652b4523d5deb Mon Sep 17 00:00:00 2001 From: Evan Duffield Date: Wed, 18 Mar 2015 09:41:30 -0700 Subject: [PATCH] Fixed blinding submission process --- configure.ac | 2 +- src/clientversion.h | 2 +- src/core.h | 2 +- src/darksend.cpp | 35 +++++++++++++++++++++-------------- src/darksend.h | 2 ++ src/masternode-pos.h | 2 +- src/masternode.cpp | 3 +++ src/version.h | 2 +- 8 files changed, 31 insertions(+), 19 deletions(-) diff --git a/configure.ac b/configure.ac index a9d2aaa0c..cdab57522 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.60]) define(_CLIENT_VERSION_MAJOR, 0) define(_CLIENT_VERSION_MINOR, 11) define(_CLIENT_VERSION_REVISION, 2) -define(_CLIENT_VERSION_BUILD, 5) +define(_CLIENT_VERSION_BUILD, 6) define(_CLIENT_VERSION_IS_RELEASE, true) define(_COPYRIGHT_YEAR, 2015) AC_INIT([Darkcoin Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[info@darkcoin.io],[darkcoin]) diff --git a/src/clientversion.h b/src/clientversion.h index 3971decb0..894b54dd6 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -12,7 +12,7 @@ #define CLIENT_VERSION_MAJOR 0 #define CLIENT_VERSION_MINOR 11 #define CLIENT_VERSION_REVISION 2 -#define CLIENT_VERSION_BUILD 5 +#define CLIENT_VERSION_BUILD 6 diff --git a/src/core.h b/src/core.h index 4868afc66..f80f21033 100644 --- a/src/core.h +++ b/src/core.h @@ -43,7 +43,7 @@ static const int64_t DARKSEND_POOL_MAX = (999.99*COIN); #define MASTERNODE_EXPIRATION_SECONDS (65*60) #define MASTERNODE_REMOVAL_SECONDS (70*60) -static const int MIN_POOL_PEER_PROTO_VERSION = 70071; // minimum peer version accepted by DarkSendPool +static const int MIN_POOL_PEER_PROTO_VERSION = 70072; // minimum peer version accepted by DarkSendPool class CTransaction; diff --git a/src/darksend.cpp b/src/darksend.cpp index d5453f989..76fe61dea 100644 --- a/src/darksend.cpp +++ b/src/darksend.cpp @@ -285,7 +285,6 @@ void CDarksendPool::ProcessMessageDarksend(CNode* pfrom, std::string& strCommand } // relay to all peers that an entry was added to the pool successfully. - RelayStatus(sessionID, GetState(), GetEntriesCount(), MASTERNODE_ACCEPTED); Check(); } else if (strCommand == "dsi") { //Darksend vIn @@ -642,12 +641,7 @@ void CDarksendPool::SetNull(bool clearEverything){ if(clearEverything){ myEntries.clear(); - - if(fMasterNode){ - sessionID = 1 + (rand() % 999999); - } else { - sessionID = 0; - } + sessionID = 0; } // -- seed random number generator (used for ordering output lists) @@ -765,7 +759,7 @@ void CDarksendPool::CheckFinalTransaction() // See if the transaction is valid if (!txNew.AcceptToMemoryPool(false)) { - if(nCountAttempts > 10) { + if(nCountAttempts > 60) { LogPrintf("CDarksendPool::Check() - CommitTransaction : Error: Transaction not valid\n"); SetNull(); pwalletMain->Lock(); @@ -773,9 +767,8 @@ void CDarksendPool::CheckFinalTransaction() // not much we can do in this case] UpdateState(POOL_STATUS_ACCEPTING_ENTRIES); - if(nCountAttempts > 5) RelayCompletedTransaction(sessionID, true, "Transaction not valid, please try again"); - - if(!fSubmitAnonymousFailed && nCountAttempts > 5) + + if(!fSubmitAnonymousFailed && nCountAttempts > 30) fSubmitAnonymousFailed = true; return; } @@ -1418,7 +1411,7 @@ bool CDarksendPool::StatusUpdate(int newState, int newEntriesCount, int newAccep lastMessage = error; } - if(newAccepted == 1) { + if(newAccepted == 1 && newSessionID != 0) { sessionID = newSessionID; LogPrintf("CDarksendPool::StatusUpdate - set sessionID to %d\n", sessionID); sessionFoundMasternode = true; @@ -1476,8 +1469,8 @@ bool CDarksendPool::SignFinalTransaction(CTransaction& finalTransactionNew, CNod if(mine >= 0){ //might have to do this one input at a time? //already signed - if(finalTransaction.vin[mine].scriptSig != CScript()) continue; - if(sigs.size() > 7) break; //send 7 each signing + CScript scriptOld = finalTransaction.vin[mine].scriptSig; + if(!fSubmitAnonymousFailed && sigs.size() > 7) break; //send 7 each signing int foundOutputs = 0; int64_t nValue1 = 0; @@ -1510,6 +1503,8 @@ bool CDarksendPool::SignFinalTransaction(CTransaction& finalTransactionNew, CNod // not sure what to do here, it will timeout...? } + if(scriptOld != CScript() && finalTransaction.vin[mine].scriptSig == scriptOld) continue; + sigs.push_back(finalTransaction.vin[mine]); if(fDebug) LogPrintf(" -- dss %d %d %s\n", mine, (int)sigs.size(), finalTransaction.vin[mine].scriptSig.ToString().c_str()); } @@ -2127,6 +2122,7 @@ bool CDarksendPool::IsCompatibleWithSession(int64_t nDenom, CTransaction txColla if(sessionUsers < 0) sessionUsers = 0; if(sessionUsers == 0) { + sessionID = 1 + (rand() % 999999); sessionDenom = nDenom; sessionUsers++; lastTimeChanged = GetTimeMillis(); @@ -2554,6 +2550,7 @@ bool CDSAnonTx::AddOutput(const CTxOut out){ vout.push_back(out); std::random_shuffle ( vout.begin(), vout.end(), randomizeList); + ClearSigs(); return true; } @@ -2570,6 +2567,16 @@ bool CDSAnonTx::AddInput(const CTxIn in){ vin.push_back(in); std::random_shuffle ( vin.begin(), vin.end(), randomizeList); + ClearSigs(); + + return true; +} + +bool CDSAnonTx::ClearSigs(){ + LOCK(cs_darksend); + + BOOST_FOREACH(CTxDSIn& in, vin) + in.scriptSig = CScript(); return true; } diff --git a/src/darksend.h b/src/darksend.h index ecda13022..dcf98dedf 100644 --- a/src/darksend.h +++ b/src/darksend.h @@ -271,6 +271,8 @@ public: bool AddOutput(const CTxOut out); /// Add an input bool AddInput(const CTxIn in); + /// Clear Signatures + bool ClearSigs(); /// Add Signature bool AddSig(const CTxIn in); /// Count the number of entries in the transaction diff --git a/src/masternode-pos.h b/src/masternode-pos.h index 39533bd14..78e4a4c46 100644 --- a/src/masternode-pos.h +++ b/src/masternode-pos.h @@ -25,7 +25,7 @@ class CMasternodeScanningError; extern map mapMasternodeScanningErrors; extern CMasternodeScanning mnscan; -static const int MIN_MASTERNODE_POS_PROTO_VERSION = 70071; +static const int MIN_MASTERNODE_POS_PROTO_VERSION = 70072; /* 1% of the network is scanned every 2.5 minutes, making a full diff --git a/src/masternode.cpp b/src/masternode.cpp index a50d5f2c9..7ea36fc89 100644 --- a/src/masternode.cpp +++ b/src/masternode.cpp @@ -143,6 +143,7 @@ CMasternode::CMasternode() nLastDsq = 0; donationAddress = CScript(); donationPercentage = 0; + nScanningErrorCount = 0; } CMasternode::CMasternode(const CMasternode& other) @@ -165,6 +166,7 @@ CMasternode::CMasternode(const CMasternode& other) nLastDsq = other.nLastDsq; donationAddress = other.donationAddress; donationPercentage = other.donationPercentage; + nScanningErrorCount = other.nScanningErrorCount; } CMasternode::CMasternode(CService newAddr, CTxIn newVin, CPubKey newPubkey, std::vector newSig, int64_t newSigTime, CPubKey newPubkey2, int protocolVersionIn, CScript newDonationAddress, int newDonationPercentage) @@ -185,6 +187,7 @@ CMasternode::CMasternode(CService newAddr, CTxIn newVin, CPubKey newPubkey, std: allowFreeTx = true; protocolVersion = protocolVersionIn; nLastDsq = 0; + nScanningErrorCount = 0; donationAddress = newDonationAddress; donationPercentage = newDonationPercentage; } diff --git a/src/version.h b/src/version.h index c4b23e1f1..217042db8 100644 --- a/src/version.h +++ b/src/version.h @@ -27,7 +27,7 @@ extern const std::string CLIENT_DATE; // network protocol versioning // -static const int PROTOCOL_VERSION = 70071; +static const int PROTOCOL_VERSION = 70072; // intial proto version, to be increased after version/verack negotiation static const int INIT_PROTO_VERSION = 209;