Skip to content

Commit

Permalink
Fix 2 small issues in sporks module (bitcoin#2133)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
UdjinM6 committed Jun 18, 2018
1 parent 6bf389a commit 6410705
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/spork.cpp
Expand Up @@ -241,6 +241,11 @@ uint256 CSporkMessage::GetSignatureHash() const

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();
std::string strError = "";

Expand Down Expand Up @@ -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);

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
// 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).
Expand Down

0 comments on commit 6410705

Please sign in to comment.