Skip to content

Commit 840c171

Browse files
committed
Pay to reward script of masternodes.
Instead of using the collateral pubkey, pay to the declared reward script of masternodes (and use that to check payments).
1 parent 16b99be commit 840c171

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

divi/src/RpcMasternodeFeatures.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ ActiveMasternodeStatus GetActiveMasternodeStatus()
223223
unsigned FindLastPayeePaymentTime(CBlockIndex* chainTip, const MasternodePaymentData& paymentData, const CMasternode& masternode, const unsigned maxBlockDepth)
224224
{
225225
assert(chainTip);
226-
CScript mnPayee = GetScriptForDestination(masternode.pubKeyCollateralAddress.GetID());
227226
unsigned n = 0;
228227
for (unsigned int i = 1; chainTip && chainTip->nHeight > 0; i++) {
229228
if (n >= maxBlockDepth) {
@@ -241,7 +240,7 @@ unsigned FindLastPayeePaymentTime(CBlockIndex* chainTip, const MasternodePayment
241240
Search for this payee, with at least 2 votes. This will aid in consensus allowing the network
242241
to converge on the same payees quickly, then keep the same schedule.
243242
*/
244-
if (masternodePayees->HasPayeeWithVotes(mnPayee, 2)) {
243+
if (masternodePayees->HasPayeeWithVotes(masternode.GetPaymentScript(), 2)) {
245244
return chainTip->nTime + masternode.DeterministicTimeOffset();
246245
}
247246
}
@@ -293,7 +292,7 @@ std::vector<MasternodeListEntry> GetMasternodeList(std::string strFilter, CBlock
293292
entry.txHash = strTxHash;
294293
entry.outputIndex = oIdx;
295294
entry.status = strStatus;
296-
entry.collateralAddress = CBitcoinAddress(masternode.pubKeyCollateralAddress.GetID()).ToString();
295+
entry.collateralAddress = collateralAddress;
297296
entry.rewardScript = HexStr(masternode.rewardScript);
298297
entry.protocolVersion = masternode.protocolVersion;
299298
entry.lastSeenTime = (int64_t)masternode.lastPing.sigTime;

divi/src/masternode-payments.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "sync.h"
1717
#include "Logging.h"
1818
#include "utilmoneystr.h"
19+
#include "utilstrencodings.h"
1920
#include "netfulfilledman.h"
2021
#include <boost/filesystem.hpp>
2122
#include <boost/lexical_cast.hpp>
@@ -328,9 +329,7 @@ bool CMasternodePayments::CheckMasternodeWinnerValidity(const CMasternodePayment
328329
/* Make sure that the payee is in our own payment queue near the top. */
329330
const std::vector<CMasternode*> mnQueue = GetMasternodePaymentQueue(scoringBlockHash, winner.GetHeight());
330331
for (int i = 0; i < std::min<int>(2 * MNPAYMENTS_SIGNATURES_TOTAL, mnQueue.size()); ++i) {
331-
const auto& mn = *mnQueue[i];
332-
const CScript mnPayee = GetScriptForDestination(mn.pubKeyCollateralAddress.GetID());
333-
if (mnPayee == winner.payee)
332+
if (winner.payee == mnQueue[i]->GetPaymentScript())
334333
return true;
335334
}
336335
return false;
@@ -464,7 +463,7 @@ void ComputeMasternodesAndScores(
464463
// proper testing with a very small number of masternodes (which would
465464
// be scheduled and skipped all the time).
466465
if (Params().NetworkID() != CBaseChainParams::REGTEST) {
467-
if (masternodePayments.IsScheduled(GetScriptForDestination(mn.pubKeyCollateralAddress.GetID()), nBlockHeight)) continue;
466+
if (masternodePayments.IsScheduled(mn.GetPaymentScript(), nBlockHeight)) continue;
468467
}
469468

470469
//it's too new, wait for a cycle

divi/src/masternode.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,7 @@ std::string CMasternode::Status() const
155155

156156
CScript CMasternode::GetPaymentScript() const
157157
{
158-
const CTxDestination dest(pubKeyCollateralAddress.GetID());
159-
return GetScriptForDestination(dest);
158+
return rewardScript;
160159
}
161160

162161
static uint256 CalculateScoreHelper(CHashWriter hashWritter, int round)

0 commit comments

Comments
 (0)