Fixed a couple of bugs that were preventing the thing to start in case of POS
This commit is contained in:
parent
863c8bbf5f
commit
4fdd4fcf51
12
lib/pool.js
12
lib/pool.js
@ -81,6 +81,10 @@ var pool = module.exports = function pool(options, authorizeFn){
|
||||
_this.daemon.cmd('submitblock',
|
||||
[blockHex],
|
||||
function(error, result){
|
||||
console.log(JSON.stringify([error,result]));
|
||||
emitLog('submitblock', JSON.stringify([error,result]));
|
||||
|
||||
|
||||
if (error)
|
||||
emitErrorLog('submitblock', 'rpc error when submitting block with submitblock')
|
||||
else
|
||||
@ -92,6 +96,7 @@ var pool = module.exports = function pool(options, authorizeFn){
|
||||
_this.daemon.cmd('getblocktemplate',
|
||||
[{'mode': 'submit', 'data': blockHex}],
|
||||
function(error, result){
|
||||
console.log(error, result);
|
||||
if (error)
|
||||
emitErrorLog('submitblock', 'rpc error when submitting block with getblocktemplate')
|
||||
else
|
||||
@ -182,7 +187,11 @@ var pool = module.exports = function pool(options, authorizeFn){
|
||||
|
||||
emitLog('system','Connected to daemon');
|
||||
options.hasSubmitMethod = results.submitMethod;
|
||||
|
||||
if (options.reward === 'POS' && typeof(results.addressInfo.pubkey) == 'undefined') {
|
||||
// address provided is not of the wallet.
|
||||
emitErrorLog('system', 'The address provided is not from the daemon wallet.');
|
||||
return;
|
||||
} else {
|
||||
publicKeyBuffer = options.reward === 'POW' ?
|
||||
util.script_to_address(results.addressInfo.address) :
|
||||
util.script_to_pubkey(results.addressInfo.pubkey);
|
||||
@ -208,6 +217,7 @@ var pool = module.exports = function pool(options, authorizeFn){
|
||||
StartStratumServer();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}).on('startFailed', function(){
|
||||
|
||||
@ -210,7 +210,7 @@ exports.address_to_pubkeyhash = function(addr){
|
||||
*/
|
||||
exports.script_to_pubkey = function(key){
|
||||
if (key.length === 66) key = new Buffer(key, 'hex');
|
||||
if (key !== 33) throw 'Invalid address';
|
||||
if (key.length !== 33) throw 'Invalid address';
|
||||
var pubkey = new Buffer(35);
|
||||
pubkey[0] = 0x21;
|
||||
pubkey[34] = 0xac;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user