Skip to content

Commit

Permalink
XMR: <address>.<payment_id> and integrated addresses are acceptable (…
Browse files Browse the repository at this point in the history
…now additional fee)
  • Loading branch information
Кириченко Сергей committed Aug 18, 2017
1 parent d724f60 commit 27fc13c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ Comes with lightweight example front-end script which uses the pool's AJAX API.
* MonetaVerde support not tested since changes for monero fork
* Set fixed difficulty on miner client by passing "address" param with ".[difficulty]" postfix
* Prevent "transaction is too big" error with "payments.maxTransactionAmount" option
* XMR: <address>.<payment_id> and integrated addresses are acceptable (now additional fee).


### Community / Support
Expand Down Expand Up @@ -215,7 +216,7 @@ Explanation for each field:
minerd -u 4AsBy39rpUMTmgTUARGq2bFQWhDhdQNekK5v4uaLU699NPAnx9CubEJ82AkvD5ScoAZNYRwBxybayainhyThHAZWCdKmPYn.5000 */
"fixedDiff": {
"enabled": true,
"separator": ".", // character separator between <address> and <difficulty>
"separator": "+", // character separator between <address> and <difficulty>
},

/* Feature to trust share difficulties from miners which can
Expand Down
2 changes: 1 addition & 1 deletion config_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
},
"fixedDiff": {
"enabled": true,
"addressSeparator": "."
"addressSeparator": "+"
},
"shareTrust": {
"enabled": true,
Expand Down
23 changes: 18 additions & 5 deletions lib/paymentProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ function runInterval(){

for (var worker in payments){
var amount = parseInt(payments[worker]);
var with_payment_id = false;
var addr = worker.split(".");
if((addr.length == 1 && worker.length == 106) || addr.length == 2) {
if(addresses > 0) {
commandIndex++;
addresses = 0;
commandAmount = 0;
}
with_payment_id = true;
}
if(config.payments.maxTransactionAmount && amount + commandAmount > config.payments.maxTransactionAmount) {
amount = config.payments.maxTransactionAmount - commandAmount;
}
Expand All @@ -92,19 +102,22 @@ function runInterval(){
unlock_time: 0
}
};
}
transferCommands[commandIndex].rpc.destinations.push({amount: amount, address: worker});
}

transferCommands[commandIndex].rpc.destinations.push({amount: amount, address: addr[0]});
transferCommands[commandIndex].redis.push(['hincrby', config.coin + ':workers:' + worker, 'balance', -amount]);
transferCommands[commandIndex].redis.push(['hincrby', config.coin + ':workers:' + worker, 'paid', amount]);
transferCommands[commandIndex].amount += amount;
if(addr.length == 2) {
transferCommands[commandIndex].rpc.payment_id = addr[1];
}

addresses++;
commandAmount += amount;
if (addresses >= config.payments.maxAddresses || ( config.payments.maxTransactionAmount && commandAmount >= config.payments.maxTransactionAmount)) {
if (addresses >= config.payments.maxAddresses || (config.payments.maxTransactionAmount && commandAmount >= config.payments.maxTransactionAmount) || with_payment_id) {
commandIndex++;
addresses = 0;
commandAmount = 0;
commandAmount = 0;
}
}

Expand Down
9 changes: 6 additions & 3 deletions lib/pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ var shareTrustMinFloat = shareTrustEnabled ? config.poolServer.shareTrust.min /
var banningEnabled = config.poolServer.banning && config.poolServer.banning.enabled;

var addressBase58Prefix = cnUtil.address_decode(new Buffer(config.poolServer.poolAddress));
var integratedAddressBase58Prefix = addressBase58Prefix + 1; // Monero integraeted address prefixes are address prefix + 1


setInterval(function(){
Expand Down Expand Up @@ -485,8 +486,8 @@ function handleMinerMethod(method, params, ip, portData, sendReply, pushMessage)
var difficulty = portData.difficulty;
var noRetarget = false;
if(config.poolServer.fixedDiff.enabled) {
var fixedDiffCharPos = login.indexOf(config.poolServer.fixedDiff.addressSeparator);
if(fixedDiffCharPos != -1) {
var fixedDiffCharPos = login.lastIndexOf(config.poolServer.fixedDiff.addressSeparator);
if((fixedDiffCharPos != -1) && (login.length - fixedDiffCharPos < 32)) {
noRetarget = true;
difficulty = login.substr(fixedDiffCharPos + 1);
if(difficulty < config.poolServer.varDiff.minDiff) {
Expand All @@ -497,7 +498,9 @@ function handleMinerMethod(method, params, ip, portData, sendReply, pushMessage)
}
}

if (addressBase58Prefix !== cnUtil.address_decode(new Buffer(login))){
var addr = login.split(".");
var addressPrefix = cnUtil.address_decode(new Buffer(addr[0]));
if (addressBase58Prefix !== addressPrefix && integratedAddressBase58Prefix !== addressPrefix){
sendReply('invalid address used for login');
return;
}
Expand Down

0 comments on commit 27fc13c

Please sign in to comment.