darkSendSigner.SignMessage() should not return error message

This commit is contained in:
UdjinM6 2016-08-18 13:19:19 +03:00
parent de7b2b6c51
commit f0ed40095a
8 changed files with 19 additions and 26 deletions

View File

@ -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;
}

View File

@ -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<unsigned char>& vchSigRet, CKey key)
bool CDarkSendSigner::SignMessage(std::string strMessage, std::vector<unsigned char>& 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<unsigned char>& 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<std::string>(nDenom) + boost::lexical_cast<std::string>(nTime) + boost::lexical_cast<std::string>(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<std::string>(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;
}

View File

@ -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<unsigned char>& vchSigRet, CKey key);
bool SignMessage(std::string strMessage, std::vector<unsigned char>& vchSigRet, CKey key);
/// Verify the message, returns true if succcessful
bool VerifyMessage(CPubKey pubkey, const std::vector<unsigned char>& vchSig, std::string strMessage, std::string& strErrorRet);
};

View File

@ -154,8 +154,8 @@ bool CGovernanceVote::Sign(CKey& keyMasternode, CPubKey& pubKeyMasternode)
std::string strMessage = vinMasternode.prevout.ToStringShort() + "|" + nParentHash.ToString() + "|" +
boost::lexical_cast<std::string>(nVoteSignal) + "|" + boost::lexical_cast<std::string>(nVoteOutcome) + "|" + boost::lexical_cast<std::string>(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;
}

View File

@ -573,8 +573,8 @@ bool CConsensusVote::Sign()
std::string strMessage = txHash.ToString().c_str() + boost::lexical_cast<std::string>(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;
}

View File

@ -323,8 +323,8 @@ bool CMasternodePaymentWinner::Sign(CKey& keyMasternode, CPubKey& pubKeyMasterno
boost::lexical_cast<std::string>(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;
}

View File

@ -604,8 +604,8 @@ bool CMasternodeBroadcast::Sign(CKey& keyCollateralAddress)
pubkey.GetID().ToString() + pubkey2.GetID().ToString() +
boost::lexical_cast<std::string>(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<std::string>(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;
}

View File

@ -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;
}