Fix GENX masternode payments (#39)

It looks like some copy+paste didn't get updated causing the same variable to be re-used. This should fix genx blocks post mn activation height.
This commit is contained in:
Beshoy Girgis 2019-04-01 10:42:50 -05:00 committed by GitHub
parent 97c65b0a41
commit 217250995c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 51 additions and 104 deletions

View File

@ -149,58 +149,6 @@ exports.createGeneration = (rpcData, blockReward, feeReward, recipients, poolAdd
)
} else if (coin.payAllFounders === true) {
// SafeCash / Genx
if (!rpcData.masternode_payments_started)
{
// Pre masternodes
// SafeCash Addresses
// Founders
// Chris
let chrisAddrHash = bitcoin.address.fromBase58Check(coin.foundersRewardAddresses[0]).hash
// Jimmy
let jimmyAddrHash = bitcoin.address.fromBase58Check(coin.foundersRewardAddresses[1]).hash
// Scott
let scottAddrHash = bitcoin.address.fromBase58Check(coin.foundersRewardAddresses[2]).hash
// Shelby
let shelbyAddrHash = bitcoin.address.fromBase58Check(coin.foundersRewardAddresses[3]).hash
// Loki
let lokiAddrHash = bitcoin.address.fromBase58Check(coin.foundersRewardAddresses[4]).hash
// Infrastructure
let infrastructureAddrHash = bitcoin.address.fromBase58Check(coin.infrastructureAddresses[0]).hash
// Giveaways
let giveawaysAddrHash = bitcoin.address.fromBase58Check(coin.giveawayAddresses[0]).hash
// Add Pool (miner coinbase) transaction
//console.log(`PoolReward: ${blockReward.miner}`)
// Calculate and do the pool fee deduction
var poolFeeDeductionTotalPercent = 0;
// Calculate the total pool fee deduction
recipients.forEach(function (recipient) {
poolFeeDeductionTotalPercent += recipient.percent;
});
var poolDeductionAmount = Math.round(blockReward.total * (poolFeeDeductionTotalPercent / 100));
console.log('Block Value: ' + blockReward.total);
console.log('Pool Fee Deduction Total Percent: ' + poolFeeDeductionTotalPercent);
console.log('Pool Fee Deduction Total Amount: ' + poolDeductionAmount);
txb.addOutput(
scriptCompile(poolAddrHash),
blockReward.miner - poolDeductionAmount + feeReward
);
// Add founders txs
txb.addOutput(scriptFoundersCompile(chrisAddrHash), blockReward.founderSplit);
txb.addOutput(scriptFoundersCompile(jimmyAddrHash), blockReward.founderSplit);
txb.addOutput(scriptFoundersCompile(scottAddrHash), blockReward.founderSplit);
txb.addOutput(scriptFoundersCompile(shelbyAddrHash), blockReward.founderSplit);
txb.addOutput(scriptFoundersCompile(lokiAddrHash), blockReward.founderSplit);
// Infrastructure
txb.addOutput(scriptFoundersCompile(infrastructureAddrHash), blockReward.infrastructure);
// Giveaways
txb.addOutput(scriptFoundersCompile(giveawaysAddrHash), blockReward.giveaways);
}
else
{
// Masternodes active
// Calculate and do the pool fee deduction
var poolFeeDeductionTotalPercent = 0;
// Calculate the total pool fee deduction
@ -242,7 +190,7 @@ exports.createGeneration = (rpcData, blockReward, feeReward, recipients, poolAdd
if (rpcData.masternodes && rpcData.masternodes.length > 0)
{
// loop through masternodes and add them to our coinbase transaction
rpcData.founders.map((masternodeItem) => {
rpcData.masternodes.map((masternodeItem) => {
txb.addOutput(
new Buffer(masternodeItem.script, 'hex'),
masternodeItem.amount
@ -253,14 +201,13 @@ exports.createGeneration = (rpcData, blockReward, feeReward, recipients, poolAdd
if (rpcData.governanceblock && rpcData.governanceblock.length > 0)
{
// loop through governance items and add them to our coinbase transaction
rpcData.founders.map((governanceItem) => {
rpcData.governanceblock.map((governanceItem) => {
txb.addOutput(
new Buffer(governanceItem.script, 'hex'),
governanceItem.amount
);
});
}
}
} else {
// founders reward
let index = parseInt(Math.floor(rpcData.height / coin.foundersRewardAddressChangeInterval))