From 8e05e9eb100ed92b06284852fe1703c8ce08ef42 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Wed, 15 Apr 2015 01:40:28 +0300 Subject: [PATCH] Fix translations: - mn replies - MN should use codes for replies, translations are done on client side (client protocol / min pool peer protocol bump) - use QString for translation instead of ostream, construct better human readable strings for translators - progress - use QString here too --- src/darksend.cpp | 152 +++++++++++++++++++++++----------------- src/darksend.h | 34 +++++++-- src/qt/dashstrings.cpp | 28 ++++---- src/qt/overviewpage.cpp | 69 +++++++++--------- src/version.h | 4 +- 5 files changed, 165 insertions(+), 122 deletions(-) diff --git a/src/darksend.cpp b/src/darksend.cpp index e72ce1479..6fc81056f 100644 --- a/src/darksend.cpp +++ b/src/darksend.cpp @@ -53,18 +53,20 @@ void CDarksendPool::ProcessMessageDarksend(CNode* pfrom, std::string& strCommand if (strCommand == "dsa") { //Darksend Accept Into Pool + int errorID; + if (pfrom->nVersion < MIN_POOL_PEER_PROTO_VERSION) { - std::string strError = _("Incompatible version."); + errorID = ERR_VERSION; LogPrintf("dsa -- incompatible version! \n"); - pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, strError); + pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, errorID); return; } if(!fMasterNode){ - std::string strError = _("This is not a Masternode."); + errorID = ERR_NOT_A_MN; LogPrintf("dsa -- not a Masternode! \n"); - pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, strError); + pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, errorID); return; } @@ -73,12 +75,11 @@ void CDarksendPool::ProcessMessageDarksend(CNode* pfrom, std::string& strCommand CTransaction txCollateral; vRecv >> nDenom >> txCollateral; - std::string error = ""; CMasternode* pmn = mnodeman.Find(activeMasternode.vin); if(pmn == NULL) { - std::string strError = _("Not in the Masternode list."); - pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, strError); + errorID = ERR_MN_LIST; + pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, errorID); return; } @@ -86,20 +87,20 @@ void CDarksendPool::ProcessMessageDarksend(CNode* pfrom, std::string& strCommand if(pmn->nLastDsq != 0 && pmn->nLastDsq + mnodeman.CountMasternodesAboveProtocol(MIN_POOL_PEER_PROTO_VERSION)/5 > mnodeman.nDsqCount){ LogPrintf("dsa -- last dsq too recent, must wait. %s \n", pfrom->addr.ToString().c_str()); - std::string strError = _("Last Darksend was too recent."); - pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, strError); + errorID = ERR_RECENT; + pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, errorID); return; } } - if(!IsCompatibleWithSession(nDenom, txCollateral, error)) + if(!IsCompatibleWithSession(nDenom, txCollateral, errorID)) { LogPrintf("dsa -- not compatible with existing transactions! \n"); - pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, error); + pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, errorID); return; } else { LogPrintf("dsa -- is compatible, please submit! \n"); - pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_ACCEPTED, error); + pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_ACCEPTED, errorID); return; } @@ -158,19 +159,19 @@ void CDarksendPool::ProcessMessageDarksend(CNode* pfrom, std::string& strCommand } } else if (strCommand == "dsi") { //DarkSend vIn - std::string error = ""; + int errorID = MSG_NOERR; if (pfrom->nVersion < MIN_POOL_PEER_PROTO_VERSION) { LogPrintf("dsi -- incompatible version! \n"); - error = _("Incompatible version."); - pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, error); + errorID = ERR_VERSION; + pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, errorID); return; } if(!fMasterNode){ LogPrintf("dsi -- not a Masternode! \n"); - error = _("This is not a Masternode."); - pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, error); + errorID = ERR_NOT_A_MN; + pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, errorID); return; } @@ -184,8 +185,8 @@ void CDarksendPool::ProcessMessageDarksend(CNode* pfrom, std::string& strCommand //do we have enough users in the current session? if(!IsSessionReady()){ LogPrintf("dsi -- session not complete! \n"); - error = _("Session not complete!"); - pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, error); + errorID = ERR_SESSION; + pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, errorID); return; } @@ -193,8 +194,8 @@ void CDarksendPool::ProcessMessageDarksend(CNode* pfrom, std::string& strCommand if(!IsCompatibleWithEntries(out)) { LogPrintf("dsi -- not compatible with existing transactions! \n"); - error = _("Not compatible with existing transactions."); - pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, error); + errorID = ERR_EXISTING_TX; + pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, errorID); return; } @@ -213,14 +214,14 @@ void CDarksendPool::ProcessMessageDarksend(CNode* pfrom, std::string& strCommand if(o.scriptPubKey.size() != 25){ LogPrintf("dsi - non-standard pubkey detected! %s\n", o.scriptPubKey.ToString().c_str()); - error = _("Non-standard public key detected."); - pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, error); + errorID = ERR_NON_STANDARD_PUBKEY; + pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, errorID); return; } if(!o.scriptPubKey.IsNormalPaymentScript()){ LogPrintf("dsi - invalid script! %s\n", o.scriptPubKey.ToString().c_str()); - error = _("Invalid script detected."); - pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, error); + errorID = ERR_INVALID_SCRIPT; + pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, errorID); return; } } @@ -243,40 +244,40 @@ void CDarksendPool::ProcessMessageDarksend(CNode* pfrom, std::string& strCommand if (nValueIn > DARKSEND_POOL_MAX) { LogPrintf("dsi -- more than Darksend pool max! %s\n", tx.ToString().c_str()); - error = _("Value more than Darksend pool maximum allows."); - pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, error); + errorID = ERR_MAXIMUM; + pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, errorID); return; } if(!missingTx){ if (nValueIn-nValueOut > nValueIn*.01) { LogPrintf("dsi -- fees are too high! %s\n", tx.ToString().c_str()); - error = _("Transaction fees are too high."); - pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, error); + errorID = ERR_FEES; + pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, errorID); return; } } else { LogPrintf("dsi -- missing input tx! %s\n", tx.ToString().c_str()); - error = _("Missing input transaction information."); - pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, error); + errorID = ERR_MISSING_TX; + pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, errorID); return; } if(!AcceptableInputs(mempool, state, CTransaction(tx), false, NULL)) { LogPrintf("dsi -- transaction not valid! \n"); - error = _("Transaction not valid."); - pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, error); + errorID = ERR_INVALID_TX; + pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, errorID); return; } } - if(AddEntry(in, nAmount, txCollateral, out, error)){ - pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_ACCEPTED, error); + if(AddEntry(in, nAmount, txCollateral, out, errorID)){ + pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_ACCEPTED, errorID); Check(); RelayStatus(sessionID, GetState(), GetEntriesCount(), MASTERNODE_RESET); } else { - pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, error); + pfrom->PushMessage("dssu", sessionID, GetState(), GetEntriesCount(), MASTERNODE_REJECTED, errorID); } } else if (strCommand == "dssu") { //Darksend status update @@ -294,17 +295,17 @@ void CDarksendPool::ProcessMessageDarksend(CNode* pfrom, std::string& strCommand int state; int entriesCount; int accepted; - std::string error; - vRecv >> sessionIDMessage >> state >> entriesCount >> accepted >> error; + int errorID; + vRecv >> sessionIDMessage >> state >> entriesCount >> accepted >> errorID; - if(fDebug) LogPrintf("dssu - state: %i entriesCount: %i accepted: %i error: %s \n", state, entriesCount, accepted, error.c_str()); + if(fDebug) LogPrintf("dssu - state: %i entriesCount: %i accepted: %i error: %s \n", state, entriesCount, accepted, GetMessageByID(errorID).c_str()); if((accepted != 1 && accepted != 0) && sessionID != sessionIDMessage){ LogPrintf("dssu - message doesn't match current Darksend session %d %d\n", sessionID, sessionIDMessage); return; } - StatusUpdate(state, entriesCount, accepted, error, sessionIDMessage); + StatusUpdate(state, entriesCount, accepted, errorID, sessionIDMessage); } else if (strCommand == "dss") { //Darksend Sign Final Tx @@ -611,7 +612,7 @@ void CDarksendPool::CheckFinalTransaction() // not much we can do in this case UpdateState(POOL_STATUS_ACCEPTING_ENTRIES); - RelayCompletedTransaction(sessionID, true, "Transaction not valid, please try again"); + RelayCompletedTransaction(sessionID, true, ERR_INVALID_TX); return; } @@ -657,7 +658,7 @@ void CDarksendPool::CheckFinalTransaction() txNew.RelayWalletTransaction(); // Tell the clients it was successful - RelayCompletedTransaction(sessionID, false, _("Transaction created successfully.")); + RelayCompletedTransaction(sessionID, false, MSG_SUCCESS); // Randomly charge clients ChargeRandomFees(); @@ -1021,13 +1022,13 @@ bool CDarksendPool::IsCollateralValid(const CTransaction& txCollateral){ // // Add a clients transaction to the pool // -bool CDarksendPool::AddEntry(const std::vector& newInput, const int64_t& nAmount, const CTransaction& txCollateral, const std::vector& newOutput, std::string& error){ +bool CDarksendPool::AddEntry(const std::vector& newInput, const int64_t& nAmount, const CTransaction& txCollateral, const std::vector& newOutput, int& errorID){ if (!fMasterNode) return false; BOOST_FOREACH(CTxIn in, newInput) { if (in.prevout.IsNull() || nAmount < 0) { if(fDebug) LogPrintf ("CDarksendPool::AddEntry - input not valid!\n"); - error = _("Input is not valid."); + errorID = ERR_INVALID_INPUT; sessionUsers--; return false; } @@ -1035,14 +1036,14 @@ bool CDarksendPool::AddEntry(const std::vector& newInput, const int64_t& if (!IsCollateralValid(txCollateral)){ if(fDebug) LogPrintf ("CDarksendPool::AddEntry - collateral not valid!\n"); - error = _("Collateral is not valid."); + errorID = ERR_INVALID_COLLATERAL; sessionUsers--; return false; } if((int)entries.size() >= GetMaxPoolTransactions()){ if(fDebug) LogPrintf ("CDarksendPool::AddEntry - entries is full!\n"); - error = _("Entries are full."); + errorID = ERR_ENTRIES_FULL; sessionUsers--; return false; } @@ -1053,7 +1054,7 @@ bool CDarksendPool::AddEntry(const std::vector& newInput, const int64_t& BOOST_FOREACH(const CTxDSIn& s, v.sev){ if((CTxIn)s == in) { if(fDebug) LogPrintf ("CDarksendPool::AddEntry - found in vin\n"); - error = _("Already have that input."); + errorID = ERR_ALREADY_HAVE; sessionUsers--; return false; } @@ -1066,7 +1067,7 @@ bool CDarksendPool::AddEntry(const std::vector& newInput, const int64_t& entries.push_back(v); if(fDebug) LogPrintf("CDarksendPool::AddEntry -- adding %s\n", newInput[0].ToString().c_str()); - error = ""; + errorID = MSG_NOERR; return true; } @@ -1202,21 +1203,21 @@ void CDarksendPool::SendDarksendDenominate(std::vector& vin, std::vector< // 0 means transaction was not accepted // 1 means transaction was accepted -bool CDarksendPool::StatusUpdate(int newState, int newEntriesCount, int newAccepted, std::string& error, int newSessionID){ +bool CDarksendPool::StatusUpdate(int newState, int newEntriesCount, int newAccepted, int& errorID, int newSessionID){ if(fMasterNode) return false; if(state == POOL_STATUS_ERROR || state == POOL_STATUS_SUCCESS) return false; UpdateState(newState); entriesCount = newEntriesCount; - if(error.size() > 0) strAutoDenomResult = _("Masternode:") + " " + error; + if(errorID != MSG_NOERR) strAutoDenomResult = _("Masternode:") + " " + GetMessageByID(errorID); if(newAccepted != -1) { lastEntryAccepted = newAccepted; countEntriesAccepted += newAccepted; if(newAccepted == 0){ UpdateState(POOL_STATUS_ERROR); - lastMessage = error; + lastMessage = GetMessageByID(errorID); } if(newAccepted == 1 && newSessionID != 0) { @@ -1827,7 +1828,7 @@ bool CDarksendPool::IsCompatibleWithEntries(std::vector& vout) return true; } -bool CDarksendPool::IsCompatibleWithSession(int64_t nDenom, CTransaction txCollateral, std::string& strReason) +bool CDarksendPool::IsCompatibleWithSession(int64_t nDenom, CTransaction txCollateral, int& errorID) { if(nDenom == 0) return false; @@ -1835,7 +1836,7 @@ bool CDarksendPool::IsCompatibleWithSession(int64_t nDenom, CTransaction txColla if (!unitTest && !IsCollateralValid(txCollateral)){ if(fDebug) LogPrintf ("CDarksendPool::IsCompatibleWithSession - collateral not valid!\n"); - strReason = _("Collateral not valid."); + errorID = ERR_INVALID_COLLATERAL; return false; } @@ -1864,14 +1865,14 @@ bool CDarksendPool::IsCompatibleWithSession(int64_t nDenom, CTransaction txColla } if((state != POOL_STATUS_ACCEPTING_ENTRIES && state != POOL_STATUS_QUEUE) || sessionUsers >= GetMaxPoolTransactions()){ - if((state != POOL_STATUS_ACCEPTING_ENTRIES && state != POOL_STATUS_QUEUE)) strReason = _("Incompatible mode."); - if(sessionUsers >= GetMaxPoolTransactions()) strReason = _("Masternode queue is full."); + if((state != POOL_STATUS_ACCEPTING_ENTRIES && state != POOL_STATUS_QUEUE)) errorID = ERR_MODE; + if(sessionUsers >= GetMaxPoolTransactions()) errorID = ERR_QUEUE_FULL; LogPrintf("CDarksendPool::IsCompatibleWithSession - incompatible mode, return false %d %d\n", state != POOL_STATUS_ACCEPTING_ENTRIES, sessionUsers >= GetMaxPoolTransactions()); return false; } if(nDenom != sessionDenom) { - strReason = _("No matching denominations found for mixing."); + errorID = ERR_DENOM; return false; } @@ -2019,6 +2020,34 @@ int CDarksendPool::GetDenominationsByAmount(int64_t nAmount, int nDenomTarget){ return GetDenominations(vout1); } +std::string CDarksendPool::GetMessageByID(int messageID) { + switch (messageID) { + case ERR_ALREADY_HAVE: return _("Already have that input."); + case ERR_DENOM: return _("No matching denominations found for mixing."); + case ERR_ENTRIES_FULL: return _("Entries are full."); + case ERR_EXISTING_TX: return _("Not compatible with existing transactions."); + case ERR_FEES: return _("Transaction fees are too high."); + case ERR_INVALID_COLLATERAL: return _("Collateral not valid."); + case ERR_INVALID_INPUT: return _("Input is not valid."); + case ERR_INVALID_SCRIPT: return _("Invalid script detected."); + case ERR_INVALID_TX: return _("Transaction not valid."); + case ERR_MAXIMUM: return _("Value more than Darksend pool maximum allows."); + case ERR_MN_LIST: return _("Not in the Masternode list."); + case ERR_MODE: return _("Incompatible mode."); + case ERR_NON_STANDARD_PUBKEY: return _("Non-standard public key detected."); + case ERR_NOT_A_MN: return _("This is not a Masternode."); + case ERR_QUEUE_FULL: return _("Masternode queue is full."); + case ERR_RECENT: return _("Last Darksend was too recent."); + case ERR_SESSION: return _("Session not complete!"); + case ERR_MISSING_TX: return _("Missing input transaction information."); + case ERR_VERSION: return _("Incompatible version."); + case MSG_SUCCESS: return _("Transaction created successfully."); + case MSG_NOERR: + default: + return ""; + } +} + bool CDarkSendSigner::IsVinAssociatedWithPubkey(CTxIn& vin, CPubKey& pubkey){ CScript payee2; payee2 = GetScriptForDestination(pubkey.GetID()); @@ -2175,18 +2204,18 @@ void CDarksendPool::RelayIn(const std::vector& vin, const int64_t& nAmo } } -void CDarksendPool::RelayStatus(const int sessionID, const int newState, const int newEntriesCount, const int newAccepted, const std::string error) +void CDarksendPool::RelayStatus(const int sessionID, const int newState, const int newEntriesCount, const int newAccepted, const int errorID) { LOCK(cs_vNodes); BOOST_FOREACH(CNode* pnode, vNodes) - pnode->PushMessage("dssu", sessionID, newState, newEntriesCount, newAccepted, error); + pnode->PushMessage("dssu", sessionID, newState, newEntriesCount, newAccepted, errorID); } -void CDarksendPool::RelayCompletedTransaction(const int sessionID, const bool error, const std::string errorMessage) +void CDarksendPool::RelayCompletedTransaction(const int sessionID, const bool error, const int errorID) { LOCK(cs_vNodes); BOOST_FOREACH(CNode* pnode, vNodes) - pnode->PushMessage("dsc", sessionID, error, errorMessage); + pnode->PushMessage("dsc", sessionID, error, errorID); } //TODO: Rename/move to core @@ -2265,6 +2294,3 @@ void ThreadCheckDarkSendPool() } } } - - - diff --git a/src/darksend.h b/src/darksend.h index 927a5bb99..50547af39 100644 --- a/src/darksend.h +++ b/src/darksend.h @@ -261,6 +261,29 @@ public: class CDarksendPool { public: + enum messages { + ERR_ALREADY_HAVE, + ERR_DENOM, + ERR_ENTRIES_FULL, + ERR_EXISTING_TX, + ERR_FEES, + ERR_INVALID_COLLATERAL, + ERR_INVALID_INPUT, + ERR_INVALID_SCRIPT, + ERR_INVALID_TX, + ERR_MAXIMUM, + ERR_MN_LIST, + ERR_MODE, + ERR_NON_STANDARD_PUBKEY, + ERR_NOT_A_MN, + ERR_QUEUE_FULL, + ERR_RECENT, + ERR_SESSION, + ERR_MISSING_TX, + ERR_VERSION, + MSG_NOERR, + MSG_SUCCESS + }; std::vector myEntries; // clients entries std::vector entries; // Masternode entries @@ -419,7 +442,7 @@ public: bool IsCompatibleWithEntries(std::vector& vout); /// Is this amount compatible with other client in the pool? - bool IsCompatibleWithSession(int64_t nAmount, CTransaction txCollateral, std::string& strReason); + bool IsCompatibleWithSession(int64_t nAmount, CTransaction txCollateral, int &errorID); /// Passively run Darksend in the background according to the configuration in settings (only for QT) bool DoAutomaticDenominating(bool fDryRun=false, bool ready=false); @@ -439,7 +462,7 @@ public: /// If the collateral is valid given by a client bool IsCollateralValid(const CTransaction& txCollateral); /// Add a clients entry to the pool - bool AddEntry(const std::vector& newInput, const int64_t& nAmount, const CTransaction& txCollateral, const std::vector& newOutput, std::string& error); + bool AddEntry(const std::vector& newInput, const int64_t& nAmount, const CTransaction& txCollateral, const std::vector& newOutput, int& errorID); /// Add signature to a vin bool AddScriptSig(const CTxIn& newVin); /// Check that all inputs are signed. (Are all inputs signed?) @@ -447,7 +470,7 @@ public: /// As a client, send a transaction to a Masternode to start the denomination process void SendDarksendDenominate(std::vector& vin, std::vector& vout, int64_t amount); /// Get Masternode updates about the progress of Darksend - bool StatusUpdate(int newState, int newEntriesCount, int newAccepted, std::string& error, int newSessionID=0); + bool StatusUpdate(int newState, int newEntriesCount, int newAccepted, int &errorID, int newSessionID=0); /// As a client, check and sign the final transaction bool SignFinalTransaction(CTransaction& finalTransactionNew, CNode* node); @@ -475,6 +498,7 @@ public: int GetDenominationsByAmount(int64_t nAmount, int nDenomTarget=0); int GetDenominationsByAmounts(std::vector& vecAmount); + std::string GetMessageByID(int messageID); // // Relay Darksend Messages @@ -484,8 +508,8 @@ public: void RelaySignaturesAnon(std::vector& vin); void RelayInAnon(std::vector& vin, std::vector& vout); void RelayIn(const std::vector& vin, const int64_t& nAmount, const CTransaction& txCollateral, const std::vector& vout); - void RelayStatus(const int sessionID, const int newState, const int newEntriesCount, const int newAccepted, const std::string error=""); - void RelayCompletedTransaction(const int sessionID, const bool error, const std::string errorMessage); + void RelayStatus(const int sessionID, const int newState, const int newEntriesCount, const int newAccepted, const int errorID=MSG_NOERR); + void RelayCompletedTransaction(const int sessionID, const bool error, const int errorID); }; void ThreadCheckDarkSendPool(); diff --git a/src/qt/dashstrings.cpp b/src/qt/dashstrings.cpp index 2d2df2d9b..ae7640881 100644 --- a/src/qt/dashstrings.cpp +++ b/src/qt/dashstrings.cpp @@ -24,8 +24,7 @@ QT_TRANSLATE_NOOP("dash-core", "" "If the file does not exist, create it with owner-readable-only file " "permissions.\n" "It is also recommended to set alertnotify so you are notified of problems;\n" -"for example: alertnotify=echo %%s | mail -s \"Dash Alert\" admin@foo." -"com\n"), +"for example: alertnotify=echo %%s | mail -s \"Dash Alert\" admin@foo.com\n"), QT_TRANSLATE_NOOP("dash-core", "" "Acceptable ciphers (default: TLSv1.2+HIGH:TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!" "3DES:@STRENGTH)"), @@ -131,8 +130,7 @@ QT_TRANSLATE_NOOP("dash-core", "" "This is a pre-release test build - use at your own risk - do not use for " "mining or merchant applications"), QT_TRANSLATE_NOOP("dash-core", "" -"Unable to bind to %s on this computer. Dash Core is probably already " -"running."), +"Unable to bind to %s on this computer. Dash Core is probably already running."), QT_TRANSLATE_NOOP("dash-core", "" "Unable to locate enough Darksend denominated funds for this transaction."), QT_TRANSLATE_NOOP("dash-core", "" @@ -188,7 +186,6 @@ QT_TRANSLATE_NOOP("dash-core", "Cannot resolve -bind address: '%s'"), QT_TRANSLATE_NOOP("dash-core", "Cannot resolve -externalip address: '%s'"), QT_TRANSLATE_NOOP("dash-core", "Cannot write default address"), QT_TRANSLATE_NOOP("dash-core", "Clear list of wallet transactions (diagnostic tool; implies -rescan)"), -QT_TRANSLATE_NOOP("dash-core", "Collateral is not valid."), QT_TRANSLATE_NOOP("dash-core", "Collateral not valid."), QT_TRANSLATE_NOOP("dash-core", "Connect only to the specified node(s)"), QT_TRANSLATE_NOOP("dash-core", "Connect through SOCKS proxy"), @@ -197,20 +194,19 @@ QT_TRANSLATE_NOOP("dash-core", "Connect to KeePassHttp on port (default: QT_TRANSLATE_NOOP("dash-core", "Connect to a node to retrieve peer addresses, and disconnect"), QT_TRANSLATE_NOOP("dash-core", "Connection options:"), QT_TRANSLATE_NOOP("dash-core", "Corrupted block database detected"), -QT_TRANSLATE_NOOP("dash-core", "Dash Core Daemon"), -QT_TRANSLATE_NOOP("dash-core", "Dash Core RPC client version"), QT_TRANSLATE_NOOP("dash-core", "Darksend is disabled."), QT_TRANSLATE_NOOP("dash-core", "Darksend options:"), +QT_TRANSLATE_NOOP("dash-core", "Dash Core Daemon"), +QT_TRANSLATE_NOOP("dash-core", "Dash Core RPC client version"), QT_TRANSLATE_NOOP("dash-core", "Debugging/Testing options:"), QT_TRANSLATE_NOOP("dash-core", "Disable safemode, override a real safe mode event (default: 0)"), QT_TRANSLATE_NOOP("dash-core", "Discover own IP address (default: 1 when listening and no -externalip)"), QT_TRANSLATE_NOOP("dash-core", "Do not load the wallet and disable wallet RPC calls"), QT_TRANSLATE_NOOP("dash-core", "Do you want to rebuild the block database now?"), QT_TRANSLATE_NOOP("dash-core", "Done loading"), -QT_TRANSLATE_NOOP("dash-core", "Downgrading and trying again."), QT_TRANSLATE_NOOP("dash-core", "Enable the client to act as a masternode (0-1, default: 0)"), QT_TRANSLATE_NOOP("dash-core", "Entries are full."), -QT_TRANSLATE_NOOP("dash-core", "Error connecting to masternode."), +QT_TRANSLATE_NOOP("dash-core", "Error connecting to Masternode."), QT_TRANSLATE_NOOP("dash-core", "Error initializing block database"), QT_TRANSLATE_NOOP("dash-core", "Error initializing wallet database environment %s!"), QT_TRANSLATE_NOOP("dash-core", "Error loading block database"), @@ -270,7 +266,7 @@ QT_TRANSLATE_NOOP("dash-core", "Keep N dash anonymized (default: 0)"), QT_TRANSLATE_NOOP("dash-core", "Keep at most unconnectable blocks in memory (default: %u)"), QT_TRANSLATE_NOOP("dash-core", "Keep at most unconnectable transactions in memory (default: %u)"), QT_TRANSLATE_NOOP("dash-core", "Last Darksend was too recent."), -QT_TRANSLATE_NOOP("dash-core", "Last successful darksend action was too recent."), +QT_TRANSLATE_NOOP("dash-core", "Last successful Darksend action was too recent."), QT_TRANSLATE_NOOP("dash-core", "Limit size of signature cache to entries (default: 50000)"), QT_TRANSLATE_NOOP("dash-core", "List commands"), QT_TRANSLATE_NOOP("dash-core", "Listen for connections on (default: 9999 or testnet: 19999)"), @@ -288,14 +284,14 @@ QT_TRANSLATE_NOOP("dash-core", "Masternode:"), QT_TRANSLATE_NOOP("dash-core", "Maximum per-connection receive buffer, *1000 bytes (default: 5000)"), QT_TRANSLATE_NOOP("dash-core", "Maximum per-connection send buffer, *1000 bytes (default: 1000)"), QT_TRANSLATE_NOOP("dash-core", "Missing input transaction information."), -QT_TRANSLATE_NOOP("dash-core", "No compatible masternode found."), +QT_TRANSLATE_NOOP("dash-core", "No Masternodes detected."), +QT_TRANSLATE_NOOP("dash-core", "No compatible Masternode found."), QT_TRANSLATE_NOOP("dash-core", "No funds detected in need of denominating."), -QT_TRANSLATE_NOOP("dash-core", "No masternodes detected."), QT_TRANSLATE_NOOP("dash-core", "No matching denominations found for mixing."), QT_TRANSLATE_NOOP("dash-core", "Non-standard public key detected."), QT_TRANSLATE_NOOP("dash-core", "Not compatible with existing transactions."), QT_TRANSLATE_NOOP("dash-core", "Not enough file descriptors available."), -QT_TRANSLATE_NOOP("dash-core", "Not in the masternode list."), +QT_TRANSLATE_NOOP("dash-core", "Not in the Masternode list."), QT_TRANSLATE_NOOP("dash-core", "Only accept block chain matching built-in checkpoints (default: 1)"), QT_TRANSLATE_NOOP("dash-core", "Only connect to nodes in network (IPv4, IPv6 or Tor)"), QT_TRANSLATE_NOOP("dash-core", "Options:"), @@ -321,9 +317,9 @@ QT_TRANSLATE_NOOP("dash-core", "Send trace/debug info to console instead of debu QT_TRANSLATE_NOOP("dash-core", "Server certificate file (default: server.cert)"), QT_TRANSLATE_NOOP("dash-core", "Server private key (default: server.pem)"), QT_TRANSLATE_NOOP("dash-core", "Session not complete!"), -QT_TRANSLATE_NOOP("dash-core", "Session timed out (30 seconds), please resubmit."), +QT_TRANSLATE_NOOP("dash-core", "Session timed out, please resubmit."), QT_TRANSLATE_NOOP("dash-core", "Set database cache size in megabytes (%d to %d, default: %d)"), -QT_TRANSLATE_NOOP("dash-core", "Set key pool size to (default: 100)"), +QT_TRANSLATE_NOOP("dash-core", "Set key pool size to (default: 1000)"), QT_TRANSLATE_NOOP("dash-core", "Set maximum block size in bytes (default: %d)"), QT_TRANSLATE_NOOP("dash-core", "Set minimum block size in bytes (default: 0)"), QT_TRANSLATE_NOOP("dash-core", "Set the masternode private key"), @@ -347,7 +343,7 @@ QT_TRANSLATE_NOOP("dash-core", "Start Dash Core Daemon"), QT_TRANSLATE_NOOP("dash-core", "System error: "), QT_TRANSLATE_NOOP("dash-core", "This help message"), QT_TRANSLATE_NOOP("dash-core", "This is intended for regression testing tools and app development."), -QT_TRANSLATE_NOOP("dash-core", "This is not a masternode."), +QT_TRANSLATE_NOOP("dash-core", "This is not a Masternode."), QT_TRANSLATE_NOOP("dash-core", "Threshold for disconnecting misbehaving peers (default: 100)"), QT_TRANSLATE_NOOP("dash-core", "To use the %s option"), QT_TRANSLATE_NOOP("dash-core", "Transaction amount too small"), diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 905db810c..c15d8b142 100755 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -358,10 +358,8 @@ void OverviewPage::updateDarksendProgress() ui->darksendProgress->setValue(progress); - std::ostringstream convert; - convert << "Progress: " << progress << "%, inputs have an average of " << pwalletMain->GetAverageAnonymizedRounds() << " of " << nDarksendRounds << " rounds"; - QString s(convert.str().c_str()); - ui->darksendProgress->setToolTip(s); + QString strToolPip = tr("Progress: %1% (inputs have an average of %2 of %n rounds)", "", nDarksendRounds).arg(progress).arg(pwalletMain->GetAverageAnonymizedRounds()); + ui->darksendProgress->setToolTip(strToolPip); } @@ -377,12 +375,10 @@ void OverviewPage::darkSendStatus() updateDarksendProgress(); - QString strSettings(" " + tr("Rounds")); - strSettings.prepend(QString::number(nDarksendRounds)).prepend(" / "); - strSettings.prepend(BitcoinUnits::formatWithUnit( - walletModel->getOptionsModel()->getDisplayUnit(), - nAnonymizeDarkcoinAmount * COIN) - ); + QString strSettings = BitcoinUnits::formatWithUnit( + walletModel->getOptionsModel()->getDisplayUnit(), + nAnonymizeDarkcoinAmount * COIN + ) + " / " + tr("%n Rounds", "", nDarksendRounds); ui->labelAmountRounds->setText(strSettings); } @@ -416,60 +412,61 @@ void OverviewPage::darkSendStatus() int accepted = darkSendPool.GetLastEntryAccepted(); /* ** @TODO this string creation really needs some clean ups ---vertoe ** */ - std::ostringstream convert; + QString strStatus; - if(state == POOL_STATUS_IDLE) { - convert << tr("Darksend is idle.").toStdString(); + if(chainActive.Tip()->nHeight - darkSendPool.cachedLastSuccess < darkSendPool.minBlockSpacing) { + strStatus = QString(darkSendPool.strAutoDenomResult.c_str()); + } else if(state == POOL_STATUS_IDLE) { + strStatus = tr("Darksend is idle."); } else if(state == POOL_STATUS_ACCEPTING_ENTRIES) { if(entries == 0) { if(darkSendPool.strAutoDenomResult.size() == 0){ - convert << tr("Mixing in progress...").toStdString(); + strStatus = tr("Mixing in progress..."); } else { - convert << darkSendPool.strAutoDenomResult; + strStatus = QString(darkSendPool.strAutoDenomResult.c_str()); } showingDarkSendMessage = 0; } else if (accepted == 1) { - convert << tr("Darksend request complete: Your transaction was accepted into the pool!").toStdString(); + strStatus = tr("Darksend request complete:") + " " + tr("Your transaction was accepted into the pool!"); if(showingDarkSendMessage % 10 > 8) { darkSendPool.lastEntryAccepted = 0; showingDarkSendMessage = 0; } } else { - if(showingDarkSendMessage % 70 <= 40) convert << tr("Submitted following entries to masternode:").toStdString() << " " << entries << "/" << darkSendPool.GetMaxPoolTransactions(); - else if(showingDarkSendMessage % 70 <= 50) convert << tr("Submitted to masternode, waiting for more entries").toStdString() << " (" << entries << "/" << darkSendPool.GetMaxPoolTransactions() << " ) ."; - else if(showingDarkSendMessage % 70 <= 60) convert << tr("Submitted to masternode, waiting for more entries").toStdString() << " (" << entries << "/" << darkSendPool.GetMaxPoolTransactions() << " ) .."; - else if(showingDarkSendMessage % 70 <= 70) convert << tr("Submitted to masternode, waiting for more entries").toStdString() << " (" << entries << "/" << darkSendPool.GetMaxPoolTransactions() << " ) ..."; + if(showingDarkSendMessage % 70 <= 40) strStatus = tr("Submitted following entries to masternode: %1 / %2").arg(entries).arg(darkSendPool.GetMaxPoolTransactions()); + else if(showingDarkSendMessage % 70 <= 50) strStatus = tr("Submitted to masternode, waiting for more entries ( %1 / %2 ) %3").arg(entries).arg(darkSendPool.GetMaxPoolTransactions()).arg(" ."); + else if(showingDarkSendMessage % 70 <= 60) strStatus = tr("Submitted to masternode, waiting for more entries ( %1 / %2 ) %3").arg(entries).arg(darkSendPool.GetMaxPoolTransactions()).arg(" .."); + else if(showingDarkSendMessage % 70 <= 70) strStatus = tr("Submitted to masternode, waiting for more entries ( %1 / %2 ) %3").arg(entries).arg(darkSendPool.GetMaxPoolTransactions()).arg(" ..."); } } else if(state == POOL_STATUS_SIGNING) { - if(showingDarkSendMessage % 70 <= 10) convert << tr("Found enough users, signing ...").toStdString(); - else if(showingDarkSendMessage % 70 <= 20) convert << tr("Found enough users, signing ( waiting").toStdString() << ". )"; - else if(showingDarkSendMessage % 70 <= 30) convert << tr("Found enough users, signing ( waiting").toStdString() << ".. )"; - else if(showingDarkSendMessage % 70 <= 40) convert << tr("Found enough users, signing ( waiting").toStdString() << "... )"; + if(showingDarkSendMessage % 70 <= 10) strStatus = tr("Found enough users, signing ..."); + else if(showingDarkSendMessage % 70 <= 20) strStatus = tr("Found enough users, signing ( waiting %1 )").arg("."); + else if(showingDarkSendMessage % 70 <= 30) strStatus = tr("Found enough users, signing ( waiting %1 )").arg(".."); + else if(showingDarkSendMessage % 70 <= 40) strStatus = tr("Found enough users, signing ( waiting %1 )").arg("..."); } else if(state == POOL_STATUS_TRANSMISSION) { - convert << tr("Transmitting final transaction.").toStdString(); + strStatus = tr("Transmitting final transaction."); } else if (state == POOL_STATUS_IDLE) { - convert << tr("Darksend is idle.").toStdString(); + strStatus = tr("Darksend is idle."); } else if (state == POOL_STATUS_FINALIZE_TRANSACTION) { - convert << tr("Finalizing transaction.").toStdString(); + strStatus = tr("Finalizing transaction."); } else if(state == POOL_STATUS_ERROR) { - convert << tr("Darksend request incomplete:").toStdString() << " " << darkSendPool.lastMessage << ". " << tr("Will retry...").toStdString(); + strStatus = tr("Darksend request incomplete:") + " " + tr(darkSendPool.lastMessage.c_str()) + " " + tr("Will retry..."); } else if(state == POOL_STATUS_SUCCESS) { - convert << tr("Darksend request complete:").toStdString() << " " << darkSendPool.lastMessage; + strStatus = tr("Darksend request complete:") + " " + tr(darkSendPool.lastMessage.c_str()); } else if(state == POOL_STATUS_QUEUE) { - if(showingDarkSendMessage % 70 <= 50) convert << tr("Submitted to masternode, waiting in queue").toStdString() << " ."; - else if(showingDarkSendMessage % 70 <= 60) convert << tr("Submitted to masternode, waiting in queue").toStdString() << " .."; - else if(showingDarkSendMessage % 70 <= 70) convert << tr("Submitted to masternode, waiting in queue").toStdString() << " ..."; + if(showingDarkSendMessage % 70 <= 50) strStatus = tr("Submitted to masternode, waiting in queue %1").arg("."); + else if(showingDarkSendMessage % 70 <= 60) strStatus = tr("Submitted to masternode, waiting in queue %1").arg(".."); + else if(showingDarkSendMessage % 70 <= 70) strStatus = tr("Submitted to masternode, waiting in queue %1").arg("..."); } else { - convert << tr("Unknown state:").toStdString() << " id = " << state; + strStatus = tr("Unknown state: id = %1").arg(state); } if(state == POOL_STATUS_ERROR || state == POOL_STATUS_SUCCESS) darkSendPool.Check(); - QString s(convert.str().c_str()); - s = tr("Last Darksend message:\n") + s; + QString s = tr("Last Darksend message:\n") + strStatus; if(s != ui->darksendStatus->text()) - LogPrintf("Last Darksend message: %s\n", convert.str().c_str()); + LogPrintf("Last Darksend message: %s\n", strStatus.toStdString()); ui->darksendStatus->setText(s); diff --git a/src/version.h b/src/version.h index 7a46b6718..bcd518b94 100644 --- a/src/version.h +++ b/src/version.h @@ -10,7 +10,7 @@ * network protocol versioning */ -static const int PROTOCOL_VERSION = 70076; +static const int PROTOCOL_VERSION = 70077; //! initial proto version, to be increased after version/verack negotiation static const int INIT_PROTO_VERSION = 209; @@ -22,7 +22,7 @@ static const int GETHEADERS_VERSION = 70076; static const int MIN_PEER_PROTO_VERSION = 70066; //! minimum peer version accepted by DarksendPool -static const int MIN_POOL_PEER_PROTO_VERSION = 70076; +static const int MIN_POOL_PEER_PROTO_VERSION = 70077; //! nTime field added to CAddress, starting with this version; //! if possible, avoid requesting addresses nodes older than this