Fix masternode voting object

This commit is contained in:
Evan Duffield 2016-04-26 10:45:06 -07:00
parent 26b8d99be2
commit 2df4059f4e
2 changed files with 29 additions and 26 deletions

View File

@ -20,19 +20,20 @@
CBudgetVote::CBudgetVote() CBudgetVote::CBudgetVote()
{ {
// vin = CTxIn(); vinMasternode = CTxIn();
// nProposalHash = uint256(); nParentHash = uint256();
nVoteAction = VOTE_ACTION_NONE; nVoteAction = VOTE_ACTION_NONE;
nVoteOutcome = VOTE_OUTCOME_NONE; nVoteOutcome = VOTE_OUTCOME_NONE;
nTime = 0; nTime = 0;
fValid = true; fValid = true;
fSynced = false; fSynced = false;
vchSig.clear();
} }
CBudgetVote::CBudgetVote(CTxIn vinIn, uint256 nProposalHashIn, int nVoteActionIn, int nVoteOutcomeIn) CBudgetVote::CBudgetVote(CTxIn vinMasternodeIn, uint256 nParentHashIn, int nVoteActionIn, int nVoteOutcomeIn)
{ {
// vin = vinIn; vinMasternode = vinMasternodeIn;
// nProposalHash = nProposalHashIn; nParentHash = nParentHashIn;
nVoteAction = nVoteActionIn; nVoteAction = nVoteActionIn;
nVoteOutcome = nVoteOutcomeIn; nVoteOutcome = nVoteOutcomeIn;
nTime = GetAdjustedTime(); nTime = GetAdjustedTime();
@ -53,17 +54,18 @@ bool CBudgetVote::Sign(CKey& keyMasternode, CPubKey& pubKeyMasternode)
CKey keyCollateralAddress; CKey keyCollateralAddress;
std::string errorMessage; std::string errorMessage;
// std::string strMessage = vin.prevout.ToStringShort() + nProposalHash.ToString() + boost::lexical_cast<std::string>(nVote) + boost::lexical_cast<std::string>(nTime); std::string strMessage = vinMasternode.prevout.ToStringShort() + "|" + nParentHash.ToString() + "|" +
boost::lexical_cast<std::string>(nVoteAction) + "|" + boost::lexical_cast<std::string>(nVoteOutcome) + "|" + boost::lexical_cast<std::string>(nTime);
// if(!darkSendSigner.SignMessage(strMessage, errorMessage, vchSig, keyMasternode)) { if(!darkSendSigner.SignMessage(strMessage, errorMessage, vchSig, keyMasternode)) {
// LogPrintf("CBudgetVote::Sign - Error upon calling SignMessage"); LogPrintf("CBudgetVote::Sign - Error upon calling SignMessage");
// return false; return false;
// } }
// if(!darkSendSigner.VerifyMessage(pubKeyMasternode, vchSig, strMessage, errorMessage)) { if(!darkSendSigner.VerifyMessage(pubKeyMasternode, vchSig, strMessage, errorMessage)) {
// LogPrintf("CBudgetVote::Sign - Error upon calling VerifyMessage"); LogPrintf("CBudgetVote::Sign - Error upon calling VerifyMessage");
// return false; return false;
// } }
return true; return true;
} }
@ -89,22 +91,23 @@ bool CBudgetVote::IsValid(bool fSignatureCheck)
return false; return false;
} }
// CMasternode* pmn = mnodeman.Find(vin); CMasternode* pmn = mnodeman.Find(vinMasternode);
// if(pmn == NULL) if(pmn == NULL)
// { {
// LogPrint("mngovernance", "CBudgetVote::IsValid() - Unknown Masternode - %s\n", vin.ToString()); LogPrint("mngovernance", "CBudgetVote::IsValid() - Unknown Masternode - %s\n", vinMasternode.ToString());
// return false; return false;
// } }
if(!fSignatureCheck) return true; if(!fSignatureCheck) return true;
std::string errorMessage; std::string errorMessage;
// std::string strMessage = vin.prevout.ToStringShort() + nProposalHash.ToString() + boost::lexical_cast<std::string>(nVote) + boost::lexical_cast<std::string>(nTime); std::string strMessage = vinMasternode.prevout.ToStringShort() + "|" + nParentHash.ToString() + "|" +
boost::lexical_cast<std::string>(nVoteAction) + "|" + boost::lexical_cast<std::string>(nVoteOutcome) + "|" + boost::lexical_cast<std::string>(nTime);
// if(!darkSendSigner.VerifyMessage(pmn->pubkey2, vchSig, strMessage, errorMessage)) { if(!darkSendSigner.VerifyMessage(pmn->pubkey2, vchSig, strMessage, errorMessage)) {
// LogPrintf("CBudgetVote::IsValid() - Verify message failed - Error: %s\n", errorMessage); LogPrintf("CBudgetVote::IsValid() - Verify message failed - Error: %s\n", errorMessage);
// return false; return false;
// } }
return true; return true;
} }

View File

@ -51,7 +51,7 @@ public:
std::vector<unsigned char> vchSig; std::vector<unsigned char> vchSig;
CBudgetVote(); CBudgetVote();
CBudgetVote(CTxIn vinMasternode, uint256 nParentHash, int nVoteActionIn, int nVoteOutcomeIn); CBudgetVote(CTxIn vinMasternodeIn, uint256 nParentHashIn, int nVoteActionIn, int nVoteOutcomeIn);
bool Sign(CKey& keyMasternode, CPubKey& pubKeyMasternode); bool Sign(CKey& keyMasternode, CPubKey& pubKeyMasternode);
bool IsValid(bool fSignatureCheck); bool IsValid(bool fSignatureCheck);