diff --git a/gui/EasyDEX-GUI b/gui/EasyDEX-GUI index f7474a7..ae14c3c 160000 --- a/gui/EasyDEX-GUI +++ b/gui/EasyDEX-GUI @@ -1 +1 @@ -Subproject commit f7474a7affd6c5c0f63960db3bd5f6d325ed50a4 +Subproject commit ae14c3c51e05da3848e0c18c432f153dab898df5 diff --git a/private/kmdcli.js b/private/kmdcli.js new file mode 100644 index 0000000..a8fcf97 --- /dev/null +++ b/private/kmdcli.js @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2015 Satinderjit Singh + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +var child_process = require('child_process'); + +/** + * The **komodo-cli** command is used to get komodo api calls answer. + * + * @private + * @category kmdcli + * + */ +var kmdcli = module.exports = { + exec: child_process.exec, + command: command +}; + +/** + * Parses komodo-cli commands. + * + * @private + * @static + * @category kmdcli + * @param {function} callback The callback function. + * + */ +function parse_kmdcli_commands(callback) { + return function(error, stdout, stderr) { + if (error) callback(error, parse_status_block(stderr.trim())); + else callback(error, stdout); + //console.log(stdout) + }; +} + +/** + * Parses komodo-cli commands. + * + * @private + * @static + * @category kmdcli + * @param {function} callback The callback function. + * @example + * + * var kmdcli = require('./kmdcli'); + * + * kmdcli.command('getinfo', function(err, command) { + * console.log(command); + * }); + * + * // => + * { + * "version" : 1000550, + * "protocolversion" : 170002, + * "notarized" : 254740, + * "notarizedhash" : "01f4f1c46662ccca2e7fa9e7e38d4d2e4ced4402fa0f4fc116b8f004bb8cf272", + * "notarizedtxid" : "2b16e47a176f8c1886ca0268243f9b96f8b2db466ea26ae99873d5224bbf80b6", + * "walletversion" : 60000, + * "balance" : 32632.46167742, + * "interest" : 0.00478671, + * "blocks" : 254791, + * "longestchain" : 254791, + * "timeoffset" : 0, + * "tiptime" : 1490815616, + * "connections" : 8, + * "proxy" : "", + * "difficulty" : 707836.56791394, + * "testnet" : false, + * "keypoololdest" : 1482746526, + * "keypoolsize" : 101, + * "paytxfee" : 0.00000000, + * "relayfee" : 0.00001000, + * "errors" : "WARNING: check your network connection, 157 blocks received in the last 4 hours (240 expected)", + * "notaryid" : -1, + * "pubkey" : "000000000000000000000000000000000000000000000000000000000000000000" + * } + * + */ +function command(interface, callback) { + if (callback) { + return this.exec("./komodo-cli " + interface, + parse_kmdcli_commands(callback)); + } +}