Skip to content

Commit d781599

Browse files
committed
Updated version. Fixed 0 commission tpos reward distribution
1 parent 72b3020 commit d781599

2 files changed

Lines changed: 21 additions & 13 deletions

File tree

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N)
22
AC_PREREQ([2.60])
33
define(_CLIENT_VERSION_MAJOR, 1)
44
define(_CLIENT_VERSION_MINOR, 0)
5-
define(_CLIENT_VERSION_REVISION, 25)
5+
define(_CLIENT_VERSION_REVISION, 26)
66
define(_CLIENT_VERSION_BUILD, 0)
77
define(_CLIENT_VERSION_IS_RELEASE, true)
88
define(_COPYRIGHT_YEAR, 2020)

src/masternode-payments.cpp

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,22 +1106,30 @@ void AdjustMasternodePayment(CMutableTransaction &tx, const CTxOut &txoutMastern
11061106
{
11071107
auto it = std::find(std::begin(tx.vout), std::end(tx.vout), txoutMasternodePayment);
11081108

1109-
if(it != std::end(tx.vout))
1110-
{
1109+
if (it != std::end(tx.vout)) {
11111110
int mnPaymentOutIndex = std::distance(std::begin(tx.vout), it);
11121111
auto masternodePayment = tx.vout[mnPaymentOutIndex].nValue;
11131112

1114-
int i = tx.vout.size() - 2;
1115-
if(tposContract.IsValid()) // here we have 3 outputs, first as stake reward, second as tpos reward, third as MN reward
1116-
{
1117-
tx.vout[i - 1].nValue -= TPoSUtils::GetOwnerPayment(masternodePayment, tposContract.nOperatorReward); // adjust reward for owner.
1118-
// it might be that last vout is masternode, since operator reward was 0
1119-
if (tx.vout[i].scriptPubKey == tposContract.scriptMerchantAddress) {
1120-
tx.vout[i].nValue -= TPoSUtils::GetOperatorPayment(masternodePayment, tposContract.nOperatorReward); // adjust reward for merchant
1113+
if (tposContract.IsValid()) {
1114+
// here we have 3 outputs, first as stake reward, second as tpos reward, third as MN reward
1115+
auto ownerOutIt = std::find_if(tx.vout.rbegin(),tx.vout.rend(), [&tposContract](const CTxOut &out) {
1116+
return out.scriptPubKey == tposContract.scriptTPoSAddress;
1117+
});
1118+
1119+
if (ownerOutIt != tx.vout.rend()) {
1120+
ownerOutIt->nValue -= TPoSUtils::GetOwnerPayment(masternodePayment, tposContract.nOperatorReward); // adjust reward for owner.
11211121
}
1122-
}
1123-
else // here we have 2 outputs, first as stake reward, second as MN reward
1124-
{
1122+
1123+
auto merchantOutIt = std::find_if(std::begin(tx.vout), std::end(tx.vout), [&tposContract](const CTxOut &out) {
1124+
return out.scriptPubKey == tposContract.scriptMerchantAddress;
1125+
});
1126+
1127+
if (merchantOutIt != std::end(tx.vout)) {
1128+
merchantOutIt->nValue -= TPoSUtils::GetOperatorPayment(masternodePayment, tposContract.nOperatorReward); // adjust reward for merchant
1129+
}
1130+
} else {
1131+
// here we have 2 outputs, first as stake reward, second as MN reward
1132+
int i = tx.vout.size() - 2;
11251133
tx.vout[i].nValue -= masternodePayment; // last vout is mn payment.
11261134
}
11271135
}

0 commit comments

Comments
 (0)