From d57fd37c24175adf055486a36def66494dda35c2 Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Mon, 18 Dec 2017 15:01:28 +0100 Subject: [PATCH 01/44] Initial --- lib/index.js | 85 ++- package-lock.json | 1249 +++++++++++++++++++++++++++++++++++++++++++++ package.json | 3 +- test.sh | 1 + 4 files changed, 1334 insertions(+), 4 deletions(-) create mode 100644 package-lock.json create mode 100644 test.sh diff --git a/lib/index.js b/lib/index.js index a0871af..bd41ba0 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,16 +1,95 @@ var net = require('net'); var events = require('events'); +var zmq = require('zeromq'); -//Gives us global access to everything we need for each hashing algorithm require('./algoProperties.js'); - var pool = require('./pool.js'); exports.daemon = require('./daemon.js'); exports.varDiff = require('./varDiff.js'); +// validate args +if(process.argv.length < 3) { + console.log("Error: Config file argument required. Good bye .."); + process.exit(1); +} -exports.createPool = function (poolOptions, authorizeFn) { +var createPool = function (poolOptions, authorizeFn) { var newPool = new pool(poolOptions, authorizeFn); return newPool; }; + +// load config +var config = require(process.argv[2]); + +// create pool +var pool = createPool(config, function (ip, port, workerName, password, callback) { //stratum authorization function + console.log("Authorize " + workerName + ":" + password + "@" + ip); + + var minerWorker = workerName.split("."); + var miner = minerWorker[0].trim(); + var worker = minerWorker.length > 1 ? minerWorker[1].trim() : ""; + + pool.daemon.cmd('validateaddress', [miner], function (results) { + var authResult = {}; + + authResult.authorized = results.filter(function (r) { + return r.response.isvalid + }).length > 0; + + authResult.disconnect = !authResult.authorized; + + callback(authResult); + }); +}); + +pool.on('log', function (severity, logText) { + console.log(severity + ': ' + logText); +}); + +// connect to publisher socket +var sock = zmq.socket('pub'); +sock.bindSync(config.publisherSocket); +pool.emitInfoLog('Connected to ZMQ socket ' + config.publisherSocket); + +// monitor shares +pool.on('share', function (isValidShare, isValidBlock, data) { + if (isValidBlock) + pool.emitInfoLog('Pool ' + config.publisherTopic + ' found block ' + data.height); + // else if (isValidShare) + // pool.emitInfoLog('Valid share submitted'); + else if (data.blockHash) + pool.emitInfoLog('We thought a block was found but it was rejected by the daemon'); + else + pool.emitInfoLog('Invalid share submitted') + + if(isValidShare) { + var minerWorker = data.worker.split("."); + + // sanitize inputs + var miner = minerWorker[0].trim(); + var worker = minerWorker.length > 1 ? minerWorker[1].trim() : ""; + + // transform it + var share = { + difficulty: data.difficulty, + networkDifficulty: data.blockDiff, + blockHeight: data.height, + blockReward: data.blockReward / 100000000, + miner: miner, + worker: worker, + ipAddress: data.ip, + isBlockCandidate: isValidBlock, + blockHex: data.blockHex, + blockHash: data.blockHash, + transactionConfirmationData: data.txHash, + userAgent: '', + payoutInfo: '' // monero only + }; + + // publish + sock.send([config.publisherTopic, JSON.stringify(share)]); + } +}); + +pool.start(); diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..b829426 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,1249 @@ +{ + "name": "stratum-pool", + "version": "0.1.6", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "abbrev": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==" + }, + "ajv": { + "version": "4.11.8", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", + "integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=", + "requires": { + "co": "4.6.0", + "json-stable-stringify": "1.0.1" + } + }, + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + }, + "aproba": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", + "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==" + }, + "are-we-there-yet": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.4.tgz", + "integrity": "sha1-u13KOCu5TwXhUZQ3PRb9O6HKEQ0=", + "requires": { + "delegates": "1.0.0", + "readable-stream": "2.3.3" + } + }, + "asap": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", + "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=" + }, + "asn1": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", + "integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y=" + }, + "assert-plus": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz", + "integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ=" + }, + "async": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.0.tgz", + "integrity": "sha512-xAfGg1/NTLBBKlHFmnd7PlmUW9KhVQIUuSrYem9xzFUZy13ScvtyGGejaae9iAVRiRq9+Cx7DPFaAAhCpyxyPw==", + "requires": { + "lodash": "4.17.4" + } + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + }, + "aws-sign2": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", + "integrity": "sha1-FDQt0428yU0OW4fXY81jYSwOeU8=" + }, + "aws4": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.6.0.tgz", + "integrity": "sha1-g+9cqGCysy5KDe7e6MdxudtXRx4=" + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, + "base-x": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.3.tgz", + "integrity": "sha512-qKXPTB94LxXhJs8hqwTdyVTiDXMFTRUFj5F7FnWOW19ALCfANf2lHHUnEcY43g3DaVi4X8E2oDCkHIN8bjr32Q==", + "requires": { + "safe-buffer": "5.1.1" + } + }, + "base58-native": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/base58-native/-/base58-native-0.1.4.tgz", + "integrity": "sha1-u5I0qN8mYtBLC3Fa7uH4mxX+8TQ=", + "requires": { + "bignum": "0.12.5" + } + }, + "bcrypt-pbkdf": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz", + "integrity": "sha1-Y7xdy2EzG5K8Bf1SiVPDNGKgb40=", + "optional": true, + "requires": { + "tweetnacl": "0.14.5" + } + }, + "bigi": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/bigi/-/bigi-1.4.2.tgz", + "integrity": "sha1-nGZalfiLiwj8Bc/XMfVhhZ1yWCU=" + }, + "bignum": { + "version": "0.12.5", + "resolved": "https://registry.npmjs.org/bignum/-/bignum-0.12.5.tgz", + "integrity": "sha1-II8rDhjrj9aVCRfjcY5M2FzM/80=", + "requires": { + "nan": "2.8.0", + "node-pre-gyp": "0.6.39" + } + }, + "bindings": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.3.0.tgz", + "integrity": "sha512-DpLh5EzMR2kzvX1KIlVC0VkC3iZtHKTgdtZ0a3pglBZdaQFjt5S9g9xd1lE+YvXyfd6mtCeRnrUfOLYiTMlNSw==" + }, + "bip66": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/bip66/-/bip66-1.1.5.tgz", + "integrity": "sha1-AfqHSHhcpwlV1QESF9GzE5lpyiI=", + "requires": { + "safe-buffer": "5.1.1" + } + }, + "bitcoin-ops": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/bitcoin-ops/-/bitcoin-ops-1.4.0.tgz", + "integrity": "sha512-hSbFP1t/hRCdTWXoSUarhwySo8g1UqIjopXNaJAf+Gi6rTzWmPEKG1khXbNIPeHLskonR1Lq09KPyu37l+7zGQ==" + }, + "bitcoinjs-lib-zcash": { + "version": "git+https://github.com/runn1ng/bitcoinjs-lib.git#e128e36171d52870312adde4321089bcdbce46fd", + "requires": { + "bigi": "1.4.2", + "bip66": "1.1.5", + "bitcoin-ops": "1.4.0", + "bs58check": "2.1.1", + "create-hash": "1.1.3", + "create-hmac": "1.1.6", + "ecurve": "1.0.6", + "merkle-lib": "1.0.0", + "pushdata-bitcoin": "1.0.1", + "randombytes": "2.0.5", + "typeforce": "1.12.0", + "varuint-bitcoin": "1.0.4", + "wif": "2.0.6" + } + }, + "bl": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.1.tgz", + "integrity": "sha1-ysMo977kVzDUBLaSID/LWQ4XLV4=", + "requires": { + "readable-stream": "2.3.3" + } + }, + "block-stream": { + "version": "0.0.9", + "resolved": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz", + "integrity": "sha1-E+v+d4oDIFz+A3UUgeu0szAMEmo=", + "requires": { + "inherits": "2.0.3" + } + }, + "boom": { + "version": "2.10.1", + "resolved": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz", + "integrity": "sha1-OciRjO/1eZ+D+UkqhI9iWt0Mdm8=", + "requires": { + "hoek": "2.16.3" + } + }, + "brace-expansion": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", + "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", + "requires": { + "balanced-match": "1.0.0", + "concat-map": "0.0.1" + } + }, + "bs58": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz", + "integrity": "sha1-vhYedsNU9veIrkBx9j806MTwpCo=", + "requires": { + "base-x": "3.0.3" + } + }, + "bs58check": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/bs58check/-/bs58check-2.1.1.tgz", + "integrity": "sha512-okRQiWc5FJuA2VOwQ1hB7Sf0MyEFg/EwRN12h4b8HrJoGkZ3xq1CGjkaAfYloLcZyqixQnO5mhPpN6IcHSplVg==", + "requires": { + "bs58": "4.0.1", + "create-hash": "1.1.3" + } + }, + "caseless": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" + }, + "chownr": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.0.1.tgz", + "integrity": "sha1-4qdQQqlVGQi+vSW4Uj1fl2nXkYE=" + }, + "cipher-base": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz", + "integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==", + "requires": { + "inherits": "2.0.3", + "safe-buffer": "5.1.1" + } + }, + "co": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", + "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=" + }, + "code-point-at": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" + }, + "combined-stream": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", + "integrity": "sha1-k4NwpXtKUd6ix3wV1cX9+JUWQAk=", + "requires": { + "delayed-stream": "1.0.0" + } + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "console-control-strings": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", + "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=" + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" + }, + "create-hash": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.1.3.tgz", + "integrity": "sha1-YGBCrIuSYnUPSDyt2rD1gZFy2P0=", + "requires": { + "cipher-base": "1.0.4", + "inherits": "2.0.3", + "ripemd160": "2.0.1", + "sha.js": "2.4.9" + } + }, + "create-hmac": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.6.tgz", + "integrity": "sha1-rLniIaThe9sHbpBlfEK5PjcmzwY=", + "requires": { + "cipher-base": "1.0.4", + "create-hash": "1.1.3", + "inherits": "2.0.3", + "ripemd160": "2.0.1", + "safe-buffer": "5.1.1", + "sha.js": "2.4.9" + } + }, + "cryptiles": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz", + "integrity": "sha1-O9/s3GCBR8HGcgL6KR59ylnqo7g=", + "requires": { + "boom": "2.10.1" + } + }, + "dashdash": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", + "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", + "requires": { + "assert-plus": "1.0.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" + } + } + }, + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, + "deep-extend": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.4.2.tgz", + "integrity": "sha1-SLaZwn4zS/ifEIkr5DL25MfTSn8=" + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + }, + "delegates": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", + "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=" + }, + "detect-libc": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", + "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=" + }, + "ecc-jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz", + "integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=", + "optional": true, + "requires": { + "jsbn": "0.1.1" + } + }, + "ecurve": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/ecurve/-/ecurve-1.0.6.tgz", + "integrity": "sha512-/BzEjNfiSuB7jIWKcS/z8FK9jNjmEWvUV2YZ4RLSmcDtP7Lq0m6FvDuSnJpBlDpGRpfRQeTLGLBI8H+kEv0r+w==", + "requires": { + "bigi": "1.4.2", + "safe-buffer": "5.1.1" + } + }, + "end-of-stream": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.0.tgz", + "integrity": "sha1-epDYM+/abPpurA9JSduw+tOmMgY=", + "requires": { + "once": "1.4.0" + } + }, + "equihashverify": { + "version": "git+https://github.com/joshuayabut/equihashverify.git#6e4dca3266018640da8e5a4830d2cc4769389577", + "requires": { + "bindings": "1.3.0", + "nan": "2.8.0", + "node-gyp": "3.6.2" + } + }, + "expand-template": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-1.1.0.tgz", + "integrity": "sha512-kkjwkMqj0h4w/sb32ERCDxCQkREMCAgS39DscDnSwDsbxnwwM1BTZySdC3Bn1lhY7vL08n9GoO/fVTynjDgRyQ==" + }, + "extend": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz", + "integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=" + }, + "extsprintf": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", + "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" + }, + "forever-agent": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", + "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=" + }, + "form-data": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.1.4.tgz", + "integrity": "sha1-M8GDrPGTJ27KqYFDpp6Uv+4XUNE=", + "requires": { + "asynckit": "0.4.0", + "combined-stream": "1.0.5", + "mime-types": "2.1.17" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "fstream": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.11.tgz", + "integrity": "sha1-XB+x8RdHcRTwYyoOtLcbPLD9MXE=", + "requires": { + "graceful-fs": "4.1.11", + "inherits": "2.0.3", + "mkdirp": "0.5.1", + "rimraf": "2.6.2" + } + }, + "fstream-ignore": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/fstream-ignore/-/fstream-ignore-1.0.5.tgz", + "integrity": "sha1-nDHa40dnAY/h0kmyTa2mfQktoQU=", + "requires": { + "fstream": "1.0.11", + "inherits": "2.0.3", + "minimatch": "3.0.4" + } + }, + "gauge": { + "version": "2.7.4", + "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", + "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", + "requires": { + "aproba": "1.2.0", + "console-control-strings": "1.1.0", + "has-unicode": "2.0.1", + "object-assign": "4.1.1", + "signal-exit": "3.0.2", + "string-width": "1.0.2", + "strip-ansi": "3.0.1", + "wide-align": "1.1.2" + } + }, + "getpass": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", + "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", + "requires": { + "assert-plus": "1.0.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" + } + } + }, + "github-from-package": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz", + "integrity": "sha1-l/tdlr/eiXMxPyDoKI75oWf6ZM4=" + }, + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + }, + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=" + }, + "har-schema": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-1.0.5.tgz", + "integrity": "sha1-0mMTX0MwfALGAq/I/pWXDAFRNp4=" + }, + "har-validator": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-4.2.1.tgz", + "integrity": "sha1-M0gdDxu/9gDdID11gSpqX7oALio=", + "requires": { + "ajv": "4.11.8", + "har-schema": "1.0.5" + } + }, + "has-unicode": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", + "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=" + }, + "hash-base": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-2.0.2.tgz", + "integrity": "sha1-ZuodhW206KVHDK32/OI65SRO8uE=", + "requires": { + "inherits": "2.0.3" + } + }, + "hawk": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz", + "integrity": "sha1-B4REvXwWQLD+VA0sm3PVlnjo4cQ=", + "requires": { + "boom": "2.10.1", + "cryptiles": "2.0.5", + "hoek": "2.16.3", + "sntp": "1.0.9" + } + }, + "hoek": { + "version": "2.16.3", + "resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz", + "integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0=" + }, + "http-signature": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz", + "integrity": "sha1-33LiZwZs0Kxn+3at+OE0qPvPkb8=", + "requires": { + "assert-plus": "0.2.0", + "jsprim": "1.4.1", + "sshpk": "1.13.1" + } + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "1.4.0", + "wrappy": "1.0.2" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "ini": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==" + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "requires": { + "number-is-nan": "1.0.1" + } + }, + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" + }, + "isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" + }, + "jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", + "optional": true + }, + "json-schema": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", + "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" + }, + "json-stable-stringify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", + "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", + "requires": { + "jsonify": "0.0.0" + } + }, + "json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" + }, + "jsonify": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", + "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=" + }, + "jsprim": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", + "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.3.0", + "json-schema": "0.2.3", + "verror": "1.10.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" + } + } + }, + "lodash": { + "version": "4.17.4", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", + "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=" + }, + "merkle-bitcoin": { + "version": "git+https://github.com/joshuayabut/merkle-bitcoin.git#ec00ae20ba60d444e150ead03c747695ddaa83a1", + "requires": { + "async": "1.5.2" + }, + "dependencies": { + "async": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", + "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=" + } + } + }, + "merkle-lib": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/merkle-lib/-/merkle-lib-1.0.0.tgz", + "integrity": "sha1-vQiLLHsQJjORA6DzQprgkCLPslw=" + }, + "mime-db": { + "version": "1.30.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.30.0.tgz", + "integrity": "sha1-dMZD2i3Z1qRTmZY0ZbJtXKfXHwE=" + }, + "mime-types": { + "version": "2.1.17", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.17.tgz", + "integrity": "sha1-Cdejk/A+mVp5+K+Fe3Cp4KsWVXo=", + "requires": { + "mime-db": "1.30.0" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "1.1.8" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "requires": { + "minimist": "0.0.8" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "nan": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.8.0.tgz", + "integrity": "sha1-7XFfP+neArV6XmJS2QqWZ14fCFo=" + }, + "node-abi": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.1.2.tgz", + "integrity": "sha512-hmUtb8m75RSi7N+zZLYqe75XDvZB+6LyTBPkj2DConvNgQet2e3BIqEwe1LLvqMrfyjabuT5ZOrTioLCH1HTdA==", + "requires": { + "semver": "5.4.1" + } + }, + "node-gyp": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-3.6.2.tgz", + "integrity": "sha1-m/vlRWIoYoSDjnUOrAUpWFP6HGA=", + "requires": { + "fstream": "1.0.11", + "glob": "7.1.2", + "graceful-fs": "4.1.11", + "minimatch": "3.0.4", + "mkdirp": "0.5.1", + "nopt": "3.0.6", + "npmlog": "4.1.2", + "osenv": "0.1.4", + "request": "2.81.0", + "rimraf": "2.6.2", + "semver": "5.3.0", + "tar": "2.2.1", + "which": "1.3.0" + }, + "dependencies": { + "nopt": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", + "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", + "requires": { + "abbrev": "1.1.1" + } + }, + "semver": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz", + "integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=" + } + } + }, + "node-pre-gyp": { + "version": "0.6.39", + "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.6.39.tgz", + "integrity": "sha512-OsJV74qxnvz/AMGgcfZoDaeDXKD3oY3QVIbBmwszTFkRisTSXbMQyn4UWzUMOtA5SVhrBZOTp0wcoSBgfMfMmQ==", + "requires": { + "detect-libc": "1.0.3", + "hawk": "3.1.3", + "mkdirp": "0.5.1", + "nopt": "4.0.1", + "npmlog": "4.1.2", + "rc": "1.2.2", + "request": "2.81.0", + "rimraf": "2.6.2", + "semver": "5.4.1", + "tar": "2.2.1", + "tar-pack": "3.4.1" + } + }, + "noop-logger": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/noop-logger/-/noop-logger-0.1.1.tgz", + "integrity": "sha1-lKKxYzxPExdVMAfYlm/Q6EG2pMI=" + }, + "nopt": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz", + "integrity": "sha1-0NRoWv1UFRk8jHUFYC0NF81kR00=", + "requires": { + "abbrev": "1.1.1", + "osenv": "0.1.4" + } + }, + "npmlog": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", + "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", + "requires": { + "are-we-there-yet": "1.1.4", + "console-control-strings": "1.1.0", + "gauge": "2.7.4", + "set-blocking": "2.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" + }, + "oauth-sign": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", + "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=" + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1.0.2" + } + }, + "os-homedir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=" + }, + "os-tmpdir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=" + }, + "osenv": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.4.tgz", + "integrity": "sha1-Qv5tWVPfBsgGS+bxdsPQWqqjRkQ=", + "requires": { + "os-homedir": "1.0.2", + "os-tmpdir": "1.0.2" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "performance-now": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-0.2.0.tgz", + "integrity": "sha1-M+8wxcd9TqIcWlOGnZG1bY8lVeU=" + }, + "prebuild-install": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-2.4.1.tgz", + "integrity": "sha512-99TyEFYTTkBWANT+mwSptmLb9ZCLQ6qKIUE36fXSIOtShB0JNprL2hzBD8F1yIuT9btjFrFEwbRHXhqDi1HmRA==", + "requires": { + "expand-template": "1.1.0", + "github-from-package": "0.0.0", + "minimist": "1.2.0", + "mkdirp": "0.5.1", + "node-abi": "2.1.2", + "noop-logger": "0.1.1", + "npmlog": "4.1.2", + "os-homedir": "1.0.2", + "pump": "1.0.3", + "rc": "1.2.2", + "simple-get": "1.4.3", + "tar-fs": "1.16.0", + "tunnel-agent": "0.6.0", + "xtend": "4.0.1" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + } + } + }, + "process-nextick-args": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", + "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=" + }, + "promise": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/promise/-/promise-8.0.1.tgz", + "integrity": "sha1-5F1osAoXZHttpxG/he1u1HII9FA=", + "requires": { + "asap": "2.0.6" + } + }, + "pump": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/pump/-/pump-1.0.3.tgz", + "integrity": "sha512-8k0JupWme55+9tCVE+FS5ULT3K6AbgqrGa58lTT49RpyfwwcGedHqaC5LlQNdEAumn/wFsu6aPwkuPMioy8kqw==", + "requires": { + "end-of-stream": "1.4.0", + "once": "1.4.0" + } + }, + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" + }, + "pushdata-bitcoin": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/pushdata-bitcoin/-/pushdata-bitcoin-1.0.1.tgz", + "integrity": "sha1-FZMdPNlnreUiBvUjqnMxrvfUOvc=", + "requires": { + "bitcoin-ops": "1.4.0" + } + }, + "qs": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.4.0.tgz", + "integrity": "sha1-E+JtKK1rD/qpExLNO/cI7TUecjM=" + }, + "randombytes": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.5.tgz", + "integrity": "sha512-8T7Zn1AhMsQ/HI1SjcCfT/t4ii3eAqco3yOcSzS4mozsOz69lHLsoMXmF9nZgnFanYscnSlUSgs8uZyKzpE6kg==", + "requires": { + "safe-buffer": "5.1.1" + } + }, + "rc": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.2.tgz", + "integrity": "sha1-2M6ctX6NZNnHut2YdsfDTL48cHc=", + "requires": { + "deep-extend": "0.4.2", + "ini": "1.3.5", + "minimist": "1.2.0", + "strip-json-comments": "2.0.1" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + } + } + }, + "readable-stream": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", + "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "safe-buffer": "5.1.1", + "string_decoder": "1.0.3", + "util-deprecate": "1.0.2" + } + }, + "request": { + "version": "2.81.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.81.0.tgz", + "integrity": "sha1-xpKJRqDgbF+Nb4qTM0af/aRimKA=", + "requires": { + "aws-sign2": "0.6.0", + "aws4": "1.6.0", + "caseless": "0.12.0", + "combined-stream": "1.0.5", + "extend": "3.0.1", + "forever-agent": "0.6.1", + "form-data": "2.1.4", + "har-validator": "4.2.1", + "hawk": "3.1.3", + "http-signature": "1.1.1", + "is-typedarray": "1.0.0", + "isstream": "0.1.2", + "json-stringify-safe": "5.0.1", + "mime-types": "2.1.17", + "oauth-sign": "0.8.2", + "performance-now": "0.2.0", + "qs": "6.4.0", + "safe-buffer": "5.1.1", + "stringstream": "0.0.5", + "tough-cookie": "2.3.3", + "tunnel-agent": "0.6.0", + "uuid": "3.1.0" + } + }, + "rimraf": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", + "requires": { + "glob": "7.1.2" + } + }, + "ripemd160": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.1.tgz", + "integrity": "sha1-D0WEKVxTo2KK9+bXmsohzlfRxuc=", + "requires": { + "hash-base": "2.0.2", + "inherits": "2.0.3" + } + }, + "safe-buffer": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" + }, + "semver": { + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.4.1.tgz", + "integrity": "sha512-WfG/X9+oATh81XtllIo/I8gOiY9EXRdv1cQdyykeXK17YcUW3EXUAi2To4pcH6nZtJPr7ZOpM5OMyWJZm+8Rsg==" + }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" + }, + "sha.js": { + "version": "2.4.9", + "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.9.tgz", + "integrity": "sha512-G8zektVqbiPHrylgew9Zg1VRB1L/DtXNUVAM6q4QLy8NE3qtHlFXTf8VLL4k1Yl6c7NMjtZUTdXV+X44nFaT6A==", + "requires": { + "inherits": "2.0.3", + "safe-buffer": "5.1.1" + } + }, + "signal-exit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" + }, + "simple-get": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-1.4.3.tgz", + "integrity": "sha1-6XVe2kB+ltpAxeUVjJ6jezO+y+s=", + "requires": { + "once": "1.4.0", + "unzip-response": "1.0.2", + "xtend": "4.0.1" + } + }, + "sntp": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz", + "integrity": "sha1-ZUEYTMkK7qbG57NeJlkIJEPGYZg=", + "requires": { + "hoek": "2.16.3" + } + }, + "sshpk": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.13.1.tgz", + "integrity": "sha1-US322mKHFEMW3EwY/hzx2UBzm+M=", + "requires": { + "asn1": "0.2.3", + "assert-plus": "1.0.0", + "bcrypt-pbkdf": "1.0.1", + "dashdash": "1.14.1", + "ecc-jsbn": "0.1.1", + "getpass": "0.1.7", + "jsbn": "0.1.1", + "tweetnacl": "0.14.5" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" + } + } + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "requires": { + "code-point-at": "1.1.0", + "is-fullwidth-code-point": "1.0.0", + "strip-ansi": "3.0.1" + } + }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "requires": { + "safe-buffer": "5.1.1" + } + }, + "stringstream": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", + "integrity": "sha1-TkhM1N5aC7vuGORjB3EKioFiGHg=" + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "requires": { + "ansi-regex": "2.1.1" + } + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" + }, + "tar": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/tar/-/tar-2.2.1.tgz", + "integrity": "sha1-jk0qJWwOIYXGsYrWlK7JaLg8sdE=", + "requires": { + "block-stream": "0.0.9", + "fstream": "1.0.11", + "inherits": "2.0.3" + } + }, + "tar-fs": { + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-1.16.0.tgz", + "integrity": "sha512-I9rb6v7mjWLtOfCau9eH5L7sLJyU2BnxtEZRQ5Mt+eRKmf1F0ohXmT/Jc3fr52kDvjJ/HV5MH3soQfPL5bQ0Yg==", + "requires": { + "chownr": "1.0.1", + "mkdirp": "0.5.1", + "pump": "1.0.3", + "tar-stream": "1.5.5" + } + }, + "tar-pack": { + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/tar-pack/-/tar-pack-3.4.1.tgz", + "integrity": "sha512-PPRybI9+jM5tjtCbN2cxmmRU7YmqT3Zv/UDy48tAh2XRkLa9bAORtSWLkVc13+GJF+cdTh1yEnHEk3cpTaL5Kg==", + "requires": { + "debug": "2.6.9", + "fstream": "1.0.11", + "fstream-ignore": "1.0.5", + "once": "1.4.0", + "readable-stream": "2.3.3", + "rimraf": "2.6.2", + "tar": "2.2.1", + "uid-number": "0.0.6" + } + }, + "tar-stream": { + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-1.5.5.tgz", + "integrity": "sha512-mQdgLPc/Vjfr3VWqWbfxW8yQNiJCbAZ+Gf6GDu1Cy0bdb33ofyiNGBtAY96jHFhDuivCwgW1H9DgTON+INiXgg==", + "requires": { + "bl": "1.2.1", + "end-of-stream": "1.4.0", + "readable-stream": "2.3.3", + "xtend": "4.0.1" + } + }, + "tough-cookie": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.3.tgz", + "integrity": "sha1-C2GKVWW23qkL80JdBNVe3EdadWE=", + "requires": { + "punycode": "1.4.1" + } + }, + "tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "requires": { + "safe-buffer": "5.1.1" + } + }, + "tweetnacl": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", + "optional": true + }, + "typeforce": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/typeforce/-/typeforce-1.12.0.tgz", + "integrity": "sha512-fvnkvueAOFLhtAqDgIA/wMP21SMwS/NQESFKZuwVrj5m/Ew6eK2S0z0iB++cwtROPWDOhaT6OUfla8UwMw4Adg==" + }, + "uid-number": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/uid-number/-/uid-number-0.0.6.tgz", + "integrity": "sha1-DqEOgDXo61uOREnwbaHHMGY7qoE=" + }, + "unzip-response": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/unzip-response/-/unzip-response-1.0.2.tgz", + "integrity": "sha1-uYTwh3/AqJwsdzzB73tbIytbBv4=" + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + }, + "uuid": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz", + "integrity": "sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==" + }, + "varuint-bitcoin": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/varuint-bitcoin/-/varuint-bitcoin-1.0.4.tgz", + "integrity": "sha1-2BLF2uFuMvYFRLat7h1L4TB9AoM=" + }, + "verror": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", + "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", + "requires": { + "assert-plus": "1.0.0", + "core-util-is": "1.0.2", + "extsprintf": "1.3.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" + } + } + }, + "which": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", + "requires": { + "isexe": "2.0.0" + } + }, + "wide-align": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.2.tgz", + "integrity": "sha512-ijDLlyQ7s6x1JgCLur53osjm/UXUYD9+0PbYKrBsYisYXzCxN+HC3mYDNy/dWdmf3AwqwU3CXwDCvsNgGK1S0w==", + "requires": { + "string-width": "1.0.2" + } + }, + "wif": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/wif/-/wif-2.0.6.tgz", + "integrity": "sha1-CNP1IFbGZnkplyb63g1DKudLRwQ=", + "requires": { + "bs58check": "2.1.1" + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=" + }, + "zeromq": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/zeromq/-/zeromq-4.6.0.tgz", + "integrity": "sha512-sU7pQqQj7f/C6orJZAXls+NEKaVMZZtnZqpMPTq5d5dP78CmdC0g15XIviFAN6poPuKl9qlGt74vipOUUuNeWg==", + "requires": { + "nan": "2.8.0", + "prebuild-install": "2.4.1" + } + } + } +} diff --git a/package.json b/package.json index d91c70f..8660223 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,8 @@ "async": "*", "merkle-bitcoin": "git+https://github.com/joshuayabut/merkle-bitcoin.git", "bitcoinjs-lib-zcash": "git+https://github.com/runn1ng/bitcoinjs-lib.git#zcash", - "promise": "*" + "promise": "*", + "zeromq": "^4.6.0" }, "engines": { "node": ">=7" diff --git a/test.sh b/test.sh new file mode 100644 index 0000000..2d05ed6 --- /dev/null +++ b/test.sh @@ -0,0 +1 @@ +node --inspect-brk lib/index.js $1 From 8282c75e085be42940bb3052101d89773e0e8a0f Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Mon, 18 Dec 2017 15:28:28 +0100 Subject: [PATCH 02/44] Add missing logging proxy funcs --- lib/pool.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index d518f3f..a2b6736 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -34,13 +34,17 @@ var pool = module.exports = function pool(options, authorizeFn) { _this.emit('log', 'special', text); }; + this.emitLog = emitLog; + this.emitInfoLog = emitInfoLog; + this.emitWarningLog = emitWarningLog; + this.emitErrorLog = emitErrorLog; + this.emitSpecialLog = emitSpecialLog; if (!(options.coin.algorithm in algos)) { emitErrorLog('The ' + options.coin.algorithm + ' hashing algorithm is not supported.'); throw new Error(); } - this.start = function () { SetupVarDiff(); SetupApi(); From 50dadc8093a347dcefc1339b627d6362f1ed0422 Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Mon, 18 Dec 2017 15:29:51 +0100 Subject: [PATCH 03/44] WIP --- lib/pool.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index a2b6736..771fe75 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -24,6 +24,9 @@ var pool = module.exports = function pool(options, authorizeFn) { var emitLog = function (text) { _this.emit('log', 'debug', text); }; + var emitInfoLog = function (text) { + _this.emit('log', 'info', text); + }; var emitWarningLog = function (text) { _this.emit('log', 'warning', text); }; From b34da76c7c79e3a23578ea03e823073e78931c20 Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Mon, 18 Dec 2017 19:14:43 +0100 Subject: [PATCH 04/44] vscode --- .vscode/launch.json | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..41fb68e --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,16 @@ +{ + // Use IntelliSense to learn about possible Node.js debug attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Attach", + "type": "node", + "request": "attach", + "port": 9229, + "outFiles": [], + "localRoot": "${workspaceRoot}", + "remoteRoot": "/mnt/c/Users/${env:USERNAME}/Projects/${workspaceRootFolderName}/" + }] +} From 45237a6998d3496e530c90d73cd97810ae7c89a2 Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Thu, 21 Dec 2017 13:03:09 +0100 Subject: [PATCH 05/44] Fixed logging --- .gitignore | 4 +++- lib/index.js | 2 +- test.sh | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index d35bbf7..e9e4da5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ node_modules/ -.idea/ \ No newline at end of file +.idea/ +/.vscode/last.sql +/.vscode/temp.sql diff --git a/lib/index.js b/lib/index.js index bd41ba0..51351cf 100644 --- a/lib/index.js +++ b/lib/index.js @@ -60,7 +60,7 @@ pool.on('share', function (isValidShare, isValidBlock, data) { // pool.emitInfoLog('Valid share submitted'); else if (data.blockHash) pool.emitInfoLog('We thought a block was found but it was rejected by the daemon'); - else + else if(!isValidShare) pool.emitInfoLog('Invalid share submitted') if(isValidShare) { diff --git a/test.sh b/test.sh index 2d05ed6..dd1175a 100644 --- a/test.sh +++ b/test.sh @@ -1 +1 @@ -node --inspect-brk lib/index.js $1 +LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./node_modules/equihashverify/build/Release node --inspect-brk lib/index.js $1 From ea2a8801437b5fadae38c0d673ecf0657cee4233 Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Thu, 21 Dec 2017 15:01:45 +0100 Subject: [PATCH 06/44] Fix blockReward --- lib/blockTemplate.js | 8 ++++---- lib/jobManager.js | 4 ++-- lib/transactions.js | 24 +++++++++++++++++------- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/lib/blockTemplate.js b/lib/blockTemplate.js index 7c1f8db..e316596 100644 --- a/lib/blockTemplate.js +++ b/lib/blockTemplate.js @@ -31,7 +31,7 @@ var BlockTemplate = module.exports = function BlockTemplate(jobId, rpcData, extr blockReward = (this.rpcData.miner + this.rpcData.founders) * 100000000; } } - + var fees = []; rpcData.transactions.forEach(function(value) { fees.push(value); @@ -40,7 +40,7 @@ var BlockTemplate = module.exports = function BlockTemplate(jobId, rpcData, extr rpcData.rewardFees = this.rewardFees; if (typeof this.genTx === 'undefined') { - this.genTx = transactions.createGeneration(rpcData.height, blockReward, this.rewardFees, recipients, poolAddress, payFoundersReward, percentFoundersReward, maxFoundersRewardBlockHeight, foundersRewardAddressChangeInterval, vFoundersRewardAddress, percentTreasuryReward, treasuryRewardStartBlockHeight, treasuryRewardAddressChangeInterval, vTreasuryRewardAddress).toString('hex'); + this.genTx = transactions.createGeneration(rpcData, blockReward, this.rewardFees, recipients, poolAddress, payFoundersReward, percentFoundersReward, maxFoundersRewardBlockHeight, foundersRewardAddressChangeInterval, vFoundersRewardAddress, percentTreasuryReward, treasuryRewardStartBlockHeight, treasuryRewardAddressChangeInterval, vTreasuryRewardAddress).toString('hex'); this.genTxHash = transactions.txHash(); /* @@ -87,14 +87,14 @@ var BlockTemplate = module.exports = function BlockTemplate(jobId, rpcData, extr if (Math.abs(txCount.length % 2) == 1) { txCount = "0" + txCount; } - + if (this.txCount <= 0x7f){ var varInt = new Buffer(txCount, 'hex'); } else if (this.txCount <= 0x7fff){ var varInt = new Buffer.concat([Buffer('FD', 'hex'), new Buffer(txCount, 'hex')]); } - + buf = new Buffer.concat([ header, soln, diff --git a/lib/jobManager.js b/lib/jobManager.js index edf91c4..ad1b248 100644 --- a/lib/jobManager.js +++ b/lib/jobManager.js @@ -212,7 +212,7 @@ var JobManager = module.exports = function JobManager(options) { if (soln.length !== 2694) { return shareError([20, 'incorrect size of solution']); } - + if (!isHexString(extraNonce2)) { return shareError([20, 'invalid hex in extraNonce2']); } @@ -285,7 +285,7 @@ var JobManager = module.exports = function JobManager(options) { port: port, worker: workerName, height: job.rpcData.height, - blockReward: job.rpcData.reward, + blockReward: job.rpcData.rewardToPool, difficulty: difficulty, shareDiff: shareDiff.toFixed(8), blockDiff: blockDiffAdjusted, diff --git a/lib/transactions.js b/lib/transactions.js index e4340f5..f0be3c8 100644 --- a/lib/transactions.js +++ b/lib/transactions.js @@ -31,7 +31,8 @@ function scriptFoundersCompile(address){ } -exports.createGeneration = function(blockHeight, blockReward, feeReward, recipients, poolAddress, payFoundersReward, percentFoundersReward, maxFoundersRewardBlockHeight, foundersRewardAddressChangeInterval, vFoundersRewardAddress, percentTreasuryReward, treasuryRewardStartBlockHeight, treasuryRewardAddressChangeInterval, vTreasuryRewardAddress){ +exports.createGeneration = function(rpcData, blockReward, feeReward, recipients, poolAddress, payFoundersReward, percentFoundersReward, maxFoundersRewardBlockHeight, foundersRewardAddressChangeInterval, vFoundersRewardAddress, percentTreasuryReward, treasuryRewardStartBlockHeight, treasuryRewardAddressChangeInterval, vTreasuryRewardAddress){ + var blockHeight = rpcData.height; var poolAddrHash = bitcoin.address.fromBase58Check(poolAddress).hash; var tx = new bitcoin.Transaction(); @@ -45,7 +46,7 @@ exports.createGeneration = function(blockHeight, blockReward, feeReward, recipie var lengthDiff = blockHeightSerial.length/2 - height; for (var i = 0; i < lengthDiff; i++) { blockHeightSerial = blockHeightSerial + '00'; - } + } length = '0' + height; var serializedBlockHeight = new Buffer.concat([ new Buffer(length, 'hex'), @@ -66,6 +67,8 @@ exports.createGeneration = function(blockHeight, blockReward, feeReward, recipie feePercent = feePercent + recipients[i].percent; } + var rewardToPool = 0; + // txs with founders reward if (payFoundersReward === true && (maxFoundersRewardBlockHeight >= blockHeight || treasuryRewardStartBlockHeight)) { @@ -80,16 +83,18 @@ exports.createGeneration = function(blockHeight, blockReward, feeReward, recipie //console.log("treasuryAddr: "+vTreasuryRewardAddress[index]); // pool t-addr + rewardToPool = Math.round(blockReward * (1 - (percentTreasuryReward + feePercent) / 100)) + feeReward; + tx.addOutput( scriptCompile(poolAddrHash), - Math.round(blockReward * (1 - (percentTreasuryReward + feePercent) / 100)) + feeReward + rewardToPool ); // treasury t-addr tx.addOutput( scriptFoundersCompile(foundersAddrHash), Math.round(blockReward * (percentTreasuryReward / 100)) ); - + } else { // founders reward @@ -100,9 +105,11 @@ exports.createGeneration = function(blockHeight, blockReward, feeReward, recipie //console.log("foundersAddr: "+vFoundersRewardAddress[index]); // pool t-addr + rewardToPool = Math.round(blockReward * (1 - (percentFoundersReward + feePercent) / 100)) + feeReward; + tx.addOutput( scriptCompile(poolAddrHash), - Math.round(blockReward * (1 - (percentFoundersReward + feePercent) / 100)) + feeReward + rewardToPool ); // founders t-addr tx.addOutput( @@ -115,10 +122,12 @@ exports.createGeneration = function(blockHeight, blockReward, feeReward, recipie else { // pool t-addr + rewardToPool = Math.round(blockReward * (1 - (feePercent / 100))) + feeReward; + tx.addOutput( scriptCompile(poolAddrHash), - Math.round(blockReward * (1 - (feePercent / 100))) + feeReward - ); + rewardToPool + ); } // pool fee recipients t-addr @@ -133,6 +142,7 @@ exports.createGeneration = function(blockHeight, blockReward, feeReward, recipie // assign txHash = tx.getHash().toString('hex'); + rpcData.rewardToPool = rewardToPool; /* console.log('txHex: ' + txHex.toString('hex')); From ade97fe7fec7d581189c3dd778bec1425abdb88f Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Thu, 11 Jan 2018 10:32:57 +0100 Subject: [PATCH 07/44] ZMQ connect --- lib/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 51351cf..5da4cc9 100644 --- a/lib/index.js +++ b/lib/index.js @@ -49,7 +49,7 @@ pool.on('log', function (severity, logText) { // connect to publisher socket var sock = zmq.socket('pub'); -sock.bindSync(config.publisherSocket); +sock.connect(config.publisherSocket); pool.emitInfoLog('Connected to ZMQ socket ' + config.publisherSocket); // monitor shares From b87ea3cdc2350c5eafd747cf98b38450acbbed8b Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Fri, 12 Jan 2018 12:41:51 +0100 Subject: [PATCH 08/44] revert --- lib/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 5da4cc9..51351cf 100644 --- a/lib/index.js +++ b/lib/index.js @@ -49,7 +49,7 @@ pool.on('log', function (severity, logText) { // connect to publisher socket var sock = zmq.socket('pub'); -sock.connect(config.publisherSocket); +sock.bindSync(config.publisherSocket); pool.emitInfoLog('Connected to ZMQ socket ' + config.publisherSocket); // monitor shares From f8097e2a48b24350cf81dcc1c719ef3696532b54 Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Sun, 14 Jan 2018 19:58:25 +0100 Subject: [PATCH 09/44] ZMQ block monitoring --- lib/pool.js | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 771fe75..040e2d3 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1,5 +1,6 @@ var events = require('events'); var async = require('async'); +var zmq = require('zeromq'); var varDiff = require('./varDiff.js'); var daemon = require('./daemon.js'); @@ -58,6 +59,7 @@ var pool = module.exports = function pool(options, authorizeFn) { OnBlockchainSynced(function () { GetFirstJob(function () { SetupBlockPolling(); + SetupBlockSub(); SetupPeer(); StartStratumServer(function () { OutputPoolInfo(); @@ -567,6 +569,25 @@ var pool = module.exports = function pool(options, authorizeFn) { }, pollingInterval); } + function SetupBlockSub(){ + if (typeof options.zmqPubSocket !== "string"){ + emitLog('Block template ZMQ subscription has been disabled'); + return; + } + + var sock = zmq.socket('sub'); + sock.connect(options.zmqPubSocket); + sock.subscribe('hashblock'); + + emitInfoLog('Connected to daemon ZMQ publisher socket ' + options.zmqPubSocket); + + sock.on('message', function(topic, message) { + GetBlockTemplate(function(error, result, foundNewBlock){ + if (foundNewBlock) + emitLog('block notification via ZMQ subscription'); + }); + }); + } function GetBlockTemplate(callback) { function getBlockSubsidyandTemplate(callback) { @@ -579,9 +600,7 @@ var pool = module.exports = function pool(options, authorizeFn) { }); } - function getBlockTemplate(subsidy) { - _this.daemon.cmd('getblocktemplate', [{"capabilities": ["coinbasetxn", "workid", "coinbase/append"]}], function (result) { @@ -593,9 +612,13 @@ var pool = module.exports = function pool(options, authorizeFn) { result.response.miner = subsidy.miner; result.response.founders = (subsidy.founders || subsidy.community); var processedNewBlock = _this.jobManager.processTemplate(result.response); + + if(processedNewBlock) { + emitInfoLog("New block to mine " + data.height); + } + callback(null, result.response, processedNewBlock); - callback = function () { - }; + callback = function () {}; } }, true ); From d2d3b3d6856fa149bdfef090f8e16af4a5b99e68 Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Sun, 14 Jan 2018 20:03:06 +0100 Subject: [PATCH 10/44] Fix --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 040e2d3..15b8678 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -614,7 +614,7 @@ var pool = module.exports = function pool(options, authorizeFn) { var processedNewBlock = _this.jobManager.processTemplate(result.response); if(processedNewBlock) { - emitInfoLog("New block to mine " + data.height); + emitInfoLog("New block to mine " + result.response.height); } callback(null, result.response, processedNewBlock); From 005d09b94a7ed2d32f3f324efc3d48cc87bb8def Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Sat, 20 Jan 2018 22:27:17 +0100 Subject: [PATCH 11/44] Logging --- lib/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 51351cf..6c5a72e 100644 --- a/lib/index.js +++ b/lib/index.js @@ -50,7 +50,7 @@ pool.on('log', function (severity, logText) { // connect to publisher socket var sock = zmq.socket('pub'); sock.bindSync(config.publisherSocket); -pool.emitInfoLog('Connected to ZMQ socket ' + config.publisherSocket); +pool.emitInfoLog('Bound ZMQ publisher socket ' + config.publisherSocket); // monitor shares pool.on('share', function (isValidShare, isValidBlock, data) { From df23de4514b084be81819ae850229d847ea6401c Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Wed, 24 Jan 2018 19:44:30 +0100 Subject: [PATCH 12/44] SSL/TLS --- lib/stratum.js | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/lib/stratum.js b/lib/stratum.js index f029d00..8b9d6e1 100644 --- a/lib/stratum.js +++ b/lib/stratum.js @@ -6,8 +6,6 @@ var fs = require('fs'); var util = require('./util.js'); -var TLSoptions; - var SubscriptionCounter = function(){ var count = 0; var padding = 'deadbeefcafebabe'; @@ -426,37 +424,41 @@ var StratumServer = exports.Server = function StratumServer(options, authorizeFn }, 1000 * options.banning.purgeInterval); } - - //SetupBroadcasting(); - - if ((typeof(options.tlsOptions) !== 'undefined' && typeof(options.tlsOptions.enabled) !== 'undefined') && (options.tlsOptions.enabled === "true" || options.tlsOptions.enabled === true)) { - TLSoptions = { - key: fs.readFileSync(options.tlsOptions.serverKey), - cert: fs.readFileSync(options.tlsOptions.serverCert), - requireCert: true - } - } - var serversStarted = 0; - for (var port in options.ports) { - if (options.ports[port].tls === false || options.ports[port].tls === "false") { - net.createServer({allowHalfOpen: false}, function(socket) { + Object.keys(options.ports).forEach(function(port){ + let portData = options.ports[port]; + + if(portData.ssl) { + tls.createServer({ + key: fs.readFileSync(portData.key), + cert: fs.readFileSync(portData.pem) + }, function(socket) { _this.handleNewClient(socket); - }).listen(parseInt(port), function() { - serversStarted++; - if (serversStarted == Object.keys(options.ports).length) - _this.emit('started'); + }).listen(parseInt(port), function (error) { + if (error) { + console.error("Unable to start server on: " + port + " Message: " + error); + return; + } + + serversStarted++; + if (serversStarted == Object.keys(options.ports).length) + _this.emit('started'); }); } else { - tls.createServer(TLSoptions, function(socket) { + net.createServer({allowHalfOpen: false}, function(socket) { _this.handleNewClient(socket); - }).listen(parseInt(port), function() { + }).listen(parseInt(port), function(error) { + if (error) { + console.error("Unable to start server on: " + port + " Message: " + error); + return; + } + serversStarted++; if (serversStarted == Object.keys(options.ports).length) _this.emit('started'); }); } - } + }); })(); From 280c8cf859317d2e5efc77b0def6dbfabebb3ccc Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Thu, 25 Jan 2018 17:28:59 +0100 Subject: [PATCH 13/44] WIP --- lib/index.js | 6 ++++++ lib/stratum.js | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/lib/index.js b/lib/index.js index 51351cf..eacf160 100644 --- a/lib/index.js +++ b/lib/index.js @@ -30,6 +30,12 @@ var pool = createPool(config, function (ip, port, workerName, password, callback var miner = minerWorker[0].trim(); var worker = minerWorker.length > 1 ? minerWorker[1].trim() : ""; + if(config.authWhiteList && config.authWhiteList.hasOwnProperty(miner)) { + console.log("Authorizing white-listed miner " + miner + " as " + config.authWhiteList[miner]); + callback({ authorized: true, workerNameOverride: config.authWhiteList[miner] }); + return; + } + pool.daemon.cmd('validateaddress', [miner], function (results) { var authResult = {}; diff --git a/lib/stratum.js b/lib/stratum.js index f029d00..f45e317 100644 --- a/lib/stratum.js +++ b/lib/stratum.js @@ -127,6 +127,10 @@ var StratumClient = function(options){ options.authorizeFn(_this.remoteAddress, options.socket.localPort, _this.workerName, _this.workerPass, function(result) { _this.authorized = (!result.error && result.authorized); + if(_this.authorized && result.workerNameOverride) { + _this.workerName = result.workerNameOverride; + } + sendJson({ id : message.id, result : _this.authorized, From 28b7f28a0df029ac8e8f44ee53aa489bec2c105e Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Thu, 1 Mar 2018 17:08:27 +0100 Subject: [PATCH 14/44] share source --- lib/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 0ca8a5f..c862cc7 100644 --- a/lib/index.js +++ b/lib/index.js @@ -90,7 +90,8 @@ pool.on('share', function (isValidShare, isValidBlock, data) { blockHash: data.blockHash, transactionConfirmationData: data.txHash, userAgent: '', - payoutInfo: '' // monero only + payoutInfo: '', // monero only + source: config.clusterName }; // publish From b93075fbdb601ea99b821bd4c8c052098b704b5a Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Fri, 2 Mar 2018 15:36:41 +0100 Subject: [PATCH 15/44] publisher connect --- lib/index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index c862cc7..6ce9263 100644 --- a/lib/index.js +++ b/lib/index.js @@ -55,8 +55,13 @@ pool.on('log', function (severity, logText) { // connect to publisher socket var sock = zmq.socket('pub'); -sock.bindSync(config.publisherSocket); -pool.emitInfoLog('Bound ZMQ publisher socket ' + config.publisherSocket); +if(!config.publisherConnect) { + sock.bindSync(config.publisherSocket); + pool.emitInfoLog('Bound to ZMQ publisher socket ' + config.publisherSocket); +} else { + sock.connect(config.publisherSocket); + pool.emitInfoLog('Connected to ZMQ publisher socket ' + config.publisherSocket); +} // monitor shares pool.on('share', function (isValidShare, isValidBlock, data) { From a8b5317dd20c39980e0f7669955165a5f7e6144c Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Sun, 4 Mar 2018 15:24:30 +0100 Subject: [PATCH 16/44] BTCP adjustments --- .vscode/database.json | 1 + lib/algoProperties.js | 11 +++++++++-- lib/blockTemplate.js | 2 +- lib/jobManager.js | 3 +++ 4 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 .vscode/database.json diff --git a/.vscode/database.json b/.vscode/database.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/.vscode/database.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/lib/algoProperties.js b/lib/algoProperties.js index f2375e8..726ab92 100644 --- a/lib/algoProperties.js +++ b/lib/algoProperties.js @@ -1,8 +1,6 @@ var ev = require('equihashverify'); var util = require('./util.js'); -var diff1 = global.diff1 = 0x0007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff; - var algos = module.exports = global.algos = { sha256: { //Uncomment diff if you want to use hardcoded truncated diff @@ -21,6 +19,15 @@ var algos = module.exports = global.algos = { return ev.verify.apply(this, arguments); } } + }, + 'equihash-btcp': { + multiplier: 1, + diff: parseInt('0x0007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'), + hash: function(){ + return function(){ + return ev.verify.apply(this, arguments); + } + } } }; diff --git a/lib/blockTemplate.js b/lib/blockTemplate.js index e316596..539ba16 100644 --- a/lib/blockTemplate.js +++ b/lib/blockTemplate.js @@ -8,7 +8,7 @@ var util = require('./util.js'); * The BlockTemplate class holds a single job. * and provides several methods to validate and submit it to the daemon coin **/ -var BlockTemplate = module.exports = function BlockTemplate(jobId, rpcData, extraNoncePlaceholder, reward, recipients, poolAddress, payFoundersReward, percentFoundersReward, maxFoundersRewardBlockHeight, foundersRewardAddressChangeInterval, vFoundersRewardAddress, percentTreasuryReward, treasuryRewardStartBlockHeight, treasuryRewardAddressChangeInterval, vTreasuryRewardAddress){ +var BlockTemplate = module.exports = function BlockTemplate(jobId, diff1, rpcData, extraNoncePlaceholder, reward, recipients, poolAddress, payFoundersReward, percentFoundersReward, maxFoundersRewardBlockHeight, foundersRewardAddressChangeInterval, vFoundersRewardAddress, percentTreasuryReward, treasuryRewardStartBlockHeight, treasuryRewardAddressChangeInterval, vTreasuryRewardAddress){ //private members var submits = []; diff --git a/lib/jobManager.js b/lib/jobManager.js index ad1b248..d8521b6 100644 --- a/lib/jobManager.js +++ b/lib/jobManager.js @@ -80,6 +80,7 @@ var JobManager = module.exports = function JobManager(options) { this.currentJob; this.validJobs = {}; + var diff1 = algos[options.coin.algorithm].diff; var hashDigest = algos[options.coin.algorithm].hash(options.coin); var coinbaseHasher = (function () { @@ -106,6 +107,7 @@ var JobManager = module.exports = function JobManager(options) { this.updateCurrentJob = function (rpcData) { var tmpBlockTemplate = new blockTemplate( jobCounter.next(), + diff1, rpcData, _this.extraNoncePlaceholder, options.coin.reward, @@ -149,6 +151,7 @@ var JobManager = module.exports = function JobManager(options) { var tmpBlockTemplate = new blockTemplate( jobCounter.next(), + diff1, rpcData, _this.extraNoncePlaceholder, options.coin.reward, From 99e66c70dd6d946703d65a64b62db052af9db223 Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Sun, 4 Mar 2018 20:39:44 +0100 Subject: [PATCH 17/44] configurable zmq blocknotify topic --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 15b8678..1c8a74f 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -577,7 +577,7 @@ var pool = module.exports = function pool(options, authorizeFn) { var sock = zmq.socket('sub'); sock.connect(options.zmqPubSocket); - sock.subscribe('hashblock'); + sock.subscribe(options.zmqPubTopic || 'hashblock'); emitInfoLog('Connected to daemon ZMQ publisher socket ' + options.zmqPubSocket); From 8fdac9d12b22aba308fc064c2f6225167e9a54aa Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Mon, 5 Mar 2018 17:34:08 +0100 Subject: [PATCH 18/44] Fix target encoding not obeying coin config --- lib/stratum.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/stratum.js b/lib/stratum.js index 37f480e..8ab7fb1 100644 --- a/lib/stratum.js +++ b/lib/stratum.js @@ -274,18 +274,16 @@ var StratumClient = function(options){ _this.difficulty = difficulty; //powLimit * difficulty - var powLimit = algos.equihash.diff; // TODO: Get algos object from argument + var powLimit = algos[options.coin.algorithm].diff; var adjPow = powLimit / difficulty; if ((64 - adjPow.toString(16).length) === 0) { var zeroPad = ''; - } - else { + } else { var zeroPad = '0'; zeroPad = zeroPad.repeat((64 - (adjPow.toString(16).length))); } var target = (zeroPad + adjPow.toString(16)).substr(0,64); - sendJson({ id : null, method: "mining.set_target", From 749080eee75bcb2799c8fcb98d5dd3b7231fc30c Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Mon, 5 Mar 2018 17:39:52 +0100 Subject: [PATCH 19/44] Fix --- lib/stratum.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/stratum.js b/lib/stratum.js index 8ab7fb1..7636e86 100644 --- a/lib/stratum.js +++ b/lib/stratum.js @@ -380,7 +380,8 @@ var StratumServer = exports.Server = function StratumServer(options, authorizeFn socket: socket, banning: options.banning, connectionTimeout: options.connectionTimeout, - tcpProxyProtocol: options.tcpProxyProtocol + tcpProxyProtocol: options.tcpProxyProtocol, + coin: options.coin } ); From 711b677ba0faf77c1e6a8877fe3241568299b276 Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Mon, 5 Mar 2018 17:43:33 +0100 Subject: [PATCH 20/44] WIP --- lib/stratum.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/stratum.js b/lib/stratum.js index 7636e86..dfb551a 100644 --- a/lib/stratum.js +++ b/lib/stratum.js @@ -274,7 +274,7 @@ var StratumClient = function(options){ _this.difficulty = difficulty; //powLimit * difficulty - var powLimit = algos[options.coin.algorithm].diff; + var powLimit = algos.equihash.diff; // algos[options.coin.algorithm].diff; var adjPow = powLimit / difficulty; if ((64 - adjPow.toString(16).length) === 0) { var zeroPad = ''; From f2a7c8fa76071d10249c0cd6c1a4a0da912bf6cc Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Mon, 5 Mar 2018 19:44:42 +0100 Subject: [PATCH 21/44] WIP --- lib/stratum.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/stratum.js b/lib/stratum.js index dfb551a..2d013a3 100644 --- a/lib/stratum.js +++ b/lib/stratum.js @@ -273,8 +273,7 @@ var StratumClient = function(options){ _this.previousDifficulty = _this.difficulty; _this.difficulty = difficulty; - //powLimit * difficulty - var powLimit = algos.equihash.diff; // algos[options.coin.algorithm].diff; + var powLimit = algos[options.coin.algorithm].diff; var adjPow = powLimit / difficulty; if ((64 - adjPow.toString(16).length) === 0) { var zeroPad = ''; From 3f0e70df29ac554676c3c3bccf8ab8cb18f2885c Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Tue, 6 Mar 2018 15:29:40 +0100 Subject: [PATCH 22/44] tx comment --- lib/transactions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/transactions.js b/lib/transactions.js index f0be3c8..a67750d 100644 --- a/lib/transactions.js +++ b/lib/transactions.js @@ -58,7 +58,7 @@ exports.createGeneration = function(rpcData, blockReward, feeReward, recipients, 4294967295, 4294967295, new Buffer.concat([serializedBlockHeight, - Buffer('5a2d4e4f4d50212068747470733a2f2f6769746875622e636f6d2f6a6f7368756179616275742f7a2d6e6f6d70', 'hex')]) //Z-NOMP! https://github.com/joshuayabut/z-nomp + Buffer('68747470733a2f2f636f696e666f756e6472792e6f7267', 'hex')]) ); // calculate total fees From a3f118bef01b8e7504ee9a260f6a95b3e677c371 Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Tue, 6 Mar 2018 15:30:24 +0100 Subject: [PATCH 23/44] WIP --- lib/transactions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/transactions.js b/lib/transactions.js index a67750d..737c8cd 100644 --- a/lib/transactions.js +++ b/lib/transactions.js @@ -58,7 +58,7 @@ exports.createGeneration = function(rpcData, blockReward, feeReward, recipients, 4294967295, 4294967295, new Buffer.concat([serializedBlockHeight, - Buffer('68747470733a2f2f636f696e666f756e6472792e6f7267', 'hex')]) + Buffer('68747470733a2f2f636f696e666f756e6472792e6f7267', 'hex')]) // Comment ); // calculate total fees From 0aa3b3c8fab9aba1ce8c8da41a18f0bf70fdaab4 Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Thu, 15 Mar 2018 11:39:20 +0100 Subject: [PATCH 24/44] Add payload-type-flag-frame to share publisher --- lib/index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 6ce9263..9699581 100644 --- a/lib/index.js +++ b/lib/index.js @@ -54,7 +54,11 @@ pool.on('log', function (severity, logText) { }); // connect to publisher socket -var sock = zmq.socket('pub'); +const sock = zmq.socket('pub'); +const pubFlags = 1; // WireFormat.Json +const pubFlagsBuf = Buffer.allocUnsafe(4); +pubFlagsBuf.writeUInt32BE(pubFlags, 0); + if(!config.publisherConnect) { sock.bindSync(config.publisherSocket); pool.emitInfoLog('Bound to ZMQ publisher socket ' + config.publisherSocket); @@ -100,7 +104,7 @@ pool.on('share', function (isValidShare, isValidBlock, data) { }; // publish - sock.send([config.publisherTopic, JSON.stringify(share)]); + sock.send([config.publisherTopic, pubFlagsBuf, JSON.stringify(share)]); } }); From ddeaec1e3added9e3be2361738c2af6946ea86e4 Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Fri, 6 Apr 2018 14:20:15 +0200 Subject: [PATCH 25/44] protobuf publish support --- lib/index.js | 36 +++++++++++++++++++++++++++++------- package.json | 3 ++- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/lib/index.js b/lib/index.js index 9699581..15b2fd2 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,9 +1,10 @@ -var net = require('net'); -var events = require('events'); -var zmq = require('zeromq'); +const net = require('net'); +const events = require('events'); +const zmq = require('zeromq'); +const protobuf = require("protobufjs"); require('./algoProperties.js'); -var pool = require('./pool.js'); +const pool = require('./pool.js'); exports.daemon = require('./daemon.js'); exports.varDiff = require('./varDiff.js'); @@ -53,9 +54,27 @@ pool.on('log', function (severity, logText) { console.log(severity + ': ' + logText); }); -// connect to publisher socket +// Define proto message +const ShareMessage = !!!config.publisherJson ? + new protobuf.Type("ShareMessage") + .add(new protobuf.Field("poolId", 1, "string")) + .add(new protobuf.Field("miner", 2, "string")) + .add(new protobuf.Field("worker", 3, "string")) + .add(new protobuf.Field("payoutInfo", 4, "string")) + .add(new protobuf.Field("userAgent", 5, "string")) + .add(new protobuf.Field("ipAddress", 6, "string")) + .add(new protobuf.Field("source", 7, "string")) + .add(new protobuf.Field("difficulty", 8, "double")) + .add(new protobuf.Field("blockHeight", 9, "int64")) + .add(new protobuf.Field("blockReward", 10, "double")) + .add(new protobuf.Field("blockHash", 11, "string")) + .add(new protobuf.Field("isBlockCandidate", 12, "bool")) + .add(new protobuf.Field("transactionConfirmationData", 13, "string")) + .add(new protobuf.Field("networkDifficulty", 14, "double")) : undefined; + +// connect/bind ZMQ share publisher socket const sock = zmq.socket('pub'); -const pubFlags = 1; // WireFormat.Json +const pubFlags = config.publisherJson ? 1 : 2; // WireFormat.Json or WireFormat.ProtoBuf const pubFlagsBuf = Buffer.allocUnsafe(4); pubFlagsBuf.writeUInt32BE(pubFlags, 0); @@ -103,8 +122,11 @@ pool.on('share', function (isValidShare, isValidBlock, data) { source: config.clusterName }; + const rawMsg = config.publisherJson ? JSON.stringify(share) : + ShareMessage.encode(ShareMessage.create(share)).finish(); + // publish - sock.send([config.publisherTopic, pubFlagsBuf, JSON.stringify(share)]); + pubSock.send([config.publisherTopic, pubFlagsBuf, rawMsg]); } }); diff --git a/package.json b/package.json index 8660223..aba3fc7 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,8 @@ "merkle-bitcoin": "git+https://github.com/joshuayabut/merkle-bitcoin.git", "bitcoinjs-lib-zcash": "git+https://github.com/runn1ng/bitcoinjs-lib.git#zcash", "promise": "*", - "zeromq": "^4.6.0" + "zeromq": "^4.6.0", + "protobufjs": "^6.8.6" }, "engines": { "node": ">=7" From 22431cf16a77be80eee612553e74cfcc71e776cc Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Fri, 6 Apr 2018 14:55:24 +0200 Subject: [PATCH 26/44] WIP --- lib/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/index.js b/lib/index.js index 15b2fd2..5ed7116 100644 --- a/lib/index.js +++ b/lib/index.js @@ -4,7 +4,7 @@ const zmq = require('zeromq'); const protobuf = require("protobufjs"); require('./algoProperties.js'); -const pool = require('./pool.js'); +const pool_proto = require('./pool.js'); exports.daemon = require('./daemon.js'); exports.varDiff = require('./varDiff.js'); @@ -15,8 +15,8 @@ if(process.argv.length < 3) { process.exit(1); } -var createPool = function (poolOptions, authorizeFn) { - var newPool = new pool(poolOptions, authorizeFn); +const createPool = function (poolOptions, authorizeFn) { + var newPool = new pool_proto(poolOptions, authorizeFn); return newPool; }; @@ -24,7 +24,7 @@ var createPool = function (poolOptions, authorizeFn) { var config = require(process.argv[2]); // create pool -var pool = createPool(config, function (ip, port, workerName, password, callback) { //stratum authorization function +const pool = createPool(config, function (ip, port, workerName, password, callback) { //stratum authorization function console.log("Authorize " + workerName + ":" + password + "@" + ip); var minerWorker = workerName.split("."); From ea71da6bbc2d6871c623a22fdcea18230743b32d Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Fri, 6 Apr 2018 15:34:12 +0200 Subject: [PATCH 27/44] SSL RPC support --- lib/daemon.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/daemon.js b/lib/daemon.js index 1a976e2..0d31738 100644 --- a/lib/daemon.js +++ b/lib/daemon.js @@ -1,4 +1,5 @@ var http = require('http'); +var https = require('https'); var cp = require('child_process'); var events = require('events'); @@ -51,7 +52,8 @@ function DaemonInterface(daemons, logger) { function performHttpRequest(instance, jsonData, callback) { var options = { hostname: (typeof(instance.host) === 'undefined' ? '127.0.0.1' : instance.host), - port: instance.port, + port : instance.port, + path : instance.httpPath, method: 'POST', auth: instance.user + ':' + instance.password, headers: { @@ -59,6 +61,10 @@ function DaemonInterface(daemons, logger) { } }; + if(instance.ssl && !instance.validateCert) { + options.rejectUnauthorized = false; + } + var parseJson = function (res, data) { var dataJson; @@ -85,7 +91,9 @@ function DaemonInterface(daemons, logger) { callback(dataJson.error, dataJson, data); }; - var req = http.request(options, function (res) { + const client = instance.ssl ? https : http; + + var req = client.request(options, function(res) { var data = ''; res.setEncoding('utf8'); res.on('data', function (chunk) { From 87ef54196f1bcf7c6d3f510df8519479c81e7a61 Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Fri, 6 Apr 2018 16:34:18 +0200 Subject: [PATCH 28/44] Fix --- lib/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 5ed7116..68b07fc 100644 --- a/lib/index.js +++ b/lib/index.js @@ -126,7 +126,7 @@ pool.on('share', function (isValidShare, isValidBlock, data) { ShareMessage.encode(ShareMessage.create(share)).finish(); // publish - pubSock.send([config.publisherTopic, pubFlagsBuf, rawMsg]); + sock.send([config.publisherTopic, pubFlagsBuf, rawMsg]); } }); From 18576776320f71f2f0c821549296b0f90bb013bc Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Fri, 6 Apr 2018 21:07:30 +0200 Subject: [PATCH 29/44] FreeBSD --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index aba3fc7..6be3ebe 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "url": "https://github.com/joshuayabut/node-stratum-pool.git" }, "dependencies": { - "equihashverify": "git+https://github.com/joshuayabut/equihashverify.git", + "equihashverify": "git+https://github.com/coinfoundry/equihashverify.git", "bignum": "*", "base58-native": "*", "async": "*", From 2553536c06a343f35336e72ca7e8a9e7cfa9a1e2 Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Fri, 6 Apr 2018 21:26:17 +0200 Subject: [PATCH 30/44] zeromq --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6be3ebe..7b5f6ea 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "merkle-bitcoin": "git+https://github.com/joshuayabut/merkle-bitcoin.git", "bitcoinjs-lib-zcash": "git+https://github.com/runn1ng/bitcoinjs-lib.git#zcash", "promise": "*", - "zeromq": "^4.6.0", + "zeromq": "git+https://github.com/coinfoundry/zeromq.js.git", "protobufjs": "^6.8.6" }, "engines": { From 77d3f8d8c18a4ff82a2c15a3691d5343f4a03f8b Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Thu, 12 Apr 2018 10:27:20 +0200 Subject: [PATCH 31/44] Exit on startup error --- lib/pool.js | 2 + package-lock.json | 176 +++++++++++++++++++++++++++++++++++----------- 2 files changed, 138 insertions(+), 40 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 1c8a74f..ffeb4ff 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -392,6 +392,7 @@ var pool = module.exports = function pool(options, authorizeFn) { _this.daemon.batchCmd(batchRpcCalls, function (error, results) { if (error || !results) { emitErrorLog('Could not start pool, error with init batch RPC call: ' + JSON.stringify(error)); + process.exit(1); return; } @@ -404,6 +405,7 @@ var pool = module.exports = function pool(options, authorizeFn) { if (rpcCall !== 'submitblock' && (r.error || !r.result)) { emitErrorLog('Could not start pool, error with init RPC ' + rpcCall + ' - ' + JSON.stringify(r.error)); + process.exit(1); return; } } diff --git a/package-lock.json b/package-lock.json index b829426..52d1a3d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,6 +4,70 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "@protobufjs/aspromise": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz", + "integrity": "sha1-m4sMxmPWaafY9vXQiToU00jzD78=" + }, + "@protobufjs/base64": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@protobufjs/base64/-/base64-1.1.2.tgz", + "integrity": "sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==" + }, + "@protobufjs/codegen": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@protobufjs/codegen/-/codegen-2.0.4.tgz", + "integrity": "sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg==" + }, + "@protobufjs/eventemitter": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz", + "integrity": "sha1-NVy8mLr61ZePntCV85diHx0Ga3A=" + }, + "@protobufjs/fetch": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/fetch/-/fetch-1.1.0.tgz", + "integrity": "sha1-upn7WYYUr2VwDBYZ/wbUVLDYTEU=", + "requires": { + "@protobufjs/aspromise": "1.1.2", + "@protobufjs/inquire": "1.1.0" + } + }, + "@protobufjs/float": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@protobufjs/float/-/float-1.0.2.tgz", + "integrity": "sha1-Xp4avctz/Ap8uLKR33jIy9l7h9E=" + }, + "@protobufjs/inquire": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/inquire/-/inquire-1.1.0.tgz", + "integrity": "sha1-/yAOPnzyQp4tyvwRQIKOjMY48Ik=" + }, + "@protobufjs/path": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@protobufjs/path/-/path-1.1.2.tgz", + "integrity": "sha1-bMKyDFya1q0NzP0hynZz2Nf79o0=" + }, + "@protobufjs/pool": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/pool/-/pool-1.1.0.tgz", + "integrity": "sha1-Cf0V8tbTq/qbZbw2ZQbWrXhG/1Q=" + }, + "@protobufjs/utf8": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/utf8/-/utf8-1.1.0.tgz", + "integrity": "sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA=" + }, + "@types/long": { + "version": "3.0.32", + "resolved": "https://registry.npmjs.org/@types/long/-/long-3.0.32.tgz", + "integrity": "sha512-ZXyOOm83p7X8p3s0IYM3VeueNmHpkk/yMlP8CLeOnEcu6hIwPH7YjZBvhQkR0ZFS2DqZAxKtJ/M5fcuv3OU5BA==" + }, + "@types/node": { + "version": "8.10.6", + "resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.6.tgz", + "integrity": "sha512-1lrX+Zjk7Z3nvNn2w9mf/LZlUJeOQJsoK0sroQIQk0WNLCRSu6ma9aKE4ksRXmuySKDEIgTl2FGanCVdBWKoHw==" + }, "abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", @@ -105,6 +169,11 @@ "tweetnacl": "0.14.5" } }, + "bech32": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/bech32/-/bech32-1.1.3.tgz", + "integrity": "sha512-yuVFUvrNcoJi0sv5phmqc6P+Fl1HjRDRNOOkHY2X/3LBy2bIGNSFx4fZ95HMaXHupuS7cZR15AsvtmCIF4UEyg==" + }, "bigi": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/bigi/-/bigi-1.4.2.tgz", @@ -138,8 +207,9 @@ "integrity": "sha512-hSbFP1t/hRCdTWXoSUarhwySo8g1UqIjopXNaJAf+Gi6rTzWmPEKG1khXbNIPeHLskonR1Lq09KPyu37l+7zGQ==" }, "bitcoinjs-lib-zcash": { - "version": "git+https://github.com/runn1ng/bitcoinjs-lib.git#e128e36171d52870312adde4321089bcdbce46fd", + "version": "git+https://github.com/runn1ng/bitcoinjs-lib.git#986da96cb320528dee491a5f445bb502a9fb4e72", "requires": { + "bech32": "1.1.3", "bigi": "1.4.2", "bip66": "1.1.5", "bitcoin-ops": "1.4.0", @@ -147,12 +217,20 @@ "create-hash": "1.1.3", "create-hmac": "1.1.6", "ecurve": "1.0.6", - "merkle-lib": "1.0.0", + "merkle-lib": "2.0.10", "pushdata-bitcoin": "1.0.1", "randombytes": "2.0.5", + "safe-buffer": "5.1.1", "typeforce": "1.12.0", "varuint-bitcoin": "1.0.4", "wif": "2.0.6" + }, + "dependencies": { + "merkle-lib": { + "version": "2.0.10", + "resolved": "https://registry.npmjs.org/merkle-lib/-/merkle-lib-2.0.10.tgz", + "integrity": "sha1-grjbrnXieneFOItz+ddyXQ9vMyY=" + } } }, "bl": { @@ -359,7 +437,7 @@ } }, "equihashverify": { - "version": "git+https://github.com/joshuayabut/equihashverify.git#6e4dca3266018640da8e5a4830d2cc4769389577", + "version": "git+https://github.com/coinfoundry/equihashverify.git#6c78fc8d560ebf8599b51c07298e6830a82d85d2", "requires": { "bindings": "1.3.0", "nan": "2.8.0", @@ -627,6 +705,11 @@ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=" }, + "long": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", + "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==" + }, "merkle-bitcoin": { "version": "git+https://github.com/joshuayabut/merkle-bitcoin.git#ec00ae20ba60d444e150ead03c747695ddaa83a1", "requires": { @@ -640,11 +723,6 @@ } } }, - "merkle-lib": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/merkle-lib/-/merkle-lib-1.0.0.tgz", - "integrity": "sha1-vQiLLHsQJjORA6DzQprgkCLPslw=" - }, "mime-db": { "version": "1.30.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.30.0.tgz", @@ -827,34 +905,6 @@ "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-0.2.0.tgz", "integrity": "sha1-M+8wxcd9TqIcWlOGnZG1bY8lVeU=" }, - "prebuild-install": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-2.4.1.tgz", - "integrity": "sha512-99TyEFYTTkBWANT+mwSptmLb9ZCLQ6qKIUE36fXSIOtShB0JNprL2hzBD8F1yIuT9btjFrFEwbRHXhqDi1HmRA==", - "requires": { - "expand-template": "1.1.0", - "github-from-package": "0.0.0", - "minimist": "1.2.0", - "mkdirp": "0.5.1", - "node-abi": "2.1.2", - "noop-logger": "0.1.1", - "npmlog": "4.1.2", - "os-homedir": "1.0.2", - "pump": "1.0.3", - "rc": "1.2.2", - "simple-get": "1.4.3", - "tar-fs": "1.16.0", - "tunnel-agent": "0.6.0", - "xtend": "4.0.1" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" - } - } - }, "process-nextick-args": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", @@ -868,6 +918,26 @@ "asap": "2.0.6" } }, + "protobufjs": { + "version": "6.8.6", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.8.6.tgz", + "integrity": "sha512-eH2OTP9s55vojr3b7NBaF9i4WhWPkv/nq55nznWNp/FomKrLViprUcqnBjHph2tFQ+7KciGPTPsVWGz0SOhL0Q==", + "requires": { + "@protobufjs/aspromise": "1.1.2", + "@protobufjs/base64": "1.1.2", + "@protobufjs/codegen": "2.0.4", + "@protobufjs/eventemitter": "1.1.0", + "@protobufjs/fetch": "1.1.0", + "@protobufjs/float": "1.0.2", + "@protobufjs/inquire": "1.1.0", + "@protobufjs/path": "1.1.2", + "@protobufjs/pool": "1.1.0", + "@protobufjs/utf8": "1.1.0", + "@types/long": "3.0.32", + "@types/node": "8.10.6", + "long": "4.0.0" + } + }, "pump": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/pump/-/pump-1.0.3.tgz", @@ -1237,12 +1307,38 @@ "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=" }, "zeromq": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/zeromq/-/zeromq-4.6.0.tgz", - "integrity": "sha512-sU7pQqQj7f/C6orJZAXls+NEKaVMZZtnZqpMPTq5d5dP78CmdC0g15XIviFAN6poPuKl9qlGt74vipOUUuNeWg==", + "version": "git+https://github.com/coinfoundry/zeromq.js.git#1b60b36d468eb108cdf5bb2db17abc8c93f6b254", "requires": { "nan": "2.8.0", - "prebuild-install": "2.4.1" + "prebuild-install": "2.3.0" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + }, + "prebuild-install": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-2.3.0.tgz", + "integrity": "sha512-gzjq2oHB8oMbzJSsSh9MQ64zrXZGt092/uT4TLZlz2qnrPxpWqp4vYB7LZrDxnlxf5RfbCjkgDI/z0EIVuYzAw==", + "requires": { + "expand-template": "1.1.0", + "github-from-package": "0.0.0", + "minimist": "1.2.0", + "mkdirp": "0.5.1", + "node-abi": "2.1.2", + "noop-logger": "0.1.1", + "npmlog": "4.1.2", + "os-homedir": "1.0.2", + "pump": "1.0.3", + "rc": "1.2.2", + "simple-get": "1.4.3", + "tar-fs": "1.16.0", + "tunnel-agent": "0.6.0", + "xtend": "4.0.1" + } + } } } } From 47d76b866e6d2a517419be4f6eaf7a8401084b52 Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Tue, 17 Apr 2018 09:43:13 +0200 Subject: [PATCH 32/44] http request error handling --- lib/daemon.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/daemon.js b/lib/daemon.js index 0d31738..f891309 100644 --- a/lib/daemon.js +++ b/lib/daemon.js @@ -75,7 +75,9 @@ function DaemonInterface(daemons, logger) { try { dataJson = JSON.parse(data); + callback(dataJson.error, dataJson, data); } + catch (e) { if (data.indexOf(':-nan') !== -1) { data = data.replace(/:-nan,/g, ":0"); @@ -86,9 +88,8 @@ function DaemonInterface(daemons, logger) { + '\nRequest Data: ' + jsonData + '\nReponse Data: ' + data); + callback('Could not parse rpc data from daemon instance ' + instance.index, {}, data); } - if (dataJson) - callback(dataJson.error, dataJson, data); }; const client = instance.ssl ? https : http; From 609437f706fd2bf583c4a0095a79b0fcc116c8f6 Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Thu, 19 Apr 2018 11:20:32 +0200 Subject: [PATCH 33/44] Support for btStream --- lib/pool.js | 111 +++++++++++++++++++++++++++++++++++-------------- lib/stratum.js | 18 ++++---- 2 files changed, 88 insertions(+), 41 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index ffeb4ff..4cab612 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -1,6 +1,7 @@ var events = require('events'); var async = require('async'); var zmq = require('zeromq'); +var zlib = require('zlib'); var varDiff = require('./varDiff.js'); var daemon = require('./daemon.js'); @@ -58,8 +59,13 @@ var pool = module.exports = function pool(options, authorizeFn) { SetupJobManager(); OnBlockchainSynced(function () { GetFirstJob(function () { - SetupBlockPolling(); - SetupBlockSub(); + if(typeof options.btStream === "undefined") { + SetupBlockPolling(); + SetupBlockSub(); + } else { + SetupBtStream(); + } + SetupPeer(); StartStratumServer(function () { OutputPoolInfo(); @@ -591,44 +597,85 @@ var pool = module.exports = function pool(options, authorizeFn) { }); } - function GetBlockTemplate(callback) { - function getBlockSubsidyandTemplate(callback) { - _this.daemon.cmd('getblocksubsidy', - [], - function (result) { - callback = function (subsidy) {getBlockTemplate(subsidy)}; - var subsidy = result[0].response; - callback(subsidy); - }); - } + function SetupBtStream(){ + var subSock = zmq.socket('sub'); + subSock.connect(options.btStream.url); + subSock.subscribe(options.btStream.topic); - function getBlockTemplate(subsidy) { - _this.daemon.cmd('getblocktemplate', - [{"capabilities": ["coinbasetxn", "workid", "coinbase/append"]}], - function (result) { - if (result.error) { - emitErrorLog('getblocktemplate call failed for daemon instance ' + - result.instance.index + ' with error ' + JSON.stringify(result.error)); - callback(result.error); - } else { - result.response.miner = subsidy.miner; - result.response.founders = (subsidy.founders || subsidy.community); - var processedNewBlock = _this.jobManager.processTemplate(result.response); + emitInfoLog('Connected to ZMQ BlockTemplate Stream ' + options.btStream.url + "/" + options.btStream.topic); + let lastBtReceived = null; - if(processedNewBlock) { - emitInfoLog("New block to mine " + result.response.height); - } + subSock.on('message', function(topic, flags, message) { + flags = flags.readUIntBE(0, 4); + + const now = new Date(); + const force = lastBtReceived == null || (now - lastBtReceived) >= (options.jobRebroadcastTimeout * 0.9 * 1000); + lastBtReceived = now; + + if(force) { + emitLog('Updating transactions & rebroadcasting work'); + } + + function process(json) { + const rpcData = JSON.parse(json); + + ProcessBlockTemplate({ response: rpcData.result }, function(error, rpcData, processedBlock) { + if (error || processedBlock) return; + _this.jobManager.updateCurrentJob(rpcData); + }, force); + } - callback(null, result.response, processedNewBlock); - callback = function () {}; + // decompress if necessary + if(flags & 1) { + zlib.inflateRaw(message, function (error, decompressed) { + if(error == null) { + process(decompressed); + } else { + callback(error); } - }, true - ); + }); + } else { + process(message); + } + }); + } + + function ProcessBlockTemplate(result, callback, force){ + // Add auxes to the RPC data to process + var data = result.response; + data.auxes = []; + for(var i = 0;i < _this.auxes.length;i++) data.auxes.push(_this.auxes[i].rpcData); + var processedNewBlock = _this.jobManager.isNewWork(data); + if(processedNewBlock || force) _this.jobManager.processTemplate(data); + + if(processedNewBlock) { + emitInfoLog("New block to mine " + data.height); } - getBlockSubsidyandTemplate(); + callback(null, result.response, processedNewBlock); + callback = function(){}; } + function GetBlockTemplate(callback, force){ + gbtParams = []; + if (_this.options.coin.getblocktemplate == "POS") { + gbtParams = [{"mode": "template" }]; + } else { + gbtParams = [{"capabilities": [ "coinbasetxn", "workid", "coinbase/append" ], "rules": [ "segwit" ]}]; + } + _this.daemon.cmd('getblocktemplate', + gbtParams, + function(result){ + if (result.error){ + emitErrorLog('getblocktemplate call failed for daemon instance ' + + result.instance.index + ' with error ' + JSON.stringify(result.error)); + callback(result.error); + } else { + ProcessBlockTemplate(result, callback, force); + } + }, true + ); + } function CheckBlockAccepted(blockHash, callback) { //setTimeout(function(){ diff --git a/lib/stratum.js b/lib/stratum.js index 2d013a3..70bb0c2 100644 --- a/lib/stratum.js +++ b/lib/stratum.js @@ -397,21 +397,21 @@ var StratumServer = exports.Server = function StratumServer(options, authorizeFn return subscriptionId; }; - this.broadcastMiningJobs = function(jobParams){ for (var clientId in stratumClients) { var client = stratumClients[clientId]; client.sendMiningJob(jobParams); } - /* Some miners will consider the pool dead if it doesn't receive a job for around a minute. - So every time we broadcast jobs, set a timeout to rebroadcast in X seconds unless cleared. */ - clearTimeout(rebroadcastTimeout); - rebroadcastTimeout = setTimeout(function(){ - _this.emit('broadcastTimeout'); - }, options.jobRebroadcastTimeout * 1000); - }; - + if(typeof options.btStream === "undefined") { + /* Some miners will consider the pool dead if it doesn't receive a job for around a minute. + So every time we broadcast jobs, set a timeout to rebroadcast in X seconds unless cleared. */ + clearTimeout(rebroadcastTimeout); + rebroadcastTimeout = setTimeout(function(){ + _this.emit('broadcastTimeout'); + }, options.jobRebroadcastTimeout * 1000); + } + }; (function init(){ From b704763048c7bffbacd76ed2f366aa17286c27e2 Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Thu, 19 Apr 2018 15:59:50 +0200 Subject: [PATCH 34/44] lastJobRefresh = now; --- lib/pool.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 4cab612..8f787ac 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -603,17 +603,17 @@ var pool = module.exports = function pool(options, authorizeFn) { subSock.subscribe(options.btStream.topic); emitInfoLog('Connected to ZMQ BlockTemplate Stream ' + options.btStream.url + "/" + options.btStream.topic); - let lastBtReceived = null; + let lastJobRefresh = null; subSock.on('message', function(topic, flags, message) { flags = flags.readUIntBE(0, 4); const now = new Date(); - const force = lastBtReceived == null || (now - lastBtReceived) >= (options.jobRebroadcastTimeout * 0.9 * 1000); - lastBtReceived = now; + const force = lastJobRefresh == null || (now - lastJobRefresh) >= (options.jobRebroadcastTimeout * 0.9 * 1000); if(force) { emitLog('Updating transactions & rebroadcasting work'); + lastJobRefresh = now; } function process(json) { From 46dbf8f893c8a08d77c1ab8b3948db220c840492 Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Thu, 19 Apr 2018 19:52:36 +0200 Subject: [PATCH 35/44] Fix --- lib/pool.js | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 8f787ac..dd9715e 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -605,6 +605,20 @@ var pool = module.exports = function pool(options, authorizeFn) { emitInfoLog('Connected to ZMQ BlockTemplate Stream ' + options.btStream.url + "/" + options.btStream.topic); let lastJobRefresh = null; + function process(json, force) { + const rpcData = JSON.parse(json); + + ProcessBlockTemplate({ response: rpcData.result }, function(error, rpcData, processedBlock) { + if(processedBlock) { + emitLog('New block notification via BT Stream'); + } + + else if(error == null && force) { + _this.jobManager.updateCurrentJob(rpcData); + } + }); + } + subSock.on('message', function(topic, flags, message) { flags = flags.readUIntBE(0, 4); @@ -616,26 +630,17 @@ var pool = module.exports = function pool(options, authorizeFn) { lastJobRefresh = now; } - function process(json) { - const rpcData = JSON.parse(json); - - ProcessBlockTemplate({ response: rpcData.result }, function(error, rpcData, processedBlock) { - if (error || processedBlock) return; - _this.jobManager.updateCurrentJob(rpcData); - }, force); - } - // decompress if necessary if(flags & 1) { zlib.inflateRaw(message, function (error, decompressed) { if(error == null) { - process(decompressed); + process(decompressed, force); } else { callback(error); } }); } else { - process(message); + process(message, force); } }); } From 8ba833fbb83fc1c8e11ce17d5e8fec07acb8fffa Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Sun, 22 Apr 2018 16:25:07 +0200 Subject: [PATCH 36/44] ZMQ --- package-lock.json | 407 +++++++++++++++++++++++++--------------------- package.json | 2 +- 2 files changed, 227 insertions(+), 182 deletions(-) diff --git a/package-lock.json b/package-lock.json index 52d1a3d..1a6ced0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -64,9 +64,9 @@ "integrity": "sha512-ZXyOOm83p7X8p3s0IYM3VeueNmHpkk/yMlP8CLeOnEcu6hIwPH7YjZBvhQkR0ZFS2DqZAxKtJ/M5fcuv3OU5BA==" }, "@types/node": { - "version": "8.10.6", - "resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.6.tgz", - "integrity": "sha512-1lrX+Zjk7Z3nvNn2w9mf/LZlUJeOQJsoK0sroQIQk0WNLCRSu6ma9aKE4ksRXmuySKDEIgTl2FGanCVdBWKoHw==" + "version": "8.10.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.9.tgz", + "integrity": "sha512-GUUTbeDaJSRaoLkqVQ5jwwKbDiLWFX3JrKLvC078q2P51Z9Dcb5F5UdnApSYqdMk4X0VrKod1gzeoX8bGl8DMg==" }, "abbrev": { "version": "1.1.1", @@ -98,7 +98,7 @@ "integrity": "sha1-u13KOCu5TwXhUZQ3PRb9O6HKEQ0=", "requires": { "delegates": "1.0.0", - "readable-stream": "2.3.3" + "readable-stream": "2.3.6" } }, "asap": { @@ -121,7 +121,7 @@ "resolved": "https://registry.npmjs.org/async/-/async-2.6.0.tgz", "integrity": "sha512-xAfGg1/NTLBBKlHFmnd7PlmUW9KhVQIUuSrYem9xzFUZy13ScvtyGGejaae9iAVRiRq9+Cx7DPFaAAhCpyxyPw==", "requires": { - "lodash": "4.17.4" + "lodash": "4.17.5" } }, "asynckit": { @@ -135,9 +135,9 @@ "integrity": "sha1-FDQt0428yU0OW4fXY81jYSwOeU8=" }, "aws4": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.6.0.tgz", - "integrity": "sha1-g+9cqGCysy5KDe7e6MdxudtXRx4=" + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.7.0.tgz", + "integrity": "sha512-32NDda82rhwD9/JBCCkB+MRYDp0oSvlo2IL6rQWA10PQi7tDUM3eqMSltXmY+Oyl/7N3P3qNtAlv7X0d9bI28w==" }, "balanced-match": { "version": "1.0.0", @@ -145,9 +145,9 @@ "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" }, "base-x": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.3.tgz", - "integrity": "sha512-qKXPTB94LxXhJs8hqwTdyVTiDXMFTRUFj5F7FnWOW19ALCfANf2lHHUnEcY43g3DaVi4X8E2oDCkHIN8bjr32Q==", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.4.tgz", + "integrity": "sha512-UYOadoSIkEI/VrRGSG6qp93rp2WdokiAiNYDfGW5qURAY8GiAQkvMbwNNSDYiVJopqv4gCna7xqf4rrNGp+5AA==", "requires": { "safe-buffer": "5.1.1" } @@ -184,7 +184,7 @@ "resolved": "https://registry.npmjs.org/bignum/-/bignum-0.12.5.tgz", "integrity": "sha1-II8rDhjrj9aVCRfjcY5M2FzM/80=", "requires": { - "nan": "2.8.0", + "nan": "2.10.0", "node-pre-gyp": "0.6.39" } }, @@ -202,9 +202,9 @@ } }, "bitcoin-ops": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/bitcoin-ops/-/bitcoin-ops-1.4.0.tgz", - "integrity": "sha512-hSbFP1t/hRCdTWXoSUarhwySo8g1UqIjopXNaJAf+Gi6rTzWmPEKG1khXbNIPeHLskonR1Lq09KPyu37l+7zGQ==" + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/bitcoin-ops/-/bitcoin-ops-1.4.1.tgz", + "integrity": "sha512-pef6gxZFztEhaE9RY9HmWVmiIHqCb2OyS4HPKkpc6CIiiOa3Qmuoylxc5P2EkU3w+5eTSifI9SEZC88idAIGow==" }, "bitcoinjs-lib-zcash": { "version": "git+https://github.com/runn1ng/bitcoinjs-lib.git#986da96cb320528dee491a5f445bb502a9fb4e72", @@ -212,33 +212,27 @@ "bech32": "1.1.3", "bigi": "1.4.2", "bip66": "1.1.5", - "bitcoin-ops": "1.4.0", + "bitcoin-ops": "1.4.1", "bs58check": "2.1.1", - "create-hash": "1.1.3", - "create-hmac": "1.1.6", + "create-hash": "1.2.0", + "create-hmac": "1.1.7", "ecurve": "1.0.6", "merkle-lib": "2.0.10", "pushdata-bitcoin": "1.0.1", - "randombytes": "2.0.5", + "randombytes": "2.0.6", "safe-buffer": "5.1.1", "typeforce": "1.12.0", - "varuint-bitcoin": "1.0.4", + "varuint-bitcoin": "1.1.0", "wif": "2.0.6" - }, - "dependencies": { - "merkle-lib": { - "version": "2.0.10", - "resolved": "https://registry.npmjs.org/merkle-lib/-/merkle-lib-2.0.10.tgz", - "integrity": "sha1-grjbrnXieneFOItz+ddyXQ9vMyY=" - } } }, "bl": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.1.tgz", - "integrity": "sha1-ysMo977kVzDUBLaSID/LWQ4XLV4=", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.2.tgz", + "integrity": "sha512-e8tQYnZodmebYDWGH7KMRvtzKXaJHx3BbilrgZCfvyLUYdKpK1t5PSPmpkny/SgiTSCnjfLW7v5rlONXVFkQEA==", "requires": { - "readable-stream": "2.3.3" + "readable-stream": "2.3.6", + "safe-buffer": "5.1.1" } }, "block-stream": { @@ -258,9 +252,9 @@ } }, "brace-expansion": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", - "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "requires": { "balanced-match": "1.0.0", "concat-map": "0.0.1" @@ -271,7 +265,7 @@ "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz", "integrity": "sha1-vhYedsNU9veIrkBx9j806MTwpCo=", "requires": { - "base-x": "3.0.3" + "base-x": "3.0.4" } }, "bs58check": { @@ -280,7 +274,7 @@ "integrity": "sha512-okRQiWc5FJuA2VOwQ1hB7Sf0MyEFg/EwRN12h4b8HrJoGkZ3xq1CGjkaAfYloLcZyqixQnO5mhPpN6IcHSplVg==", "requires": { "bs58": "4.0.1", - "create-hash": "1.1.3" + "create-hash": "1.2.0" } }, "caseless": { @@ -313,9 +307,9 @@ "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" }, "combined-stream": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", - "integrity": "sha1-k4NwpXtKUd6ix3wV1cX9+JUWQAk=", + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz", + "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=", "requires": { "delayed-stream": "1.0.0" } @@ -336,27 +330,28 @@ "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, "create-hash": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.1.3.tgz", - "integrity": "sha1-YGBCrIuSYnUPSDyt2rD1gZFy2P0=", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", + "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", "requires": { "cipher-base": "1.0.4", "inherits": "2.0.3", - "ripemd160": "2.0.1", - "sha.js": "2.4.9" + "md5.js": "1.3.4", + "ripemd160": "2.0.2", + "sha.js": "2.4.11" } }, "create-hmac": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.6.tgz", - "integrity": "sha1-rLniIaThe9sHbpBlfEK5PjcmzwY=", + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", + "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", "requires": { "cipher-base": "1.0.4", - "create-hash": "1.1.3", + "create-hash": "1.2.0", "inherits": "2.0.3", - "ripemd160": "2.0.1", + "ripemd160": "2.0.2", "safe-buffer": "5.1.1", - "sha.js": "2.4.9" + "sha.js": "2.4.11" } }, "cryptiles": { @@ -390,6 +385,14 @@ "ms": "2.0.0" } }, + "decompress-response": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-3.3.0.tgz", + "integrity": "sha1-gKTdMjdIOEv6JICDYirt7Jgq3/M=", + "requires": { + "mimic-response": "1.0.0" + } + }, "deep-extend": { "version": "0.4.2", "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.4.2.tgz", @@ -429,9 +432,9 @@ } }, "end-of-stream": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.0.tgz", - "integrity": "sha1-epDYM+/abPpurA9JSduw+tOmMgY=", + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", + "integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==", "requires": { "once": "1.4.0" } @@ -440,7 +443,7 @@ "version": "git+https://github.com/coinfoundry/equihashverify.git#6c78fc8d560ebf8599b51c07298e6830a82d85d2", "requires": { "bindings": "1.3.0", - "nan": "2.8.0", + "nan": "2.10.0", "node-gyp": "3.6.2" } }, @@ -470,8 +473,8 @@ "integrity": "sha1-M8GDrPGTJ27KqYFDpp6Uv+4XUNE=", "requires": { "asynckit": "0.4.0", - "combined-stream": "1.0.5", - "mime-types": "2.1.17" + "combined-stream": "1.0.6", + "mime-types": "2.1.18" } }, "fs.realpath": { @@ -573,11 +576,12 @@ "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=" }, "hash-base": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-2.0.2.tgz", - "integrity": "sha1-ZuodhW206KVHDK32/OI65SRO8uE=", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.0.4.tgz", + "integrity": "sha1-X8hoaEfs1zSZQDMZprCj8/auSRg=", "requires": { - "inherits": "2.0.3" + "inherits": "2.0.3", + "safe-buffer": "5.1.1" } }, "hawk": { @@ -603,7 +607,7 @@ "requires": { "assert-plus": "0.2.0", "jsprim": "1.4.1", - "sshpk": "1.13.1" + "sshpk": "1.14.1" } }, "inflight": { @@ -701,15 +705,24 @@ } }, "lodash": { - "version": "4.17.4", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", - "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=" + "version": "4.17.5", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==" }, "long": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==" }, + "md5.js": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.4.tgz", + "integrity": "sha1-6b296UogpawYsENA/Fdk1bCdkB0=", + "requires": { + "hash-base": "3.0.4", + "inherits": "2.0.3" + } + }, "merkle-bitcoin": { "version": "git+https://github.com/joshuayabut/merkle-bitcoin.git#ec00ae20ba60d444e150ead03c747695ddaa83a1", "requires": { @@ -723,25 +736,35 @@ } } }, + "merkle-lib": { + "version": "2.0.10", + "resolved": "https://registry.npmjs.org/merkle-lib/-/merkle-lib-2.0.10.tgz", + "integrity": "sha1-grjbrnXieneFOItz+ddyXQ9vMyY=" + }, "mime-db": { - "version": "1.30.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.30.0.tgz", - "integrity": "sha1-dMZD2i3Z1qRTmZY0ZbJtXKfXHwE=" + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==" }, "mime-types": { - "version": "2.1.17", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.17.tgz", - "integrity": "sha1-Cdejk/A+mVp5+K+Fe3Cp4KsWVXo=", + "version": "2.1.18", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "requires": { - "mime-db": "1.30.0" + "mime-db": "1.33.0" } }, + "mimic-response": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.0.tgz", + "integrity": "sha1-3z02Uqc/3ta5sLJBRub9BSNTRY4=" + }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "requires": { - "brace-expansion": "1.1.8" + "brace-expansion": "1.1.11" } }, "minimist": { @@ -763,16 +786,16 @@ "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, "nan": { - "version": "2.8.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.8.0.tgz", - "integrity": "sha1-7XFfP+neArV6XmJS2QqWZ14fCFo=" + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.10.0.tgz", + "integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA==" }, "node-abi": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.1.2.tgz", - "integrity": "sha512-hmUtb8m75RSi7N+zZLYqe75XDvZB+6LyTBPkj2DConvNgQet2e3BIqEwe1LLvqMrfyjabuT5ZOrTioLCH1HTdA==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.3.0.tgz", + "integrity": "sha512-zwm6vU3SsVgw3e9fu48JBaRBCJGIvAgysDsqtf5+vEexFE71bEOtaMWb5zr/zODZNzTPtQlqUUpC79k68Hspow==", "requires": { - "semver": "5.4.1" + "semver": "5.5.0" } }, "node-gyp": { @@ -787,7 +810,7 @@ "mkdirp": "0.5.1", "nopt": "3.0.6", "npmlog": "4.1.2", - "osenv": "0.1.4", + "osenv": "0.1.5", "request": "2.81.0", "rimraf": "2.6.2", "semver": "5.3.0", @@ -820,10 +843,10 @@ "mkdirp": "0.5.1", "nopt": "4.0.1", "npmlog": "4.1.2", - "rc": "1.2.2", + "rc": "1.2.6", "request": "2.81.0", "rimraf": "2.6.2", - "semver": "5.4.1", + "semver": "5.5.0", "tar": "2.2.1", "tar-pack": "3.4.1" } @@ -839,7 +862,7 @@ "integrity": "sha1-0NRoWv1UFRk8jHUFYC0NF81kR00=", "requires": { "abbrev": "1.1.1", - "osenv": "0.1.4" + "osenv": "0.1.5" } }, "npmlog": { @@ -887,9 +910,9 @@ "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=" }, "osenv": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.4.tgz", - "integrity": "sha1-Qv5tWVPfBsgGS+bxdsPQWqqjRkQ=", + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.5.tgz", + "integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==", "requires": { "os-homedir": "1.0.2", "os-tmpdir": "1.0.2" @@ -905,10 +928,39 @@ "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-0.2.0.tgz", "integrity": "sha1-M+8wxcd9TqIcWlOGnZG1bY8lVeU=" }, + "prebuild-install": { + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-2.5.3.tgz", + "integrity": "sha512-/rI36cN2g7vDQnKWN8Uzupi++KjyqS9iS+/fpwG4Ea8d0Pip0PQ5bshUNzVwt+/D2MRfhVAplYMMvWLqWrCF/g==", + "requires": { + "detect-libc": "1.0.3", + "expand-template": "1.1.0", + "github-from-package": "0.0.0", + "minimist": "1.2.0", + "mkdirp": "0.5.1", + "node-abi": "2.3.0", + "noop-logger": "0.1.1", + "npmlog": "4.1.2", + "os-homedir": "1.0.2", + "pump": "2.0.1", + "rc": "1.2.6", + "simple-get": "2.7.0", + "tar-fs": "1.16.0", + "tunnel-agent": "0.6.0", + "which-pm-runs": "1.0.0" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + } + } + }, "process-nextick-args": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=" + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==" }, "promise": { "version": "8.0.1", @@ -934,16 +986,16 @@ "@protobufjs/pool": "1.1.0", "@protobufjs/utf8": "1.1.0", "@types/long": "3.0.32", - "@types/node": "8.10.6", + "@types/node": "8.10.9", "long": "4.0.0" } }, "pump": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/pump/-/pump-1.0.3.tgz", - "integrity": "sha512-8k0JupWme55+9tCVE+FS5ULT3K6AbgqrGa58lTT49RpyfwwcGedHqaC5LlQNdEAumn/wFsu6aPwkuPMioy8kqw==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pump/-/pump-2.0.1.tgz", + "integrity": "sha512-ruPMNRkN3MHP1cWJc9OWr+T/xDP0jhXYCLfJcBuX54hhfIBnaQmAUMfDcG4DM5UMWByBbJY69QSphm3jtDKIkA==", "requires": { - "end-of-stream": "1.4.0", + "end-of-stream": "1.4.1", "once": "1.4.0" } }, @@ -957,7 +1009,7 @@ "resolved": "https://registry.npmjs.org/pushdata-bitcoin/-/pushdata-bitcoin-1.0.1.tgz", "integrity": "sha1-FZMdPNlnreUiBvUjqnMxrvfUOvc=", "requires": { - "bitcoin-ops": "1.4.0" + "bitcoin-ops": "1.4.1" } }, "qs": { @@ -966,17 +1018,17 @@ "integrity": "sha1-E+JtKK1rD/qpExLNO/cI7TUecjM=" }, "randombytes": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.5.tgz", - "integrity": "sha512-8T7Zn1AhMsQ/HI1SjcCfT/t4ii3eAqco3yOcSzS4mozsOz69lHLsoMXmF9nZgnFanYscnSlUSgs8uZyKzpE6kg==", + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.6.tgz", + "integrity": "sha512-CIQ5OFxf4Jou6uOKe9t1AOgqpeU5fd70A8NPdHSGeYXqXsPe6peOwI0cUl88RWZ6sP1vPMV3avd/R6cZ5/sP1A==", "requires": { "safe-buffer": "5.1.1" } }, "rc": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.2.tgz", - "integrity": "sha1-2M6ctX6NZNnHut2YdsfDTL48cHc=", + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.6.tgz", + "integrity": "sha1-6xiYnG1PTxYsOZ953dKfODVWgJI=", "requires": { "deep-extend": "0.4.2", "ini": "1.3.5", @@ -992,16 +1044,16 @@ } }, "readable-stream": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", - "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "requires": { "core-util-is": "1.0.2", "inherits": "2.0.3", "isarray": "1.0.0", - "process-nextick-args": "1.0.7", + "process-nextick-args": "2.0.0", "safe-buffer": "5.1.1", - "string_decoder": "1.0.3", + "string_decoder": "1.1.1", "util-deprecate": "1.0.2" } }, @@ -1011,9 +1063,9 @@ "integrity": "sha1-xpKJRqDgbF+Nb4qTM0af/aRimKA=", "requires": { "aws-sign2": "0.6.0", - "aws4": "1.6.0", + "aws4": "1.7.0", "caseless": "0.12.0", - "combined-stream": "1.0.5", + "combined-stream": "1.0.6", "extend": "3.0.1", "forever-agent": "0.6.1", "form-data": "2.1.4", @@ -1023,15 +1075,15 @@ "is-typedarray": "1.0.0", "isstream": "0.1.2", "json-stringify-safe": "5.0.1", - "mime-types": "2.1.17", + "mime-types": "2.1.18", "oauth-sign": "0.8.2", "performance-now": "0.2.0", "qs": "6.4.0", "safe-buffer": "5.1.1", "stringstream": "0.0.5", - "tough-cookie": "2.3.3", + "tough-cookie": "2.3.4", "tunnel-agent": "0.6.0", - "uuid": "3.1.0" + "uuid": "3.2.1" } }, "rimraf": { @@ -1043,11 +1095,11 @@ } }, "ripemd160": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.1.tgz", - "integrity": "sha1-D0WEKVxTo2KK9+bXmsohzlfRxuc=", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz", + "integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==", "requires": { - "hash-base": "2.0.2", + "hash-base": "3.0.4", "inherits": "2.0.3" } }, @@ -1057,9 +1109,9 @@ "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" }, "semver": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.4.1.tgz", - "integrity": "sha512-WfG/X9+oATh81XtllIo/I8gOiY9EXRdv1cQdyykeXK17YcUW3EXUAi2To4pcH6nZtJPr7ZOpM5OMyWJZm+8Rsg==" + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==" }, "set-blocking": { "version": "2.0.0", @@ -1067,9 +1119,9 @@ "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" }, "sha.js": { - "version": "2.4.9", - "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.9.tgz", - "integrity": "sha512-G8zektVqbiPHrylgew9Zg1VRB1L/DtXNUVAM6q4QLy8NE3qtHlFXTf8VLL4k1Yl6c7NMjtZUTdXV+X44nFaT6A==", + "version": "2.4.11", + "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", + "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", "requires": { "inherits": "2.0.3", "safe-buffer": "5.1.1" @@ -1080,14 +1132,19 @@ "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" }, + "simple-concat": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.0.tgz", + "integrity": "sha1-c0TLuLbib7J9ZrL8hvn21Zl1IcY=" + }, "simple-get": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-1.4.3.tgz", - "integrity": "sha1-6XVe2kB+ltpAxeUVjJ6jezO+y+s=", + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-2.7.0.tgz", + "integrity": "sha512-RkE9rGPHcxYZ/baYmgJtOSM63vH0Vyq+ma5TijBcLla41SWlh8t6XYIGMR/oeZcmr+/G8k+zrClkkVrtnQ0esg==", "requires": { + "decompress-response": "3.3.0", "once": "1.4.0", - "unzip-response": "1.0.2", - "xtend": "4.0.1" + "simple-concat": "1.0.0" } }, "sntp": { @@ -1099,9 +1156,9 @@ } }, "sshpk": { - "version": "1.13.1", - "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.13.1.tgz", - "integrity": "sha1-US322mKHFEMW3EwY/hzx2UBzm+M=", + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.14.1.tgz", + "integrity": "sha1-Ew9Zde3a2WPx1W+SuaxsUfqfg+s=", "requires": { "asn1": "0.2.3", "assert-plus": "1.0.0", @@ -1131,9 +1188,9 @@ } }, "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "requires": { "safe-buffer": "5.1.1" } @@ -1175,6 +1232,17 @@ "mkdirp": "0.5.1", "pump": "1.0.3", "tar-stream": "1.5.5" + }, + "dependencies": { + "pump": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/pump/-/pump-1.0.3.tgz", + "integrity": "sha512-8k0JupWme55+9tCVE+FS5ULT3K6AbgqrGa58lTT49RpyfwwcGedHqaC5LlQNdEAumn/wFsu6aPwkuPMioy8kqw==", + "requires": { + "end-of-stream": "1.4.1", + "once": "1.4.0" + } + } } }, "tar-pack": { @@ -1186,7 +1254,7 @@ "fstream": "1.0.11", "fstream-ignore": "1.0.5", "once": "1.4.0", - "readable-stream": "2.3.3", + "readable-stream": "2.3.6", "rimraf": "2.6.2", "tar": "2.2.1", "uid-number": "0.0.6" @@ -1197,16 +1265,16 @@ "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-1.5.5.tgz", "integrity": "sha512-mQdgLPc/Vjfr3VWqWbfxW8yQNiJCbAZ+Gf6GDu1Cy0bdb33ofyiNGBtAY96jHFhDuivCwgW1H9DgTON+INiXgg==", "requires": { - "bl": "1.2.1", - "end-of-stream": "1.4.0", - "readable-stream": "2.3.3", + "bl": "1.2.2", + "end-of-stream": "1.4.1", + "readable-stream": "2.3.6", "xtend": "4.0.1" } }, "tough-cookie": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.3.tgz", - "integrity": "sha1-C2GKVWW23qkL80JdBNVe3EdadWE=", + "version": "2.3.4", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "requires": { "punycode": "1.4.1" } @@ -1235,25 +1303,23 @@ "resolved": "https://registry.npmjs.org/uid-number/-/uid-number-0.0.6.tgz", "integrity": "sha1-DqEOgDXo61uOREnwbaHHMGY7qoE=" }, - "unzip-response": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/unzip-response/-/unzip-response-1.0.2.tgz", - "integrity": "sha1-uYTwh3/AqJwsdzzB73tbIytbBv4=" - }, "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" }, "uuid": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz", - "integrity": "sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==" + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==" }, "varuint-bitcoin": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/varuint-bitcoin/-/varuint-bitcoin-1.0.4.tgz", - "integrity": "sha1-2BLF2uFuMvYFRLat7h1L4TB9AoM=" + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/varuint-bitcoin/-/varuint-bitcoin-1.1.0.tgz", + "integrity": "sha512-jCEPG+COU/1Rp84neKTyDJQr478/hAfVp5xxYn09QEH0yBjbmPeMfuuQIrp+BUD83hybtYZKhr5elV3bvdV1bA==", + "requires": { + "safe-buffer": "5.1.1" + } }, "verror": { "version": "1.10.0", @@ -1280,6 +1346,11 @@ "isexe": "2.0.0" } }, + "which-pm-runs": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/which-pm-runs/-/which-pm-runs-1.0.0.tgz", + "integrity": "sha1-Zws6+8VS4LVd9rd4DKdGFfI60cs=" + }, "wide-align": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.2.tgz", @@ -1307,38 +1378,12 @@ "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=" }, "zeromq": { - "version": "git+https://github.com/coinfoundry/zeromq.js.git#1b60b36d468eb108cdf5bb2db17abc8c93f6b254", + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/zeromq/-/zeromq-4.6.0.tgz", + "integrity": "sha512-sU7pQqQj7f/C6orJZAXls+NEKaVMZZtnZqpMPTq5d5dP78CmdC0g15XIviFAN6poPuKl9qlGt74vipOUUuNeWg==", "requires": { - "nan": "2.8.0", - "prebuild-install": "2.3.0" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" - }, - "prebuild-install": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-2.3.0.tgz", - "integrity": "sha512-gzjq2oHB8oMbzJSsSh9MQ64zrXZGt092/uT4TLZlz2qnrPxpWqp4vYB7LZrDxnlxf5RfbCjkgDI/z0EIVuYzAw==", - "requires": { - "expand-template": "1.1.0", - "github-from-package": "0.0.0", - "minimist": "1.2.0", - "mkdirp": "0.5.1", - "node-abi": "2.1.2", - "noop-logger": "0.1.1", - "npmlog": "4.1.2", - "os-homedir": "1.0.2", - "pump": "1.0.3", - "rc": "1.2.2", - "simple-get": "1.4.3", - "tar-fs": "1.16.0", - "tunnel-agent": "0.6.0", - "xtend": "4.0.1" - } - } + "nan": "2.10.0", + "prebuild-install": "2.5.3" } } } diff --git a/package.json b/package.json index 7b5f6ea..6be3ebe 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "merkle-bitcoin": "git+https://github.com/joshuayabut/merkle-bitcoin.git", "bitcoinjs-lib-zcash": "git+https://github.com/runn1ng/bitcoinjs-lib.git#zcash", "promise": "*", - "zeromq": "git+https://github.com/coinfoundry/zeromq.js.git", + "zeromq": "^4.6.0", "protobufjs": "^6.8.6" }, "engines": { From 3eb31118ad9dd1b6eb8246216f32803df76eff06 Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Mon, 23 Apr 2018 08:58:12 +0200 Subject: [PATCH 37/44] WIP --- lib/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 68b07fc..9fb4638 100644 --- a/lib/index.js +++ b/lib/index.js @@ -123,7 +123,7 @@ pool.on('share', function (isValidShare, isValidBlock, data) { }; const rawMsg = config.publisherJson ? JSON.stringify(share) : - ShareMessage.encode(ShareMessage.create(share)).finish(); + Buffer.from(ShareMessage.encode(ShareMessage.create(share)).finish()); // publish sock.send([config.publisherTopic, pubFlagsBuf, rawMsg]); From 5bc36080807ae1478160ee31d2f4266d360bf945 Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Sun, 29 Apr 2018 20:42:50 +0200 Subject: [PATCH 38/44] Code style --- lib/pool.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index dd9715e..56b4463 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -611,9 +611,7 @@ var pool = module.exports = function pool(options, authorizeFn) { ProcessBlockTemplate({ response: rpcData.result }, function(error, rpcData, processedBlock) { if(processedBlock) { emitLog('New block notification via BT Stream'); - } - - else if(error == null && force) { + } else if(error == null && force) { _this.jobManager.updateCurrentJob(rpcData); } }); From bc7e9d680a9f52570a7ef03a559e640dfef475da Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Sat, 22 Sep 2018 22:16:05 +0200 Subject: [PATCH 39/44] Switch endianess for flags --- lib/pool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pool.js b/lib/pool.js index 56b4463..ed548d1 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -618,7 +618,7 @@ var pool = module.exports = function pool(options, authorizeFn) { } subSock.on('message', function(topic, flags, message) { - flags = flags.readUIntBE(0, 4); + flags = flags.readUIntLE(0, 4); const now = new Date(); const force = lastJobRefresh == null || (now - lastJobRefresh) >= (options.jobRebroadcastTimeout * 0.9 * 1000); From f544beea418707890463b6cf8e2780276942fad3 Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Tue, 2 Oct 2018 15:12:14 +0200 Subject: [PATCH 40/44] Support for btStream on Curve --- lib/pool.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/pool.js b/lib/pool.js index ed548d1..7c4ec78 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -599,6 +599,15 @@ var pool = module.exports = function pool(options, authorizeFn) { function SetupBtStream(){ var subSock = zmq.socket('sub'); + + if(options.btStream.rawSharedEncryptionKey) { + var curve = zmq.curveKeypair(); + subSock.curve_server = 0; + subSock.curve_serverkey = new Buffer(options.btStream.rawSharedEncryptionKey, "hex"); + subSock.curve_publickey = curve.public; + subSock.curve_secretkey = curve.secret; + } + subSock.connect(options.btStream.url); subSock.subscribe(options.btStream.topic); From b4eb5ed9f9ee413265899e8715933afb0c8705b1 Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Tue, 2 Oct 2018 15:28:22 +0200 Subject: [PATCH 41/44] WIP --- lib/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/index.js b/lib/index.js index 9fb4638..79f42ca 100644 --- a/lib/index.js +++ b/lib/index.js @@ -78,6 +78,11 @@ const pubFlags = config.publisherJson ? 1 : 2; // WireFormat.Json or WireFormat const pubFlagsBuf = Buffer.allocUnsafe(4); pubFlagsBuf.writeUInt32BE(pubFlags, 0); +if(config.publisherRawServerSecret) { + subSock.curve_server = 1; + subSock.curve_serverkey = new Buffer(config.publisherRawServerSecret, "hex"); +} + if(!config.publisherConnect) { sock.bindSync(config.publisherSocket); pool.emitInfoLog('Bound to ZMQ publisher socket ' + config.publisherSocket); From c0221574f69813844f7ba4c33aeea75724619da4 Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Tue, 2 Oct 2018 15:32:26 +0200 Subject: [PATCH 42/44] WIP --- lib/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 79f42ca..f165f87 100644 --- a/lib/index.js +++ b/lib/index.js @@ -79,8 +79,8 @@ const pubFlagsBuf = Buffer.allocUnsafe(4); pubFlagsBuf.writeUInt32BE(pubFlags, 0); if(config.publisherRawServerSecret) { - subSock.curve_server = 1; - subSock.curve_serverkey = new Buffer(config.publisherRawServerSecret, "hex"); + sock.curve_server = 1; + sock.curve_serverkey = new Buffer(config.publisherRawServerSecret, "hex"); } if(!config.publisherConnect) { From 9709e8802f25b6142c06ab3310131856888a95c7 Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Thu, 4 Oct 2018 09:11:40 +0200 Subject: [PATCH 43/44] Implement static diff --- lib/pool.js | 17 ++++++++++------- lib/stratum.js | 2 ++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index 7c4ec78..08248bf 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -481,14 +481,17 @@ var pool = module.exports = function pool(options, authorizeFn) { _this.jobManager.updateCurrentJob(rpcData); }); - }).on('client.connected', function (client) { - if (typeof(_this.varDiff[client.socket.localPort]) !== 'undefined') { - _this.varDiff[client.socket.localPort].manageClient(client); - } - - client.on('difficultyChanged', function (diff) { + }).on('client.connected', function(client){ + client.on('client.authorized', function(client) { + const m = /;?d=(\d*(\.\d+)?)/.exec(client.workerPass); + if(m) { + const staticDiff = parseFloat(m[1]); + client.enqueueNextDifficulty(staticDiff); + } else if (typeof(_this.varDiff[client.socket.localPort]) !== 'undefined') { + _this.varDiff[client.socket.localPort].manageClient(client); + } + }).on('difficultyChanged', function(diff){ _this.emit('difficultyUpdate', client.workerName, diff); - }).on('subscription', function (params, resultCallback) { var extraNonce = _this.jobManager.extraNonceCounter.next(); diff --git a/lib/stratum.js b/lib/stratum.js index 70bb0c2..9932dab 100644 --- a/lib/stratum.js +++ b/lib/stratum.js @@ -139,6 +139,8 @@ var StratumClient = function(options){ if (result.disconnect === true) { options.socket.destroy(); } + + _this.emit('client.authorized', _this); }); } From 27339474ec1b018f49187b7837c8234f43b8a977 Mon Sep 17 00:00:00 2001 From: Oliver Weichhold Date: Thu, 4 Oct 2018 09:32:54 +0200 Subject: [PATCH 44/44] curve --- lib/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index f165f87..8eaeae8 100644 --- a/lib/index.js +++ b/lib/index.js @@ -79,8 +79,10 @@ const pubFlagsBuf = Buffer.allocUnsafe(4); pubFlagsBuf.writeUInt32BE(pubFlags, 0); if(config.publisherRawServerSecret) { + sock.curve_secretkey = new Buffer(config.publisherRawServerSecret, "hex"); sock.curve_server = 1; - sock.curve_serverkey = new Buffer(config.publisherRawServerSecret, "hex"); + + pool.emitInfoLog('Enabled ZMQ Curve server mode'); } if(!config.publisherConnect) {