From 67def9ef2e37674061939b422f66cd5da97cb565 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Fri, 19 Aug 2016 15:50:04 +0400 Subject: [PATCH] Merge #948 Refactor CDarkSendSigner f0ed400 darkSendSigner.SignMessage() should not return error message 154f1b6 darkSendSigner.VerifyMessage() should return non-localized message, its callers should populate error to debug.log b130c32 darkSendSigner.GetKeysFromSecret() should not return error message, its callers should handle it --- src/darksend-relay.cpp | 26 +++++++++----------- src/darksend.cpp | 31 ++++++++--------------- src/darksend.h | 4 +-- src/governance-vote.cpp | 16 ++++++------ src/init.cpp | 4 +-- src/instantx.cpp | 8 +++--- src/masternode-payments.cpp | 16 ++++++------ src/masternode.cpp | 49 ++++++++++++++++++------------------- src/rpcgovernance.cpp | 4 +-- src/spork.cpp | 23 +++++++++-------- 10 files changed, 82 insertions(+), 99 deletions(-) diff --git a/src/darksend-relay.cpp b/src/darksend-relay.cpp index 97212b0ff6..66535cda31 100644 --- a/src/darksend-relay.cpp +++ b/src/darksend-relay.cpp @@ -36,25 +36,24 @@ std::string CDarkSendRelay::ToString() bool CDarkSendRelay::Sign(std::string strSharedKey) { + std::string strError = ""; std::string strMessage = in.ToString() + out.ToString(); CKey key2; CPubKey pubkey2; - std::string errorMessage = ""; - if(!darkSendSigner.GetKeysFromSecret(strSharedKey, errorMessage, key2, pubkey2)) - { - LogPrintf("CDarkSendRelay():Sign - ERROR: Invalid shared key: '%s'\n", errorMessage); + if(!darkSendSigner.GetKeysFromSecret(strSharedKey, key2, pubkey2)) { + LogPrintf("CDarkSendRelay::Sign -- GetKeysFromSecret() failed, invalid shared key %s\n", 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; } - if(!darkSendSigner.VerifyMessage(pubkey2, vchSig2, strMessage, errorMessage)) { - LogPrintf("CDarkSendRelay():Sign - Verify message failed\n"); + if(!darkSendSigner.VerifyMessage(pubkey2, vchSig2, strMessage, strError)) { + LogPrintf("CDarkSendRelay::Sign -- VerifyMessage() failed, error: %s\n", strError); return false; } @@ -63,20 +62,19 @@ bool CDarkSendRelay::Sign(std::string strSharedKey) bool CDarkSendRelay::VerifyMessage(std::string strSharedKey) { + std::string strError = ""; std::string strMessage = in.ToString() + out.ToString(); CKey key2; CPubKey pubkey2; - std::string errorMessage = ""; - if(!darkSendSigner.GetKeysFromSecret(strSharedKey, errorMessage, key2, pubkey2)) - { - LogPrintf("CDarkSendRelay()::VerifyMessage - ERROR: Invalid shared key: '%s'\n", errorMessage); + if(!darkSendSigner.GetKeysFromSecret(strSharedKey, key2, pubkey2)) { + LogPrintf("CDarkSendRelay::VerifyMessage -- GetKeysFromSecret() failed, invalid shared key %s\n", strSharedKey); return false; } - if(!darkSendSigner.VerifyMessage(pubkey2, vchSig2, strMessage, errorMessage)) { - LogPrintf("CDarkSendRelay()::VerifyMessage - Verify message failed\n"); + if(!darkSendSigner.VerifyMessage(pubkey2, vchSig2, strMessage, strError)) { + LogPrintf("CDarkSendRelay::VerifyMessage -- VerifyMessage() failed, error: %s\n", strError); return false; } diff --git a/src/darksend.cpp b/src/darksend.cpp index 287944d835..d6316f50ba 100644 --- a/src/darksend.cpp +++ b/src/darksend.cpp @@ -2084,15 +2084,11 @@ bool CDarkSendSigner::IsVinAssociatedWithPubkey(const CTxIn& txin, const CPubKey return false; } -bool CDarkSendSigner::GetKeysFromSecret(std::string strSecret, std::string& strErrorRet, CKey& keyRet, CPubKey& pubkeyRet) +bool CDarkSendSigner::GetKeysFromSecret(std::string strSecret, CKey& keyRet, CPubKey& pubkeyRet) { CBitcoinSecret vchSecret; - bool fGood = vchSecret.SetString(strSecret); - if(!fGood) { - strErrorRet = _("Invalid secret."); - return false; - } + if(!vchSecret.SetString(strSecret)) return false; keyRet = vchSecret.GetKey(); pubkeyRet = keyRet.GetPubKey(); @@ -2100,18 +2096,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) @@ -2122,12 +2113,12 @@ bool CDarkSendSigner::VerifyMessage(CPubKey pubkey, const std::vector(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; } @@ -2196,7 +2186,7 @@ bool CDarksendQueue::CheckSignature() std::string strError = ""; if(!darkSendSigner.VerifyMessage(pmn->pubkey2, vchSig, strMessage, strError)) { - LogPrintf("CDarksendQueue::CheckSignature -- Got bad Masternode queue signature, vin=%s\n", vin.ToString()); + LogPrintf("CDarksendQueue::CheckSignature -- Got bad Masternode queue signature, vin=%s, error: %s\n", vin.ToString(), strError); return false; } @@ -2235,9 +2225,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; } @@ -2254,7 +2243,7 @@ bool CDarksendBroadcastTx::CheckSignature() std::string strError = ""; if(!darkSendSigner.VerifyMessage(pmn->pubkey2, vchSig, strMessage, strError)) { - LogPrintf("CDarksendBroadcastTx::CheckSignature -- Got bad dstx signature\n"); + LogPrintf("CDarksendBroadcastTx::CheckSignature -- Got bad dstx signature, error: %s\n", strError); return false; } diff --git a/src/darksend.h b/src/darksend.h index 08613c3475..a1fe8f429d 100644 --- a/src/darksend.h +++ b/src/darksend.h @@ -226,9 +226,9 @@ public: /// Is the input associated with this public key? (and there is 1000 DASH - checking if valid masternode) bool IsVinAssociatedWithPubkey(const CTxIn& vin, const CPubKey& pubkey); /// Set the private/public key values, returns true if successful - bool GetKeysFromSecret(std::string strSecret, std::string& strErrorRet, CKey& keyRet, CPubKey& pubkeyRet); + bool GetKeysFromSecret(std::string strSecret, 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..e8b37b560b 100644 --- a/src/governance-vote.cpp +++ b/src/governance-vote.cpp @@ -150,17 +150,17 @@ bool CGovernanceVote::Sign(CKey& keyMasternode, CPubKey& pubKeyMasternode) CPubKey pubKeyCollateralAddress; CKey keyCollateralAddress; - std::string errorMessage; + std::string strError; 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; } - if(!darkSendSigner.VerifyMessage(pubKeyMasternode, vchSig, strMessage, errorMessage)) { - LogPrintf("CGovernanceVote::Sign - Error upon calling VerifyMessage"); + if(!darkSendSigner.VerifyMessage(pubKeyMasternode, vchSig, strMessage, strError)) { + LogPrintf("CGovernanceVote::Sign -- VerifyMessage() failed, error: %s\n", strError); return false; } @@ -197,12 +197,12 @@ bool CGovernanceVote::IsValid(bool fSignatureCheck) if(!fSignatureCheck) return true; - std::string errorMessage; + std::string strError; std::string strMessage = vinMasternode.prevout.ToStringShort() + "|" + nParentHash.ToString() + "|" + boost::lexical_cast(nVoteSignal) + "|" + boost::lexical_cast(nVoteOutcome) + "|" + boost::lexical_cast(nTime); - if(!darkSendSigner.VerifyMessage(pmn->pubkey2, vchSig, strMessage, errorMessage)) { - LogPrintf("CGovernanceVote::IsValid() - Verify message failed - Error: %s\n", errorMessage); + if(!darkSendSigner.VerifyMessage(pmn->pubkey2, vchSig, strMessage, strError)) { + LogPrintf("CGovernanceVote::IsValid -- VerifyMessage() failed, error: %s\n", strError); return false; } diff --git a/src/init.cpp b/src/init.cpp index e28798ac92..866a8fa905 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1798,9 +1798,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) std::string strMasterNodePrivKey = GetArg("-masternodeprivkey", ""); if(!strMasterNodePrivKey.empty()) { - std::string strErrorMessage; - - if(!darkSendSigner.GetKeysFromSecret(strMasterNodePrivKey, strErrorMessage, activeMasternode.keyMasternode, activeMasternode.pubKeyMasternode)) + if(!darkSendSigner.GetKeysFromSecret(strMasterNodePrivKey, activeMasternode.keyMasternode, activeMasternode.pubKeyMasternode)) return InitError(_("Invalid masternodeprivkey. Please see documenation.")); LogPrintf(" pubKeyMasternode: %s\n", CBitcoinAddress(activeMasternode.pubKeyMasternode.GetID()).ToString()); diff --git a/src/instantx.cpp b/src/instantx.cpp index 30a8ca20c6..b3bd3970fe 100644 --- a/src/instantx.cpp +++ b/src/instantx.cpp @@ -560,7 +560,7 @@ bool CConsensusVote::CheckSignature() } if(!darkSendSigner.VerifyMessage(pmn->pubkey2, vchMasterNodeSignature, strMessage, strError)) { - LogPrintf("CConsensusVote::CheckSignature -- VerifyMessage() failed\n"); + LogPrintf("CConsensusVote::CheckSignature -- VerifyMessage() failed, error: %s\n", strError); return false; } @@ -573,13 +573,13 @@ 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; } if(!darkSendSigner.VerifyMessage(activeMasternode.pubKeyMasternode, vchMasterNodeSignature, strMessage, strError)) { - LogPrintf("CConsensusVote::Sign -- VerifyMessage() failed"); + LogPrintf("CConsensusVote::Sign -- VerifyMessage() failed, error: %s\n", strError); return false; } diff --git a/src/masternode-payments.cpp b/src/masternode-payments.cpp index f3266c8d5a..269e89babc 100644 --- a/src/masternode-payments.cpp +++ b/src/masternode-payments.cpp @@ -316,20 +316,20 @@ void CMasternodePayments::ProcessMessage(CNode* pfrom, std::string& strCommand, bool CMasternodePaymentWinner::Sign(CKey& keyMasternode, CPubKey& pubKeyMasternode) { - std::string errorMessage; + std::string strError; std::string strMasterNodeSignMessage; std::string strMessage = vinMasternode.prevout.ToStringShort() + 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; } - if(!darkSendSigner.VerifyMessage(pubKeyMasternode, vchSig, strMessage, errorMessage)) { - LogPrintf("CMasternodePing::Sign() - Error: %s\n", errorMessage); + if(!darkSendSigner.VerifyMessage(pubKeyMasternode, vchSig, strMessage, strError)) { + LogPrintf("CMasternodePing::Sign() -- VerifyMessage() failed, error: %s\n", strError); return false; } @@ -628,13 +628,13 @@ bool CMasternodePaymentWinner::SignatureValid() if(pmn != NULL) { + std::string strError = ""; std::string strMessage = vinMasternode.prevout.ToStringShort() + boost::lexical_cast(nBlockHeight) + ScriptToAsmStr(payee); - std::string errorMessage = ""; - if(!darkSendSigner.VerifyMessage(pmn->pubkey2, vchSig, strMessage, errorMessage)){ - return error("CMasternodePaymentWinner::SignatureValid() - Got bad Masternode payment signature %s", vinMasternode.ToString().c_str()); + if(!darkSendSigner.VerifyMessage(pmn->pubkey2, vchSig, strMessage, strError)) { + return error("CMasternodePaymentWinner::CheckSignature -- Got bad Masternode payment signature: vin=%s, error: %s", vinMasternode.ToString().c_str(), strError); } return true; diff --git a/src/masternode.cpp b/src/masternode.cpp index 1e1fd129b9..09736765b0 100644 --- a/src/masternode.cpp +++ b/src/masternode.cpp @@ -337,8 +337,8 @@ bool CMasternodeBroadcast::Create(std::string strService, std::string strKeyMast return false; } - if(!darkSendSigner.GetKeysFromSecret(strKeyMasternode, strErrorMessage, keyMasternodeNew, pubKeyMasternodeNew)) { - strErrorMessage = strprintf("Can't find keys for masternode %s, error: %s", strService, strErrorMessage); + if(!darkSendSigner.GetKeysFromSecret(strKeyMasternode, keyMasternodeNew, pubKeyMasternodeNew)) { + strErrorMessage = strprintf("Invalid masternode key %s", strKeyMasternode); LogPrintf("CMasternodeBroadcast::Create -- %s\n", strErrorMessage); return false; } @@ -595,7 +595,7 @@ void CMasternodeBroadcast::Relay() bool CMasternodeBroadcast::Sign(CKey& keyCollateralAddress) { - std::string errorMessage; + std::string strError; std::string strMessage; sigTime = GetAdjustedTime(); @@ -604,13 +604,13 @@ 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; } - if(!darkSendSigner.VerifyMessage(pubkey, vchSig, strMessage, errorMessage)) { - LogPrintf("CMasternodeBroadcast::Sign() - Error: %s\n", errorMessage); + if(!darkSendSigner.VerifyMessage(pubkey, vchSig, strMessage, strError)) { + LogPrintf("CMasternodeBroadcast::Sign -- VerifyMessage() failed, error: %s\n", strError); return false; } @@ -620,7 +620,7 @@ bool CMasternodeBroadcast::Sign(CKey& keyCollateralAddress) bool CMasternodeBroadcast::VerifySignature(int& nDos) { std::string strMessage; - std::string errorMessage = ""; + std::string strError = ""; nDos = 0; // @@ -636,7 +636,7 @@ bool CMasternodeBroadcast::VerifySignature(int& nDos) SanitizeString(strMessage), CBitcoinAddress(pubkey.GetID()).ToString(), EncodeBase64(&vchSig[0], vchSig.size())); - if(!darkSendSigner.VerifyMessage(pubkey, vchSig, strMessage, errorMessage)){ + if(!darkSendSigner.VerifyMessage(pubkey, vchSig, strMessage, strError)) { if (addr.ToString() != addr.ToString(false)) { // maybe it's wrong format, try again with the old one @@ -647,17 +647,17 @@ bool CMasternodeBroadcast::VerifySignature(int& nDos) SanitizeString(strMessage), CBitcoinAddress(pubkey.GetID()).ToString(), EncodeBase64(&vchSig[0], vchSig.size())); - if(!darkSendSigner.VerifyMessage(pubkey, vchSig, strMessage, errorMessage)){ + if(!darkSendSigner.VerifyMessage(pubkey, vchSig, strMessage, strError)) { // didn't work either - LogPrintf("CMasternodeBroadcast::VerifySignature - Got bad Masternode address signature, second try, sanitized error: %s\n", - SanitizeString(errorMessage)); + LogPrintf("CMasternodeBroadcast::VerifySignature -- Got bad Masternode announce signature, second try, sanitized error: %s\n", + SanitizeString(strError)); // don't ban for old masternodes, their sigs could be broken because of the bug return false; } } else { // nope, sig is actually wrong - LogPrintf("CMasternodeBroadcast::VerifySignature - Got bad Masternode address signature, sanitized error: %s\n", - SanitizeString(errorMessage)); + LogPrintf("CMasternodeBroadcast::VerifySignature -- Got bad Masternode announce signature, sanitized error: %s\n", + SanitizeString(strError)); // don't ban for old masternodes, their sigs could be broken because of the bug return false; } @@ -672,8 +672,8 @@ bool CMasternodeBroadcast::VerifySignature(int& nDos) LogPrint("masternode", "CMasternodeBroadcast::VerifySignature - strMessage: %s, pubkey address: %s, sig: %s\n", strMessage, CBitcoinAddress(pubkey.GetID()).ToString(), EncodeBase64(&vchSig[0], vchSig.size())); - if(!darkSendSigner.VerifyMessage(pubkey, vchSig, strMessage, errorMessage)){ - LogPrintf("CMasternodeBroadcast::VerifySignature - Got bad Masternode address signature, error: %s\n", errorMessage); + if(!darkSendSigner.VerifyMessage(pubkey, vchSig, strMessage, strError)){ + LogPrintf("CMasternodeBroadcast::VerifySignature -- Got bad Masternode announce signature, error: %s\n", strError); nDos = 100; return false; } @@ -710,19 +710,19 @@ CMasternodePing::CMasternodePing(CTxIn& newVin) bool CMasternodePing::Sign(CKey& keyMasternode, CPubKey& pubKeyMasternode) { - std::string errorMessage; + std::string strError; std::string strMasterNodeSignMessage; 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; } - if(!darkSendSigner.VerifyMessage(pubKeyMasternode, vchSig, strMessage, errorMessage)) { - LogPrintf("CMasternodePing::Sign() - Error: %s\n", errorMessage); + if(!darkSendSigner.VerifyMessage(pubKeyMasternode, vchSig, strMessage, strError)) { + LogPrintf("CMasternodePing::Sign -- VerifyMessage() failed, error: %s\n", strError); return false; } @@ -731,12 +731,11 @@ bool CMasternodePing::Sign(CKey& keyMasternode, CPubKey& pubKeyMasternode) bool CMasternodePing::VerifySignature(CPubKey& pubKeyMasternode, int &nDos) { std::string strMessage = vin.ToString() + blockHash.ToString() + boost::lexical_cast(sigTime); - std::string errorMessage = ""; + std::string strError = ""; nDos = 0; - if(!darkSendSigner.VerifyMessage(pubKeyMasternode, vchSig, strMessage, errorMessage)) - { - LogPrintf("CMasternodePing::VerifySignature - Got bad Masternode ping signature %s Error: %s\n", vin.ToString(), errorMessage); + if(!darkSendSigner.VerifyMessage(pubKeyMasternode, vchSig, strMessage, strError)) { + LogPrintf("CMasternodePing::VerifySignature -- Got bad Masternode ping signature: %s error: %s\n", vin.ToString(), strError); nDos = 33; return false; } diff --git a/src/rpcgovernance.cpp b/src/rpcgovernance.cpp index e074ba4de0..c2de397c7e 100644 --- a/src/rpcgovernance.cpp +++ b/src/rpcgovernance.cpp @@ -312,10 +312,10 @@ UniValue gobject(const UniValue& params, bool fHelp) UniValue statusObj(UniValue::VOBJ); - if(!darkSendSigner.GetKeysFromSecret(mne.getPrivKey(), errorMessage, keyMasternode, pubKeyMasternode)){ + if(!darkSendSigner.GetKeysFromSecret(mne.getPrivKey(), keyMasternode, pubKeyMasternode)) { failed++; statusObj.push_back(Pair("result", "failed")); - statusObj.push_back(Pair("errorMessage", "Masternode signing error, could not set key correctly: " + errorMessage)); + statusObj.push_back(Pair("errorMessage", strprintf("Invalid masternode key %s.", mne.getPrivKey()))); resultsObj.push_back(Pair(mne.getAlias(), statusObj)); continue; } diff --git a/src/spork.cpp b/src/spork.cpp index 510d3f018a..2a14f95678 100644 --- a/src/spork.cpp +++ b/src/spork.cpp @@ -196,24 +196,23 @@ bool CSporkManager::SetPrivKey(std::string strPrivKey) bool CSporkMessage::Sign(std::string strSignKey) { - std::string strMessage = boost::lexical_cast(nSporkID) + boost::lexical_cast(nValue) + boost::lexical_cast(nTimeSigned); - CKey key; CPubKey pubkey; - std::string errorMessage = ""; + std::string strError = ""; + std::string strMessage = boost::lexical_cast(nSporkID) + boost::lexical_cast(nValue) + boost::lexical_cast(nTimeSigned); - if(!darkSendSigner.GetKeysFromSecret(strSignKey, errorMessage, key, pubkey)) { - LogPrintf("CSporkMessage::Sign -- ERROR: '%s'\n", errorMessage); + if(!darkSendSigner.GetKeysFromSecret(strSignKey, key, pubkey)) { + LogPrintf("CSporkMessage::Sign -- GetKeysFromSecret() failed, invalid spork key %s\n", 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; } - if(!darkSendSigner.VerifyMessage(pubkey, vchSig, strMessage, errorMessage)) { - LogPrintf("CSporkMessage::Sign -- VerifyMessage() failed"); + if(!darkSendSigner.VerifyMessage(pubkey, vchSig, strMessage, strError)) { + LogPrintf("CSporkMessage::Sign -- VerifyMessage() failed, error: %s\n", strError); return false; } @@ -223,12 +222,12 @@ bool CSporkMessage::Sign(std::string strSignKey) bool CSporkMessage::CheckSignature() { //note: need to investigate why this is failing + std::string strError = ""; std::string strMessage = boost::lexical_cast(nSporkID) + boost::lexical_cast(nValue) + boost::lexical_cast(nTimeSigned); CPubKey pubkey(ParseHex(Params().SporkPubKey())); - std::string errorMessage = ""; - if(!darkSendSigner.VerifyMessage(pubkey, vchSig, strMessage, errorMessage)){ - LogPrintf("CSporkMessage::CheckSignature -- VerifyMessage() failed"); + if(!darkSendSigner.VerifyMessage(pubkey, vchSig, strMessage, strError)) { + LogPrintf("CSporkMessage::CheckSignature -- VerifyMessage() failed, error: %s\n", strError); return false; }