mirror of https://github.com/BTCPrivate/z-nomp.git
Move Txfee to coins/coin.json
This commit is contained in:
parent
5fbbed7446
commit
b85536e65e
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "komodo",
|
"name": "komodo",
|
||||||
"symbol": "kmd",
|
"symbol": "kmd",
|
||||||
"algorithm": "equihash"
|
"algorithm": "equihash",
|
||||||
|
"txfee": 0.00005
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,5 +56,6 @@
|
||||||
"t3PSn5TbMMAEw7Eu36DYctFezRzpX1hzf3M",
|
"t3PSn5TbMMAEw7Eu36DYctFezRzpX1hzf3M",
|
||||||
"t3R3Y5vnBLrEn8L6wFjPjBLnxSUQsKnmFpv",
|
"t3R3Y5vnBLrEn8L6wFjPjBLnxSUQsKnmFpv",
|
||||||
"t3Pcm737EsVkGTbhsu2NekKtJeG92mvYyoN"
|
"t3Pcm737EsVkGTbhsu2NekKtJeG92mvYyoN"
|
||||||
]
|
],
|
||||||
|
"txfee": 0.0004
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,16 +9,17 @@
|
||||||
"foundersRewardAddressChangeInterval": 17709.3125,
|
"foundersRewardAddressChangeInterval": 17709.3125,
|
||||||
"vFoundersRewardAddress": [
|
"vFoundersRewardAddress": [
|
||||||
"t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi", "t2N9PH9Wk9xjqYg9iin1Ua3aekJqfAtE543", "t2NGQjYMQhFndDHguvUw4wZdNdsssA6K7x2", "t2ENg7hHVqqs9JwU5cgjvSbxnT2a9USNfhy",
|
"t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi", "t2N9PH9Wk9xjqYg9iin1Ua3aekJqfAtE543", "t2NGQjYMQhFndDHguvUw4wZdNdsssA6K7x2", "t2ENg7hHVqqs9JwU5cgjvSbxnT2a9USNfhy",
|
||||||
"t2BkYdVCHzvTJJUTx4yZB8qeegD8QsPx8bo", "t2J8q1xH1EuigJ52MfExyyjYtN3VgvshKDf", "t2Crq9mydTm37kZokC68HzT6yez3t2FBnFj", "t2EaMPUiQ1kthqcP5UEkF42CAFKJqXCkXC9",
|
"t2BkYdVCHzvTJJUTx4yZB8qeegD8QsPx8bo", "t2J8q1xH1EuigJ52MfExyyjYtN3VgvshKDf", "t2Crq9mydTm37kZokC68HzT6yez3t2FBnFj", "t2EaMPUiQ1kthqcP5UEkF42CAFKJqXCkXC9",
|
||||||
"t2F9dtQc63JDDyrhnfpzvVYTJcr57MkqA12", "t2LPirmnfYSZc481GgZBa6xUGcoovfytBnC", "t26xfxoSw2UV9Pe5o3C8V4YybQD4SESfxtp", "t2D3k4fNdErd66YxtvXEdft9xuLoKD7CcVo",
|
"t2F9dtQc63JDDyrhnfpzvVYTJcr57MkqA12", "t2LPirmnfYSZc481GgZBa6xUGcoovfytBnC", "t26xfxoSw2UV9Pe5o3C8V4YybQD4SESfxtp", "t2D3k4fNdErd66YxtvXEdft9xuLoKD7CcVo",
|
||||||
"t2DWYBkxKNivdmsMiivNJzutaQGqmoRjRnL", "t2C3kFF9iQRxfc4B9zgbWo4dQLLqzqjpuGQ", "t2MnT5tzu9HSKcppRyUNwoTp8MUueuSGNaB", "t2AREsWdoW1F8EQYsScsjkgqobmgrkKeUkK",
|
"t2DWYBkxKNivdmsMiivNJzutaQGqmoRjRnL", "t2C3kFF9iQRxfc4B9zgbWo4dQLLqzqjpuGQ", "t2MnT5tzu9HSKcppRyUNwoTp8MUueuSGNaB", "t2AREsWdoW1F8EQYsScsjkgqobmgrkKeUkK",
|
||||||
"t2Vf4wKcJ3ZFtLj4jezUUKkwYR92BLHn5UT", "t2K3fdViH6R5tRuXLphKyoYXyZhyWGghDNY", "t2VEn3KiKyHSGyzd3nDw6ESWtaCQHwuv9WC", "t2F8XouqdNMq6zzEvxQXHV1TjwZRHwRg8gC",
|
"t2Vf4wKcJ3ZFtLj4jezUUKkwYR92BLHn5UT", "t2K3fdViH6R5tRuXLphKyoYXyZhyWGghDNY", "t2VEn3KiKyHSGyzd3nDw6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"t2D5y7J5fpXajLbGrMBQkFg2mFN8fo3n8cX", "t2UV2wr1PTaUiybpkV3FdSdGxUJeZdZztyt"
|
||||||
]
|
],
|
||||||
|
"txfee": 0.0004
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,5 +3,6 @@
|
||||||
"symbol": "zcl",
|
"symbol": "zcl",
|
||||||
"algorithm": "equihash",
|
"algorithm": "equihash",
|
||||||
"requireShielding": true,
|
"requireShielding": true,
|
||||||
"peerMagic": "24e92764"
|
"peerMagic": "24e92764",
|
||||||
|
"txfee": 0.0004
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,5 +2,6 @@
|
||||||
"name": "zdash",
|
"name": "zdash",
|
||||||
"symbol": "zdash",
|
"symbol": "zdash",
|
||||||
"algorithm": "equihash",
|
"algorithm": "equihash",
|
||||||
"requireShielding": true
|
"requireShielding": true,
|
||||||
|
"txfee": 0.0004
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,12 +50,13 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
||||||
var logSystem = 'Payments';
|
var logSystem = 'Payments';
|
||||||
var logComponent = coin;
|
var logComponent = coin;
|
||||||
var opidCount = 0;
|
var opidCount = 0;
|
||||||
|
|
||||||
var minConfShield = 3;
|
var minConfShield = 3;
|
||||||
var minConfPayout = 10;
|
var minConfPayout = 10;
|
||||||
|
|
||||||
var requireShielding = poolOptions.coin.requireShielding === true;
|
var requireShielding = poolOptions.coin.requireShielding === true;
|
||||||
|
var fee = poolOptions.coin.txfee;
|
||||||
|
|
||||||
logger.special(logSystem, logComponent, logComponent + ' requireShielding: ' + requireShielding);
|
logger.special(logSystem, logComponent, logComponent + ' requireShielding: ' + requireShielding);
|
||||||
|
|
||||||
var daemon = new Stratum.daemon.interface([processingConfig.daemon], function(severity, message){
|
var daemon = new Stratum.daemon.interface([processingConfig.daemon], function(severity, message){
|
||||||
|
@ -221,14 +222,14 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
||||||
return;
|
return;
|
||||||
if ((tBalance - 10000) < 0)
|
if ((tBalance - 10000) < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// do not allow more than a single z_sendmany operation at a time
|
// do not allow more than a single z_sendmany operation at a time
|
||||||
if (opidCount > 0) {
|
if (opidCount > 0) {
|
||||||
logger.warning(logSystem, logComponent, 'sendTToZ is waiting, too many z_sendmany operations already in progress.');
|
logger.warning(logSystem, logComponent, 'sendTToZ is waiting, too many z_sendmany operations already in progress.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var amount = balanceRound((tBalance - 10000) / magnitude);
|
var amount = balanceRound((tBalance - 10000) / magnitude);
|
||||||
var params = [poolOptions.address, [{'address': poolOptions.zAddress, 'amount': amount}]];
|
var params = [poolOptions.address, [{'address': poolOptions.zAddress, 'amount': amount}]];
|
||||||
daemon.cmd('z_sendmany', params,
|
daemon.cmd('z_sendmany', params,
|
||||||
function (result) {
|
function (result) {
|
||||||
|
@ -247,7 +248,7 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// send z_address balance to t_address
|
// send z_address balance to t_address
|
||||||
function sendZToT (callback, zBalance) {
|
function sendZToT (callback, zBalance) {
|
||||||
if (callback === true)
|
if (callback === true)
|
||||||
|
@ -260,12 +261,12 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
||||||
logger.warning(logSystem, logComponent, 'sendZToT is waiting, too many z_sendmany operations already in progress.');
|
logger.warning(logSystem, logComponent, 'sendZToT is waiting, too many z_sendmany operations already in progress.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var amount = balanceRound((zBalance - 10000) / magnitude);
|
var amount = balanceRound((zBalance - 10000) / magnitude);
|
||||||
// no more than 100 ZEC at a time
|
// no more than 100 ZEC at a time
|
||||||
if (amount > 100.0)
|
if (amount > 100.0)
|
||||||
amount = 100.0;
|
amount = 100.0;
|
||||||
|
|
||||||
var params = [poolOptions.zAddress, [{'address': poolOptions.tAddress, 'amount': amount}]];
|
var params = [poolOptions.zAddress, [{'address': poolOptions.tAddress, 'amount': amount}]];
|
||||||
daemon.cmd('z_sendmany', params,
|
daemon.cmd('z_sendmany', params,
|
||||||
function (result) {
|
function (result) {
|
||||||
|
@ -285,21 +286,21 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function cacheNetworkStats () {
|
function cacheNetworkStats () {
|
||||||
var params = null;
|
var params = null;
|
||||||
daemon.cmd('getmininginfo', params,
|
daemon.cmd('getmininginfo', params,
|
||||||
function (result) {
|
function (result) {
|
||||||
var finalRedisCommands = [];
|
var finalRedisCommands = [];
|
||||||
var coin = logComponent;
|
var coin = logComponent;
|
||||||
|
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
logger.error(logSystem, logComponent, 'Error with RPC call `getmininginfo`'
|
logger.error(logSystem, logComponent, 'Error with RPC call `getmininginfo`'
|
||||||
+ JSON.stringify(result.error));
|
+ JSON.stringify(result.error));
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
if (result[0].response.blocks !== null) {
|
if (result[0].response.blocks !== null) {
|
||||||
finalRedisCommands.push(['hset', coin + ':stats', 'networkBlocks', result[0].response.blocks]);
|
finalRedisCommands.push(['hset', coin + ':stats', 'networkBlocks', result[0].response.blocks]);
|
||||||
finalRedisCommands.push(['hset', coin + ':stats', 'networkDiff', result[0].response.difficulty]);
|
finalRedisCommands.push(['hset', coin + ':stats', 'networkDiff', result[0].response.difficulty]);
|
||||||
finalRedisCommands.push(['hset', coin + ':stats', 'networkSols', result[0].response.networksolps]);
|
finalRedisCommands.push(['hset', coin + ':stats', 'networkSols', result[0].response.networksolps]);
|
||||||
|
@ -307,7 +308,7 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
||||||
logger.error(logSystem, logComponent, "Error parse RPC call reponse.blocks tp `getmininginfo`." + JSON.stringify(result[0].response));
|
logger.error(logSystem, logComponent, "Error parse RPC call reponse.blocks tp `getmininginfo`." + JSON.stringify(result[0].response));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
daemon.cmd('getnetworkinfo', params,
|
daemon.cmd('getnetworkinfo', params,
|
||||||
function (result) {
|
function (result) {
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
|
@ -335,7 +336,7 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// run coinbase coin transfers every x minutes
|
// run coinbase coin transfers every x minutes
|
||||||
var intervalState = 0; // do not send ZtoT and TtoZ and same time, this results in operation failed!
|
var intervalState = 0; // do not send ZtoT and TtoZ and same time, this results in operation failed!
|
||||||
var interval = poolOptions.walletInterval * 60 * 1000; // run every x minutes
|
var interval = poolOptions.walletInterval * 60 * 1000; // run every x minutes
|
||||||
|
@ -356,7 +357,7 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
||||||
// update network stats using coin daemon
|
// update network stats using coin daemon
|
||||||
cacheNetworkStats();
|
cacheNetworkStats();
|
||||||
}, interval);
|
}, interval);
|
||||||
|
|
||||||
// check operation statuses every x seconds
|
// check operation statuses every x seconds
|
||||||
var opid_interval = poolOptions.walletInterval * 1000;
|
var opid_interval = poolOptions.walletInterval * 1000;
|
||||||
// shielding not required for some equihash coins
|
// shielding not required for some equihash coins
|
||||||
|
@ -438,7 +439,7 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
||||||
|
|
||||||
/* Call redis to get an array of rounds - which are coinbase transactions and block heights from submitted
|
/* Call redis to get an array of rounds - which are coinbase transactions and block heights from submitted
|
||||||
blocks. */
|
blocks. */
|
||||||
function(callback){
|
function(callback){
|
||||||
startRedisTimer();
|
startRedisTimer();
|
||||||
redisClient.multi([
|
redisClient.multi([
|
||||||
['hgetall', coin + ':balances'],
|
['hgetall', coin + ':balances'],
|
||||||
|
@ -470,7 +471,7 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
||||||
callback(null, workers, rounds);
|
callback(null, workers, rounds);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/* Does a batch rpc call to daemon with all the transaction hashes to see if they are confirmed yet.
|
/* Does a batch rpc call to daemon with all the transaction hashes to see if they are confirmed yet.
|
||||||
It also adds the block reward amount to the round object - which the daemon gives also gives us. */
|
It also adds the block reward amount to the round object - which the daemon gives also gives us. */
|
||||||
|
@ -482,11 +483,11 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
||||||
});
|
});
|
||||||
// guarantee a response for batchRPCcommand2
|
// guarantee a response for batchRPCcommand2
|
||||||
batchRPCcommand2.push(['getblockcount']);
|
batchRPCcommand2.push(['getblockcount']);
|
||||||
|
|
||||||
startRPCTimer();
|
startRPCTimer();
|
||||||
daemon.batchCmd(batchRPCcommand2, function(error, blockDetails){
|
daemon.batchCmd(batchRPCcommand2, function(error, blockDetails){
|
||||||
endRPCTimer();
|
endRPCTimer();
|
||||||
|
|
||||||
// error getting block info by hash?
|
// error getting block info by hash?
|
||||||
if (error || !blockDetails){
|
if (error || !blockDetails){
|
||||||
logger.error(logSystem, logComponent, 'Check finished - daemon rpc error with batch getblock '
|
logger.error(logSystem, logComponent, 'Check finished - daemon rpc error with batch getblock '
|
||||||
|
@ -494,35 +495,35 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
||||||
callback(true);
|
callback(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// update confirmations in redis for pending blocks
|
// update confirmations in redis for pending blocks
|
||||||
var confirmsUpdate = blockDetails.map(function(b) {
|
var confirmsUpdate = blockDetails.map(function(b) {
|
||||||
if (b.result != null && b.result.confirmations > 0) {
|
if (b.result != null && b.result.confirmations > 0) {
|
||||||
if (b.result.confirmations > 100) {
|
if (b.result.confirmations > 100) {
|
||||||
return ['hdel', logComponent + ':blocksPendingConfirms', b.result.hash];
|
return ['hdel', logComponent + ':blocksPendingConfirms', b.result.hash];
|
||||||
}
|
}
|
||||||
return ['hset', logComponent + ':blocksPendingConfirms', b.result.hash, b.result.confirmations];
|
return ['hset', logComponent + ':blocksPendingConfirms', b.result.hash, b.result.confirmations];
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
// filter nulls, last item is always null...
|
// filter nulls, last item is always null...
|
||||||
confirmsUpdate = confirmsUpdate.filter(function(val) { return val !== null; });
|
confirmsUpdate = confirmsUpdate.filter(function(val) { return val !== null; });
|
||||||
// guarantee at least one redis update
|
// guarantee at least one redis update
|
||||||
if (confirmsUpdate.length < 1)
|
if (confirmsUpdate.length < 1)
|
||||||
confirmsUpdate.push(['hset', logComponent + ':blocksPendingConfirms', 0, 0]);
|
confirmsUpdate.push(['hset', logComponent + ':blocksPendingConfirms', 0, 0]);
|
||||||
|
|
||||||
startRedisTimer();
|
startRedisTimer();
|
||||||
redisClient.multi(confirmsUpdate).exec(function(error, updated){
|
redisClient.multi(confirmsUpdate).exec(function(error, updated){
|
||||||
endRedisTimer();
|
endRedisTimer();
|
||||||
|
|
||||||
if (error){
|
if (error){
|
||||||
logger.error(logSystem, logComponent, 'failed to update pending block confirmations'
|
logger.error(logSystem, logComponent, 'failed to update pending block confirmations'
|
||||||
+ JSON.stringify(error));
|
+ JSON.stringify(error));
|
||||||
callback(true);
|
callback(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for invalid blocks by block hash
|
// check for invalid blocks by block hash
|
||||||
blockDetails.forEach(function(block, i) {
|
blockDetails.forEach(function(block, i) {
|
||||||
// this is just the response from getblockcount
|
// this is just the response from getblockcount
|
||||||
|
@ -568,35 +569,35 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// now check block transaction ids
|
// now check block transaction ids
|
||||||
var batchRPCcommand = rounds.map(function(r){
|
var batchRPCcommand = rounds.map(function(r){
|
||||||
return ['gettransaction', [r.txHash]];
|
return ['gettransaction', [r.txHash]];
|
||||||
});
|
});
|
||||||
// guarantee a response for batchRPCcommand
|
// guarantee a response for batchRPCcommand
|
||||||
batchRPCcommand.push(['getaccount', [poolOptions.address]]);
|
batchRPCcommand.push(['getaccount', [poolOptions.address]]);
|
||||||
|
|
||||||
startRPCTimer();
|
startRPCTimer();
|
||||||
daemon.batchCmd(batchRPCcommand, function(error, txDetails){
|
daemon.batchCmd(batchRPCcommand, function(error, txDetails){
|
||||||
endRPCTimer();
|
endRPCTimer();
|
||||||
|
|
||||||
if (error || !txDetails){
|
if (error || !txDetails){
|
||||||
logger.error(logSystem, logComponent, 'Check finished - daemon rpc error with batch gettransactions '
|
logger.error(logSystem, logComponent, 'Check finished - daemon rpc error with batch gettransactions '
|
||||||
+ JSON.stringify(error));
|
+ JSON.stringify(error));
|
||||||
callback(true);
|
callback(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var addressAccount = "";
|
var addressAccount = "";
|
||||||
|
|
||||||
// check for transaction errors and generated coins
|
// check for transaction errors and generated coins
|
||||||
txDetails.forEach(function(tx, i){
|
txDetails.forEach(function(tx, i){
|
||||||
|
|
||||||
if (i === txDetails.length - 1){
|
if (i === txDetails.length - 1){
|
||||||
addressAccount = tx.result;
|
addressAccount = tx.result;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var round = rounds[i];
|
var round = rounds[i];
|
||||||
if (tx.error && tx.error.code === -5){
|
if (tx.error && tx.error.code === -5){
|
||||||
logger.warning(logSystem, logComponent, 'Daemon reports invalid transaction: ' + round.txHash);
|
logger.warning(logSystem, logComponent, 'Daemon reports invalid transaction: ' + round.txHash);
|
||||||
|
@ -627,18 +628,12 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
||||||
+ round.txHash);
|
+ round.txHash);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO, estimate transaction fees, make dynamic
|
|
||||||
var fee = 0.00005; // komodo
|
|
||||||
if (logComponent != "komodo") {
|
|
||||||
fee = 0.0004; // all other coins
|
|
||||||
}
|
|
||||||
|
|
||||||
round.category = generationTx.category;
|
round.category = generationTx.category;
|
||||||
if (round.category === 'generate') {
|
if (round.category === 'generate') {
|
||||||
round.reward = balanceRound(generationTx.amount - fee) || balanceRound(generationTx.value - fee); // TODO: Adjust fees to be dynamic
|
round.reward = balanceRound(generationTx.amount - fee) || balanceRound(generationTx.value - fee); // TODO: Adjust fees to be dynamic
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var canDeleteShares = function(r){
|
var canDeleteShares = function(r){
|
||||||
|
@ -653,7 +648,7 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
//Filter out all rounds that are immature (not confirmed or orphaned yet)
|
//Filter out all rounds that are immature (not confirmed or orphaned yet)
|
||||||
rounds = rounds.filter(function(r){
|
rounds = rounds.filter(function(r){
|
||||||
switch (r.category) {
|
switch (r.category) {
|
||||||
|
@ -667,28 +662,24 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO, estimate transaction fees, make dynamic
|
fee = fee * 1e8;
|
||||||
var fee = 500; // komodo
|
|
||||||
if (logComponent != "komodo") {
|
|
||||||
fee = 4000; // all other coins
|
|
||||||
}
|
|
||||||
|
|
||||||
// calculate what the pool owes its miners
|
// calculate what the pool owes its miners
|
||||||
var totalOwed = parseInt(0);
|
var totalOwed = parseInt(0);
|
||||||
for (var i = 0; i < rounds.length; i++) {
|
for (var i = 0; i < rounds.length; i++) {
|
||||||
totalOwed = totalOwed + Math.round(rounds[i].reward * magnitude) - fee; // TODO: make tx fees dynamic
|
totalOwed = totalOwed + Math.round(rounds[i].reward * magnitude) - fee; // TODO: make tx fees dynamic
|
||||||
}
|
}
|
||||||
|
|
||||||
var notAddr = null;
|
var notAddr = null;
|
||||||
if (requireShielding === true) {
|
if (requireShielding === true) {
|
||||||
notAddr = poolOptions.address;
|
notAddr = poolOptions.address;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if we have enough tAddress funds to brgin payment processing
|
// check if we have enough tAddress funds to brgin payment processing
|
||||||
listUnspent(null, notAddr, minConfPayout, false, function (error, tBalance){
|
listUnspent(null, notAddr, minConfPayout, false, function (error, tBalance){
|
||||||
if (error) {
|
if (error) {
|
||||||
logger.error(logSystem, logComponent, 'Error checking pool balance before payouts. (Unable to begin payment process)');
|
logger.error(logSystem, logComponent, 'Error checking pool balance before payouts. (Unable to begin payment process)');
|
||||||
return callback(true);
|
return callback(true);
|
||||||
} else if (tBalance < totalOwed) {
|
} else if (tBalance < totalOwed) {
|
||||||
logger.error(logSystem, logComponent, 'Insufficient pool funds to being payment process; '+(tBalance / magnitude).toFixed(8) + ' < ' + (totalOwed / magnitude).toFixed(8)+'. (Possibly due to pending txs) ');
|
logger.error(logSystem, logComponent, 'Insufficient pool funds to being payment process; '+(tBalance / magnitude).toFixed(8) + ' < ' + (totalOwed / magnitude).toFixed(8)+'. (Possibly due to pending txs) ');
|
||||||
return callback(true);
|
return callback(true);
|
||||||
|
@ -730,7 +721,7 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
||||||
+ round.height + ' blockHash: ' + round.blockHash);
|
+ round.height + ' blockHash: ' + round.blockHash);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (round.category){
|
switch (round.category){
|
||||||
case 'kicked':
|
case 'kicked':
|
||||||
case 'orphan':
|
case 'orphan':
|
||||||
|
@ -813,7 +804,7 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
||||||
worker.sent = 0;
|
worker.sent = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if no payouts...continue to next set of callbacks
|
// if no payouts...continue to next set of callbacks
|
||||||
if (Object.keys(addressAmounts).length === 0){
|
if (Object.keys(addressAmounts).length === 0){
|
||||||
callback(null, workers, rounds);
|
callback(null, workers, rounds);
|
||||||
|
@ -841,7 +832,7 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
||||||
var higherPercent = withholdPercent + 0.01;
|
var higherPercent = withholdPercent + 0.01;
|
||||||
logger.warning(logSystem, logComponent, 'Not enough funds to cover the tx fees for sending out payments, decreasing rewards by '
|
logger.warning(logSystem, logComponent, 'Not enough funds to cover the tx fees for sending out payments, decreasing rewards by '
|
||||||
+ (higherPercent * 100) + '% and retrying');
|
+ (higherPercent * 100) + '% and retrying');
|
||||||
|
|
||||||
trySend(higherPercent);
|
trySend(higherPercent);
|
||||||
}
|
}
|
||||||
else if (result.error && result.error.code === -5) {
|
else if (result.error && result.error.code === -5) {
|
||||||
|
@ -866,24 +857,24 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
// make sure sendmany gives us back a txid
|
// make sure sendmany gives us back a txid
|
||||||
var txid = null;
|
var txid = null;
|
||||||
if (result.response) {
|
if (result.response) {
|
||||||
txid = result.response;
|
txid = result.response;
|
||||||
}
|
}
|
||||||
if (txid != null) {
|
if (txid != null) {
|
||||||
|
|
||||||
// it worked, congrats on your pools payout ;)
|
// it worked, congrats on your pools payout ;)
|
||||||
logger.special(logSystem, logComponent, 'Sent ' + (totalSent / magnitude).toFixed(8)
|
logger.special(logSystem, logComponent, 'Sent ' + (totalSent / magnitude).toFixed(8)
|
||||||
+ ' to ' + Object.keys(addressAmounts).length + ' miners; txid: '+txid);
|
+ ' to ' + Object.keys(addressAmounts).length + ' miners; txid: '+txid);
|
||||||
|
|
||||||
if (withholdPercent > 0) {
|
if (withholdPercent > 0) {
|
||||||
logger.warning(logSystem, logComponent, 'Had to withhold ' + (withholdPercent * 100)
|
logger.warning(logSystem, logComponent, 'Had to withhold ' + (withholdPercent * 100)
|
||||||
+ '% of reward from miners to cover transaction fees. '
|
+ '% of reward from miners to cover transaction fees. '
|
||||||
+ 'Fund pool wallet with coins to prevent this from happening');
|
+ 'Fund pool wallet with coins to prevent this from happening');
|
||||||
}
|
}
|
||||||
|
|
||||||
// save payments data to redis
|
// save payments data to redis
|
||||||
var paymentBlocks = rounds.map(function(r){
|
var paymentBlocks = rounds.map(function(r){
|
||||||
return parseInt(r.height);
|
return parseInt(r.height);
|
||||||
|
@ -899,11 +890,11 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
||||||
}
|
}
|
||||||
callback(null, workers, rounds);
|
callback(null, workers, rounds);
|
||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
clearInterval(paymentInterval);
|
clearInterval(paymentInterval);
|
||||||
|
|
||||||
logger.error(logSystem, logComponent, 'Error RPC sendmany did not return txid '
|
logger.error(logSystem, logComponent, 'Error RPC sendmany did not return txid '
|
||||||
+ JSON.stringify(result) + 'Disabling payment processing to prevent possible double-payouts.');
|
+ JSON.stringify(result) + 'Disabling payment processing to prevent possible double-payouts.');
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue