Fix 2 small issues in sporks module (#2133)

* Fix a crash when someone tries to update sporks without specifying `sporkkey`

Before:
Crashes with `Assertion failed: (fValid), function GetPubKey, file key.cpp, line 156.`

After:
Fails and prints rpc help for `spork`

* Silence logging in CSporkMessage::CheckSignature() a bit

CMessageSigner::VerifyMessage() failure is not really an error
if CHashSigner::VerifyHash() below passes with no issues.
No need to log this.
This commit is contained in:
UdjinM6 2018-06-19 02:40:55 +03:00 committed by GitHub
parent 6bf389afb8
commit 6410705211
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -241,6 +241,11 @@ uint256 CSporkMessage::GetSignatureHash() const
bool CSporkMessage::Sign(const CKey& key) bool CSporkMessage::Sign(const CKey& key)
{ {
if (!key.IsValid()) {
LogPrintf("CSporkMessage::Sign -- signing key is not valid\n");
return false;
}
CKeyID pubKeyId = key.GetPubKey().GetID(); CKeyID pubKeyId = key.GetPubKey().GetID();
std::string strError = ""; std::string strError = "";
@ -290,7 +295,6 @@ bool CSporkMessage::CheckSignature(const CKeyID& pubKeyId) const
std::string strMessage = boost::lexical_cast<std::string>(nSporkID) + boost::lexical_cast<std::string>(nValue) + boost::lexical_cast<std::string>(nTimeSigned); std::string strMessage = boost::lexical_cast<std::string>(nSporkID) + boost::lexical_cast<std::string>(nValue) + boost::lexical_cast<std::string>(nTimeSigned);
if (!CMessageSigner::VerifyMessage(pubKeyId, vchSig, strMessage, strError)){ if (!CMessageSigner::VerifyMessage(pubKeyId, vchSig, strMessage, strError)){
LogPrintf("CSporkMessage::CheckSignature -- VerifyMessage() failed, error: %s\n", strError);
// Note: unlike for other messages we have to check for new format even with SPORK_6_NEW_SIGS // Note: unlike for other messages we have to check for new format even with SPORK_6_NEW_SIGS
// inactive because SPORK_6_NEW_SIGS default is OFF and it is not the first spork to sync // inactive because SPORK_6_NEW_SIGS default is OFF and it is not the first spork to sync
// (and even if it would, spork order can't be guaranteed anyway). // (and even if it would, spork order can't be guaranteed anyway).