@@ -244,11 +244,16 @@ void CInstantSend::Vote(CTxLockCandidate& txLockCandidate, CConnman& connman)
244244 int nLockInputHeight = nPrevoutHeight + Params ().GetConsensus ().nInstantSendConfirmationsRequired - 2 ;
245245
246246 int nRank;
247+ uint256 quorumModifierHash;
247248 int nMinRequiredProtocol = std::max (MIN_INSTANTSEND_PROTO_VERSION, mnpayments.GetMinMasternodePaymentsProto ());
248- if (!mnodeman.GetMasternodeRank (activeMasternodeInfo.outpoint , nRank, nLockInputHeight, nMinRequiredProtocol)) {
249+ if (!mnodeman.GetMasternodeRank (activeMasternodeInfo.outpoint , nRank, quorumModifierHash, nLockInputHeight, nMinRequiredProtocol)) {
249250 LogPrint (" instantsend" , " CInstantSend::Vote -- Can't calculate rank for masternode %s\n " , activeMasternodeInfo.outpoint .ToStringShort ());
250251 continue ;
251252 }
253+ if (!deterministicMNManager->IsDeterministicMNsSporkActive ()) {
254+ // not used until spork15 activation
255+ quorumModifierHash = uint256 ();
256+ }
252257
253258 int nSignaturesTotal = COutPointLock::SIGNATURES_TOTAL;
254259 if (nRank > nSignaturesTotal) {
@@ -282,7 +287,7 @@ void CInstantSend::Vote(CTxLockCandidate& txLockCandidate, CConnman& connman)
282287
283288 // we haven't voted for this outpoint yet, let's try to do this now
284289 // Please note that activeMasternodeInfo.proTxHash is only valid after spork15 activation
285- CTxLockVote vote (txHash, outpointLockPair.first , activeMasternodeInfo.outpoint , activeMasternodeInfo.proTxHash );
290+ CTxLockVote vote (txHash, outpointLockPair.first , activeMasternodeInfo.outpoint , quorumModifierHash, activeMasternodeInfo.proTxHash );
286291
287292 if (!vote.Sign ()) {
288293 LogPrintf (" CInstantSend::Vote -- Failed to sign consensus vote\n " );
@@ -1052,12 +1057,23 @@ bool CTxLockVote::IsValid(CNode* pnode, CConnman& connman) const
10521057 int nLockInputHeight = coin.nHeight + Params ().GetConsensus ().nInstantSendConfirmationsRequired - 2 ;
10531058
10541059 int nRank;
1060+ uint256 expectedQuorumModifierHash;
10551061 int nMinRequiredProtocol = std::max (MIN_INSTANTSEND_PROTO_VERSION, mnpayments.GetMinMasternodePaymentsProto ());
1056- if (!mnodeman.GetMasternodeRank (outpointMasternode, nRank, nLockInputHeight, nMinRequiredProtocol)) {
1062+ if (!mnodeman.GetMasternodeRank (outpointMasternode, nRank, expectedQuorumModifierHash, nLockInputHeight, nMinRequiredProtocol)) {
10571063 // can be caused by past versions trying to vote with an invalid protocol
10581064 LogPrint (" instantsend" , " CTxLockVote::IsValid -- Can't calculate rank for masternode %s\n " , outpointMasternode.ToStringShort ());
10591065 return false ;
10601066 }
1067+ if (!quorumModifierHash.IsNull ()) {
1068+ if (quorumModifierHash != expectedQuorumModifierHash) {
1069+ LogPrint (" instantsend" , " CTxLockVote::IsValid -- invalid quorumModifierHash %s, expected %s\n " , quorumModifierHash.ToString (), expectedQuorumModifierHash.ToString ());
1070+ return false ;
1071+ }
1072+ } else if (deterministicMNManager->IsDeterministicMNsSporkActive ()) {
1073+ LogPrint (" instantsend" , " CTxLockVote::IsValid -- missing quorumModifierHash while DIP3 is active\n " );
1074+ return false ;
1075+ }
1076+
10611077 LogPrint (" instantsend" , " CTxLockVote::IsValid -- Masternode %s, rank=%d\n " , outpointMasternode.ToStringShort (), nRank);
10621078
10631079 int nSignaturesTotal = COutPointLock::SIGNATURES_TOTAL;
0 commit comments