Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion lib/blockTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,17 @@ var BlockTemplate = module.exports = function BlockTemplate(
var masternodeReward;
var masternodePayee;
var masternodePayment;

var zelnodeBasicAddress;
var zelnodeBasicAmount;
var zelnodeSuperAddress;
var zelnodeSuperAmount;
var zelnodeBamfAddress;
var zelnodeBamfAmount;

var fluxPoolAddress;
var fluxPoolAmount;

if(coin.vFundingStreams) {
// Zcash has moved to fundingstreams via getblocksubsidy.
// This will calculate block reward and fundingstream totals.
Expand Down Expand Up @@ -117,13 +121,17 @@ var BlockTemplate = module.exports = function BlockTemplate(
masternodeReward = rpcData.payee_amount;
masternodePayee = rpcData.payee;
masternodePayment = rpcData.masternode_payments;

zelnodeBasicAddress = coin.payZelNodes ? rpcData.basic_zelnode_address : null;
zelnodeBasicAmount = coin.payZelNodes ? (rpcData.basic_zelnode_payout || 0) : 0;
zelnodeSuperAddress = coin.payZelNodes ? rpcData.super_zelnode_address : null;
zelnodeSuperAmount = coin.payZelNodes ? (rpcData.super_zelnode_payout || 0) : 0;
zelnodeBamfAddress = coin.payZelNodes ? rpcData.bamf_zelnode_address : null;
zelnodeBamfAmount = coin.payZelNodes ? (rpcData.bamf_zelnode_payout || 0): 0;

fluxPoolAddress = coin.payZelNodes ? rpcData.flux_creation_address : null;
fluxPoolAmount = coin.payZelNodes ? (rpcData.flux_creation_amount || 0) : 0;

var fees = [];
rpcData.transactions.forEach(function(value) {
fees.push(value);
Expand All @@ -148,7 +156,9 @@ var BlockTemplate = module.exports = function BlockTemplate(
zelnodeSuperAddress,
zelnodeSuperAmount,
zelnodeBamfAddress,
zelnodeBamfAmount
zelnodeBamfAmount,
fluxPoolAddress,
fluxPoolAmount
).toString('hex');
this.genTxHash = transactions.txHash();

Expand Down
67 changes: 53 additions & 14 deletions lib/transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const scriptFoundersCompile = address => bitcoin.script.compile([
let txHash
exports.txHash = () => txHash

exports.createGeneration = (rpcData, blockReward, feeReward, recipients, poolAddress, poolHex, coin, masternodeReward, masternodePayee, masternodePayment, zelnodeBasicAddress, zelnodeBasicAmount, zelnodeSuperAddress, zelnodeSuperAmount, zelnodeBamfAddress, zelnodeBamfAmount) => {
exports.createGeneration = (rpcData, blockReward, feeReward, recipients, poolAddress, poolHex, coin, masternodeReward, masternodePayee, masternodePayment, zelnodeBasicAddress, zelnodeBasicAmount, zelnodeSuperAddress, zelnodeSuperAmount, zelnodeBamfAddress, zelnodeBamfAmount, fluxPoolAddress, fluxPoolAmount) => {
let poolAddrHash = bitcoin.address.fromBase58Check(poolAddress).hash

let network = coin.network
Expand Down Expand Up @@ -465,34 +465,73 @@ exports.createGeneration = (rpcData, blockReward, feeReward, recipients, poolAdd
let zelnodeSuperAddrHash = zelnodeSuperAddress ? bitcoin.address.fromBase58Check(zelnodeSuperAddress).hash : null
let zelnodeBamfAddrHash = zelnodeBamfAddress ? bitcoin.address.fromBase58Check(zelnodeBamfAddress).hash : null

// pool t-addr
// pool t-addr, assume p2pkh
txb.addOutput(
scriptCompile(poolAddrHash),
Math.round(blockReward.total * (1 - (feePercent / 100))) + feeReward - zelnodeBasicAmount - zelnodeSuperAmount - zelnodeBamfAmount
)

// zelnode basic reward
if (zelnodeBasicAddrHash != null) {
txb.addOutput(
scriptCompile(zelnodeBasicAddrHash),
Math.round(zelnodeBasicAmount)
)
if (zelnodeBasicAddress.startsWith('t3') || zelnodeBasicAddress.startsWith('t2')) {
txb.addOutput(
scriptFoundersCompile(zelnodeBasicAddrHash),
Math.round(zelnodeBasicAmount)
)
} else {
txb.addOutput(
scriptCompile(zelnodeBasicAddrHash),
Math.round(zelnodeBasicAmount)
)
}
}

// zelnode super reward
if (zelnodeSuperAddrHash != null) {
txb.addOutput(
scriptCompile(zelnodeSuperAddrHash),
Math.round(zelnodeSuperAmount)
)
if (zelnodeSuperAddress.startsWith('t3') || zelnodeSuperAddress.startsWith('t2')) {
txb.addOutput(
scriptFoundersCompile(zelnodeSuperAddrHash),
Math.round(zelnodeSuperAmount)
)
} else {
txb.addOutput(
scriptCompile(zelnodeSuperAddrHash),
Math.round(zelnodeSuperAmount)
)
}
}

// zelnode bamf reward
if (zelnodeBamfAddrHash != null) {
txb.addOutput(
scriptCompile(zelnodeBamfAddrHash),
Math.round(zelnodeBamfAmount)
)
if (zelnodeBamfAddress.startsWith('t3') || zelnodeBamfAddress.startsWith('t2')) {
txb.addOutput(
scriptFoundersCompile(zelnodeBamfAddrHash),
Math.round(zelnodeBamfAmount)
)
} else {
txb.addOutput(
scriptCompile(zelnodeBamfAddrHash),
Math.round(zelnodeBamfAmount)
)
}
}

// Flux fork. Adds additional funds generation for swap pools, exchanges, foundation
let fluxPoolAddrHash = fluxPoolAddress ? bitcoin.address.fromBase58Check(fluxPoolAddress).hash : null

// flux pool creation
if (fluxPoolAddrHash != null) {
if (fluxPoolAddress.startsWith('t3') || fluxPoolAddress.startsWith('t2')) {
txb.addOutput(
scriptFoundersCompile(fluxPoolAddrHash),
Math.round(fluxPoolAmount)
)
} else {
txb.addOutput(
scriptCompile(fluxPoolAddrHash),
Math.round(fluxPoolAmount)
)
}
}
}

Expand Down