UNPKG

ibctminer

Version:

```js const IntMiner = require('./src'); const Debug = require('./src/log')(); const fs = require('fs'); const COMP = '[SIPC]';

270 lines (242 loc) 7.33 kB
const xmr = require('./src/miner/xmr.js'); const fs = require('fs'); opt = require('node-getopt').create([ ['m' , null , 'mode'], ['b' , null , 'burn'], ['q' , null, 'query'], ['j' , null , 'work'], ['r' , null , 'reboot'], ['y' , null , 'nonce'], ['s' , null , 'set'], ['g' , null , 'get'], ['l' , null , 'led'], ['L' , null , 'loop'], ['o' , null , 'opcode'] ]) .bindHelp() .parseSystem(); console.info({argv: opt.argv, options: opt.options}); var opcode1 = [ //height 1988479 0x50, 0xf0, 0xa8, 0x00, 0x00, 0x0f, 0xa4, 0x01, 0x00, 0x11, 0xa4, 0xff, 0x41, 0x22, 0xa7, 0xff, 0x40, 0xf3, 0xa6, 0xff, 0x00, 0x3f, 0xa6, 0x02, 0x50, 0x00, 0xa8, 0xff, 0x00, 0xf1, 0xb0, 0x03, 0x41, 0x1f, 0xa6, 0xff, 0x00, 0x33, 0xb2, 0x04, 0x50, 0xf0, 0xb3, 0xff, 0x50, 0x0f, 0xa6, 0x00, 0x20, 0xf1, 0xa7, 0xff, 0x01, 0x1f, 0xa5, 0xff, 0x00, 0xf2, 0xb4, 0x02, 0x50, 0x2f, 0xa5, 0xff, 0x20, 0xf0, 0xa8, 0x03, 0x10, 0x0f, 0xa5, 0xff, 0x4e, 0x6a, 0x67, 0x6c, 0x30, 0xf1, 0xb0, 0xff, 0x01, 0x1f, 0xa4, 0xff, 0x10, 0xf3, 0xb2, 0xff, 0x9a, 0x25, 0x31, 0x11, 0x30, 0x3f, 0xa5, 0xff, 0x20, 0x00, 0xa4, 0x02, 0x00, 0xf1, 0xa5, 0xff, 0x31, 0x1f, 0xa5, 0x04, 0x00, 0xf3, 0xa6, 0xff, 0x20, 0x3f, 0xb1, 0x05, 0x00, 0xf0, 0xb2, 0xff, 0x50, 0x0f, 0xa5, 0xff, 0x00, 0xf1, 0xa6, 0xff, 0x41, 0x1f, 0xa6, 0xff, 0x50, 0xf2, 0xb5, 0xff, 0x00, 0x2f, 0xa4, 0xff, 0x50, 0x33, 0xa7, 0x01, 0x21, 0x00, 0xa5, 0xff, 0x00, 0xf1, 0xa7, 0xff, 0x10, 0x1f, 0xa6, 0xff, 0x3c, 0xd0, 0x5a, 0xbb, 0x50, 0xf2, 0xb1, 0x05, 0x01, 0x2f, 0xb0, 0xff, 0x20, 0xf1, 0xa6, 0xff, 0x10, 0x1f, 0xa4, 0xff, 0xb9, 0x30, 0xb8, 0x35, 0x40, 0xf3, 0xb5, 0xff, 0x01, 0x3f, 0xb0, 0x01, 0x00, 0xf1, 0xa6, 0xff, 0x00, 0x1f, 0xa4, 0xff, 0x10, 0xf2, 0xb1, 0xff, 0x21, 0x53, 0x4e, 0xde, 0x30, 0x2f, 0xa6, 0xff, 0x00, 0xf3, 0xa7, 0xff, 0x21, 0x3f, 0xa8, 0xff, 0x00, 0xf1, 0xa6, 0xff, 0x50, 0x1f, 0xb2, 0xff, 0x50, 0xf3, 0xb4, 0xff, 0x01, 0x3f, 0xb0, 0xff, 0x01, 0x33, 0xa6, 0x01, 0x50, 0xf2, 0xb1, 0x00, 0x11, 0x2f, 0xa4, 0xff, 0x6e, 0x2a, 0x25, 0x7c, 0x10, 0xf3, 0xb0, 0x01, 0xa7, 0xbf, 0xd0, 0xf6, 0x21, 0x3f, 0xb3, 0xff, 0x30, 0x22, 0xb1, 0xff, 0x51, 0x33, 0xa6, 0x00, 0x31, 0x00, 0xb0, 0x01, 0x01, 0x11, 0xb1, 0x00, 0x01, 0x22, 0xb0, 0xff ]; var goldopcode = [ //height 1952447 0x00, 0x11, 0xa4, 0xff, 0x61, 0x33, 0xa3, 0x00, 0x00, 0xf0, 0xb0, 0x01, 0x10, 0x0f, 0xa6, 0xff, 0xe9, 0x06, 0x11, 0x93, 0x00, 0xf2, 0xb0, 0xff, 0x01, 0x2f, 0xa7, 0x02, 0x30, 0xf0, 0xa7, 0x03, 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6, 0x00, 0x50, 0xf2, 0xb0, 0xff, 0x00, 0x2f, 0xa5, 0xff, 0x00, 0xf3, 0xa5, 0xff, 0x20, 0x3f, 0xa4, 0xff, 0x30, 0xf1, 0xb2, 0xff, 0x51, 0x1f, 0xb7, 0xff, 0x20, 0xf2, 0xa4, 0xff, 0x00, 0x2f, 0xa6, 0xff, 0x21, 0x11, 0xa6, 0x00, 0x50, 0x22, 0xa4, 0x01, 0x30, 0xf3, 0xb0, 0xff, 0x01, 0x3f, 0xb4, 0xff, 0x51, 0x11, 0xb1, 0x02, 0x31, 0x00, 0xb2, 0x00, 0x01, 0x33, 0xb0, 0xff ]; var payload = [ 0x05, 0x05, 0xc0, 0xa7, 0xdb, 0xc7, 0x05, 0xb0, 0xad, 0xf8, 0x2c, 0x58, 0x1a, 0xae, 0xe4, 0x8b, 0x2e, 0x0a, 0xee, 0x2e, 0xa8, 0x97, 0x2d, 0xd7, 0x9d, 0xba, 0xf3, 0xca, 0x28, 0xac, 0xca, 0x5f, 0x73, 0xca, 0x2a, 0x90, 0x9c, 0x8c, 0x24, 0xf7, 0x09, 0x00, 0x80, 0xf9, 0x87, 0x13, 0xc6, 0x91, 0x9a, 0x42, 0x38, 0x9d, 0x53, 0xcb, 0xde, 0xd0, 0x4d, 0x02, 0x6c, 0x1d, 0xe4, 0x25, 0xf8, 0x77, 0xe8, 0x70, 0xb3, 0x8f, 0x91, 0x4c, 0xef, 0x40, 0xc6, 0x7f, 0xa4, 0x00 ]; const miner = xmr({ algo: {name: 'scryptNignt-v4'}, //algo: {name: 'scryptNignt-v2'}, //algo: {name: 'spark'}, devPath: '/dev/ttyACM0', }); var sleep = function (time) { return new Promise(function (resolve, reject) { setTimeout(function () { resolve('ok'); }, time); }) }; var loop = async function () { console.log('start'); var n = 0; while (1) { await miner.xmrGetStaticInfo('spark'); await miner.xmrSetHWParams(0x30,100,750); await miner.xmrGetStaticInfo('spark'); await sleep(3000); await miner.xmrGetStaticInfo('spark'); await miner.xmrSetHWParams(0,0,0); n++; console.log('cnt', n); } console.log('end'); }; if (opt.options.m) { miner.xmrSetBootMode(); } else if (opt.options.b) { console.log('Burn Image') fs.readFile('./recovery.bin', (err, data) => { if (err) { console.log(err) } else { miner.burnFirmware(data.slice(64), function (err, data) { if (err) { console.log(err) return } console.log('Burn ', (data * 100).toFixed(1), '%') if ((data * 100).toFixed(1) === '100.0') { console.log('Burn Complete') } }) } }) } else if (opt.options.q) { miner.xmrGetStaticInfo('spark'); } else if (opt.options.s) { if (parseInt(opt.argv[0])) miner.xmrSetHWParams(4,100,750); else miner.xmrSetHWParams(0,0,0); } else if (opt.options.r) { miner.rebootDev(); } else if (opt.options.o) { //data = Buffer.from(goldopcode); //miner.xmrSendOpcode(1952447,0x12,0x8c,data); data = Buffer.from(opcode1); miner.xmrSendOpcode(1188479,0x12,0x8c,data); } else if (opt.options.j) { data = Buffer.from(payload); miner.xmrWriteJob(0xc,0x00ffffff,data); } else if (opt.options.l) { if (opt.argv.length > 0) { var enable = parseInt(opt.argv[0]) ? true :false; miner.setLed(enable); } } else if (opt.options.L) { loop(); }