Skip to content

Commit

Permalink
Miner address validation based on pool address
Browse files Browse the repository at this point in the history
  • Loading branch information
fancoder committed Jul 3, 2014
1 parent 57f94fb commit a9d4879
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 11 deletions.
1 change: 0 additions & 1 deletion config_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"enabled": true,
"clusterForks": "auto",
"poolAddress": "48Y4SoUJM5L3YXBEfNQ8bFNsvTNsqcH5Rgq8RF7BwpgvTBj2xr7CmWVanaw7L4U9MnZ4AG7U6Pn1pBhfQhFyFZ1rL1efL8z",
"addressBase58Prefix": 18,
"blockRefreshInterval": 1000,
"minerTimeout": 900,
"ports": [
Expand Down
4 changes: 3 additions & 1 deletion lib/pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ var shareTrustMinFloat = shareTrustEnabled ? config.poolServer.shareTrust.min /

var banningEnabled = config.poolServer.banning && config.poolServer.banning.enabled;

var addressBase58Prefix = cnUtil.address_decode(config.poolServer.poolAddress);


setInterval(function(){
var now = Date.now() / 1000 | 0;
Expand Down Expand Up @@ -440,7 +442,7 @@ function handleMinerMethod(method, params, ip, portData, sendReply, pushMessage)
sendReply('missing login');
return;
}
if (!utils.isValidAddress(params.login, config.poolServer.addressBase58Prefix)){
if (addressBase58Prefix !== cnUtil.address_decode(params.login)){
sendReply('invalid address used for login');
return;
}
Expand Down
9 changes: 0 additions & 9 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,3 @@ exports.ringBuffer = function(maxSize){
exports.varIntEncode = function(n){

};

exports.isValidAddress = function(addr, prefix){
try{
return cnUtil.check_address(new Buffer(addr), prefix);
}
catch(e){
return false;
}
};

0 comments on commit a9d4879

Please sign in to comment.