test invalid userhash (might be an invalid tx received from network)

This commit is contained in:
Miguel Freitas 2013-07-20 20:00:30 -03:00
parent d9fdca340c
commit a6ff5511fa
2 changed files with 3 additions and 1 deletions

View File

@ -84,7 +84,7 @@ uint256 CTransaction::GetUsernameHash() const
return SerializeHash(userName.ExtractSmallString());
}
// [MF] TODO: remove this assert later, it will fail for spammessage.
assert(!"username not small string");
//assert(!"username not small string");
return uint256();
}

View File

@ -494,6 +494,8 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state)
return state.DoS(10, error("CheckTransaction() : pubKey empty"));
if (!tx.userName.IsSmallString())
return state.DoS(10, error("CheckTransaction() : username not smallstring"));
if (tx.GetUsernameHash() == uint256())
return state.DoS(10, error("CheckTransaction() : username hash error"));
if (!CheckUsername( tx.userName.ExtractSmallString(), state ))
return state.DoS(10, error("CheckTransaction() : username check failed"));
}