From f0ed40095a6b0be4bfdd25f936cdd494846f081c Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Thu, 18 Aug 2016 13:19:19 +0300 Subject: [PATCH] darkSendSigner.SignMessage() should not return error message --- src/darksend-relay.cpp | 4 ++-- src/darksend.cpp | 15 ++++----------- src/darksend.h | 2 +- src/governance-vote.cpp | 4 ++-- src/instantx.cpp | 4 ++-- src/masternode-payments.cpp | 4 ++-- src/masternode.cpp | 8 ++++---- src/spork.cpp | 4 ++-- 8 files changed, 19 insertions(+), 26 deletions(-) diff --git a/src/darksend-relay.cpp b/src/darksend-relay.cpp index 97212b0ff6..f3272e8e86 100644 --- a/src/darksend-relay.cpp +++ b/src/darksend-relay.cpp @@ -48,8 +48,8 @@ bool CDarkSendRelay::Sign(std::string strSharedKey) return false; } - if(!darkSendSigner.SignMessage(strMessage, errorMessage, vchSig2, key2)) { - LogPrintf("CDarkSendRelay():Sign - Sign message failed\n"); + if(!darkSendSigner.SignMessage(strMessage, vchSig2, key2)) { + LogPrintf("CDarkSendRelay::Sign -- SignMessage() failed\n"); return false; } diff --git a/src/darksend.cpp b/src/darksend.cpp index 287944d835..1377cd2774 100644 --- a/src/darksend.cpp +++ b/src/darksend.cpp @@ -2100,18 +2100,13 @@ bool CDarkSendSigner::GetKeysFromSecret(std::string strSecret, std::string& strE return true; } -bool CDarkSendSigner::SignMessage(std::string strMessage, std::string& strErrorRet, std::vector& vchSigRet, CKey key) +bool CDarkSendSigner::SignMessage(std::string strMessage, std::vector& vchSigRet, CKey key) { CHashWriter ss(SER_GETHASH, 0); ss << strMessageMagic; ss << strMessage; - if(!key.SignCompact(ss.GetHash(), vchSigRet)) { - strErrorRet = _("Signing failed."); - return false; - } - - return true; + return key.SignCompact(ss.GetHash(), vchSigRet); } bool CDarkSendSigner::VerifyMessage(CPubKey pubkey, const std::vector& vchSig, std::string strMessage, std::string& strErrorRet) @@ -2177,9 +2172,8 @@ bool CDarksendQueue::Sign() if(!fMasterNode) return false; std::string strMessage = vin.ToString() + boost::lexical_cast(nDenom) + boost::lexical_cast(nTime) + boost::lexical_cast(fReady); - std::string strError = ""; - if(!darkSendSigner.SignMessage(strMessage, strError, vchSig, activeMasternode.keyMasternode)) { + if(!darkSendSigner.SignMessage(strMessage, vchSig, activeMasternode.keyMasternode)) { LogPrintf("CDarksendQueue::Sign -- SignMessage() failed\n"); return false; } @@ -2235,9 +2229,8 @@ bool CDarksendBroadcastTx::Sign() if(!fMasterNode) return false; std::string strMessage = tx.GetHash().ToString() + boost::lexical_cast(sigTime); - std::string strError = ""; - if(!darkSendSigner.SignMessage(strMessage, strError, vchSig, activeMasternode.keyMasternode)) { + if(!darkSendSigner.SignMessage(strMessage, vchSig, activeMasternode.keyMasternode)) { LogPrintf("CDarksendBroadcastTx::Sign -- SignMessage() failed\n"); return false; } diff --git a/src/darksend.h b/src/darksend.h index 08613c3475..0f4cdda62b 100644 --- a/src/darksend.h +++ b/src/darksend.h @@ -228,7 +228,7 @@ public: /// Set the private/public key values, returns true if successful bool GetKeysFromSecret(std::string strSecret, std::string& strErrorRet, CKey& keyRet, CPubKey& pubkeyRet); /// Sign the message, returns true if successful - bool SignMessage(std::string strMessage, std::string& strErrorRet, std::vector& vchSigRet, CKey key); + bool SignMessage(std::string strMessage, std::vector& vchSigRet, CKey key); /// Verify the message, returns true if succcessful bool VerifyMessage(CPubKey pubkey, const std::vector& vchSig, std::string strMessage, std::string& strErrorRet); }; diff --git a/src/governance-vote.cpp b/src/governance-vote.cpp index 42f95cf2ba..d4f3be8bb3 100644 --- a/src/governance-vote.cpp +++ b/src/governance-vote.cpp @@ -154,8 +154,8 @@ bool CGovernanceVote::Sign(CKey& keyMasternode, CPubKey& pubKeyMasternode) std::string strMessage = vinMasternode.prevout.ToStringShort() + "|" + nParentHash.ToString() + "|" + boost::lexical_cast(nVoteSignal) + "|" + boost::lexical_cast(nVoteOutcome) + "|" + boost::lexical_cast(nTime); - if(!darkSendSigner.SignMessage(strMessage, errorMessage, vchSig, keyMasternode)) { - LogPrintf("CGovernanceVote::Sign - Error upon calling SignMessage"); + if(!darkSendSigner.SignMessage(strMessage, vchSig, keyMasternode)) { + LogPrintf("CGovernanceVote::Sign -- SignMessage() failed\n"); return false; } diff --git a/src/instantx.cpp b/src/instantx.cpp index 30a8ca20c6..cba26b7b42 100644 --- a/src/instantx.cpp +++ b/src/instantx.cpp @@ -573,8 +573,8 @@ bool CConsensusVote::Sign() std::string strMessage = txHash.ToString().c_str() + boost::lexical_cast(nBlockHeight); - if(!darkSendSigner.SignMessage(strMessage, strError, vchMasterNodeSignature, activeMasternode.keyMasternode)) { - LogPrintf("CConsensusVote::Sign -- SignMessage() failed"); + if(!darkSendSigner.SignMessage(strMessage, vchMasterNodeSignature, activeMasternode.keyMasternode)) { + LogPrintf("CConsensusVote::Sign -- SignMessage() failed\n"); return false; } diff --git a/src/masternode-payments.cpp b/src/masternode-payments.cpp index f3266c8d5a..d3f1594765 100644 --- a/src/masternode-payments.cpp +++ b/src/masternode-payments.cpp @@ -323,8 +323,8 @@ bool CMasternodePaymentWinner::Sign(CKey& keyMasternode, CPubKey& pubKeyMasterno boost::lexical_cast(nBlockHeight) + ScriptToAsmStr(payee); - if(!darkSendSigner.SignMessage(strMessage, errorMessage, vchSig, keyMasternode)) { - LogPrintf("CMasternodePing::Sign() - Error: %s\n", errorMessage); + if(!darkSendSigner.SignMessage(strMessage, vchSig, keyMasternode)) { + LogPrintf("CMasternodePaymentWinner::Sign -- SignMessage() failed\n"); return false; } diff --git a/src/masternode.cpp b/src/masternode.cpp index 1e1fd129b9..4d82b41b4e 100644 --- a/src/masternode.cpp +++ b/src/masternode.cpp @@ -604,8 +604,8 @@ bool CMasternodeBroadcast::Sign(CKey& keyCollateralAddress) pubkey.GetID().ToString() + pubkey2.GetID().ToString() + boost::lexical_cast(protocolVersion); - if(!darkSendSigner.SignMessage(strMessage, errorMessage, vchSig, keyCollateralAddress)) { - LogPrintf("CMasternodeBroadcast::Sign() - Error: %s\n", errorMessage); + if(!darkSendSigner.SignMessage(strMessage, vchSig, keyCollateralAddress)) { + LogPrintf("CMasternodeBroadcast::Sign -- SignMessage() failed\n"); return false; } @@ -716,8 +716,8 @@ bool CMasternodePing::Sign(CKey& keyMasternode, CPubKey& pubKeyMasternode) sigTime = GetAdjustedTime(); std::string strMessage = vin.ToString() + blockHash.ToString() + boost::lexical_cast(sigTime); - if(!darkSendSigner.SignMessage(strMessage, errorMessage, vchSig, keyMasternode)) { - LogPrintf("CMasternodePing::Sign() - Error: %s\n", errorMessage); + if(!darkSendSigner.SignMessage(strMessage, vchSig, keyMasternode)) { + LogPrintf("CMasternodePing::Sign -- SignMessage() failed\n"); return false; } diff --git a/src/spork.cpp b/src/spork.cpp index 510d3f018a..46b4dee7d2 100644 --- a/src/spork.cpp +++ b/src/spork.cpp @@ -207,8 +207,8 @@ bool CSporkMessage::Sign(std::string strSignKey) return false; } - if(!darkSendSigner.SignMessage(strMessage, errorMessage, vchSig, key)) { - LogPrintf("CSporkMessage::Sign -- SignMessage() failed"); + if(!darkSendSigner.SignMessage(strMessage, vchSig, key)) { + LogPrintf("CSporkMessage::Sign -- SignMessage() failed\n"); return false; }