diff --git a/CHANGELOG.md b/CHANGELOG.md index 68e433a..480664a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,15 @@ # Changelog -## [1.1.0](https://github.com/seegno/bitcoin-core/tree/1.1.0) (2016-09-19) -[Full Changelog](https://github.com/seegno/bitcoin-core/compare/v1.0.0...1.1.0) +## [1.2.0](https://github.com/seegno/bitcoin-core/tree/1.2.0) (2017-02-12) +[Full Changelog](https://github.com/seegno/bitcoin-core/compare/v1.1.0...1.2.0) + +**Merged pull requests:** + +- Pin docker image to 0.13.0 to avoid failing tests on newer versions [\#21](https://github.com/seegno/bitcoin-core/pull/21) ([pedrobranco](https://github.com/pedrobranco)) +- Add logging to all requests [\#19](https://github.com/seegno/bitcoin-core/pull/19) ([pedrobranco](https://github.com/pedrobranco)) + +## [v1.1.0](https://github.com/seegno/bitcoin-core/tree/v1.1.0) (2016-09-19) +[Full Changelog](https://github.com/seegno/bitcoin-core/compare/v1.0.0...v1.1.0) **Merged pull requests:** diff --git a/dist/src/errors/rpc-error.js b/dist/src/errors/rpc-error.js index daecf6e..f4e85c1 100755 --- a/dist/src/errors/rpc-error.js +++ b/dist/src/errors/rpc-error.js @@ -50,7 +50,7 @@ class RpcError extends _standardError2.default { } toString() { - return `${ this.name }: ${ this.code } ${ this.message }`; + return `${this.name}: ${this.code} ${this.message}`; } } exports.default = RpcError; diff --git a/dist/src/index.js b/dist/src/index.js index 789151a..3a6864c 100755 --- a/dist/src/index.js +++ b/dist/src/index.js @@ -25,13 +25,17 @@ var _lodash = require('lodash'); var _lodash2 = _interopRequireDefault(_lodash); +var _debugnyan = require('debugnyan'); + +var _debugnyan2 = _interopRequireDefault(_debugnyan); + var _methods = require('./methods'); var _methods2 = _interopRequireDefault(_methods); -var _request = require('request'); +var _requestLogger = require('./logging/request-logger'); -var _request2 = _interopRequireDefault(_request); +var _requestLogger2 = _interopRequireDefault(_requestLogger); var _semver = require('semver'); @@ -76,26 +80,28 @@ const networks = { class Client { constructor() { - var _ref = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; + var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; let agentOptions = _ref.agentOptions; var _ref$headers = _ref.headers; let headers = _ref$headers === undefined ? false : _ref$headers; var _ref$host = _ref.host; let host = _ref$host === undefined ? 'localhost' : _ref$host; + var _ref$logger = _ref.logger; + let logger = _ref$logger === undefined ? (0, _debugnyan2.default)('bitcoin-core') : _ref$logger; var _ref$network = _ref.network; - let network = _ref$network === undefined ? 'mainnet' : _ref$network; - let password = _ref.password; - let port = _ref.port; + let network = _ref$network === undefined ? 'mainnet' : _ref$network, + password = _ref.password, + port = _ref.port; var _ref$ssl = _ref.ssl; let ssl = _ref$ssl === undefined ? false : _ref$ssl; var _ref$timeout = _ref.timeout; - let timeout = _ref$timeout === undefined ? 30000 : _ref$timeout; - let username = _ref.username; - let version = _ref.version; + let timeout = _ref$timeout === undefined ? 30000 : _ref$timeout, + username = _ref.username, + version = _ref.version; if (!_lodash2.default.has(networks, network)) { - throw new Error(`Invalid network name "${ network }"`, { network: network }); + throw new Error(`Invalid network name "${network}"`, { network: network }); } this.agentOptions = agentOptions; @@ -114,12 +120,14 @@ class Client { let unsupported = []; if (version) { - unsupported = _lodash2.default.chain(_methods2.default).pickBy(range => !_semver2.default.satisfies(version, range)).keys().invokeMap(String.prototype.toLowerCase).value(); + unsupported = _lodash2.default.chain(_methods2.default).pickBy(method => !_semver2.default.satisfies(version, method.version)).keys().invokeMap(String.prototype.toLowerCase).value(); } - this.request = _bluebird2.default.promisifyAll(_request2.default.defaults({ + const request = (0, _requestLogger2.default)(logger); + + this.request = _bluebird2.default.promisifyAll(request.defaults({ agentOptions: this.agentOptions, - baseUrl: `${ this.ssl.enabled ? 'https' : 'http' }://${ this.host }:${ this.port }`, + baseUrl: `${this.ssl.enabled ? 'https' : 'http'}://${this.host}:${this.port}`, json: true, strictSSL: this.ssl.strict, timeout: this.timeout @@ -169,22 +177,20 @@ class Client { */ getTransactionByHash() { - var _source = source.apply(undefined, arguments); - - var _source2 = _slicedToArray(_source, 2); - - var _source2$ = _slicedToArray(_source2[0], 2); + var _source = source.apply(undefined, arguments), + _source2 = _slicedToArray(_source, 2), + _source2$ = _slicedToArray(_source2[0], 2); const hash = _source2$[0]; var _source2$$ = _source2$[1]; _source2$$ = _source2$$ === undefined ? {} : _source2$$; var _source2$$$extension = _source2$$.extension; - const extension = _source2$$$extension === undefined ? 'json' : _source2$$$extension; - const callback = _source2[1]; + const extension = _source2$$$extension === undefined ? 'json' : _source2$$$extension, + callback = _source2[1]; return _bluebird2.default.try(() => { - return this.request.getAsync(`/rest/tx/${ hash }.${ extension }`).bind(this).then(this.parser.rest); + return this.request.getAsync(`/rest/tx/${hash}.${extension}`).bind(this).then(this.parser.rest); }).asCallback(callback); } @@ -195,11 +201,9 @@ class Client { */ getBlockByHash() { - var _source3 = source.apply(undefined, arguments); - - var _source4 = _slicedToArray(_source3, 2); - - var _source4$ = _slicedToArray(_source4[0], 2); + var _source3 = source.apply(undefined, arguments), + _source4 = _slicedToArray(_source3, 2), + _source4$ = _slicedToArray(_source4[0], 2); const hash = _source4$[0]; var _source4$$ = _source4$[1]; @@ -207,12 +211,12 @@ class Client { var _source4$$$summary = _source4$$.summary; const summary = _source4$$$summary === undefined ? false : _source4$$$summary; var _source4$$$extension = _source4$$.extension; - const extension = _source4$$$extension === undefined ? 'json' : _source4$$$extension; - const callback = _source4[1]; + const extension = _source4$$$extension === undefined ? 'json' : _source4$$$extension, + callback = _source4[1]; return _bluebird2.default.try(() => { - return this.request.getAsync(`/rest/block${ summary ? '/notxdetails/' : '/' }${ hash }.${ extension }`).bind(this).then(this.parser.rest); + return this.request.getAsync(`/rest/block${summary ? '/notxdetails/' : '/'}${hash}.${extension}`).bind(this).then(this.parser.rest); }).asCallback(callback); } @@ -221,27 +225,25 @@ class Client { */ getBlockHeadersByHash() { - var _source5 = source.apply(undefined, arguments); + var _source5 = source.apply(undefined, arguments), + _source6 = _slicedToArray(_source5, 2), + _source6$ = _slicedToArray(_source6[0], 3); - var _source6 = _slicedToArray(_source5, 2); - - var _source6$ = _slicedToArray(_source6[0], 3); - - const hash = _source6$[0]; - const count = _source6$[1]; + const hash = _source6$[0], + count = _source6$[1]; var _source6$$ = _source6$[2]; _source6$$ = _source6$$ === undefined ? {} : _source6$$; var _source6$$$extension = _source6$$.extension; - const extension = _source6$$$extension === undefined ? 'json' : _source6$$$extension; - const callback = _source6[1]; + const extension = _source6$$$extension === undefined ? 'json' : _source6$$$extension, + callback = _source6[1]; return _bluebird2.default.try(() => { if (!_lodash2.default.includes(['bin', 'hex'], extension)) { - throw new Error(`Extension "${ extension }" is not supported`); + throw new Error(`Extension "${extension}" is not supported`); } - return this.request.getAsync(`/rest/headers/${ count }/${ hash }.${ extension }`).bind(this).then(this.parser.rest); + return this.request.getAsync(`/rest/headers/${count}/${hash}.${extension}`).bind(this).then(this.parser.rest); }).asCallback(callback); } @@ -251,9 +253,8 @@ class Client { */ getBlockchainInformation() { - var _source7 = source.apply(undefined, arguments); - - var _source8 = _slicedToArray(_source7, 2); + var _source7 = source.apply(undefined, arguments), + _source8 = _slicedToArray(_source7, 2); const callback = _source8[1]; @@ -268,25 +269,23 @@ class Client { */ getUnspentTransactionOutputs() { - var _source9 = source.apply(undefined, arguments); - - var _source10 = _slicedToArray(_source9, 2); - - var _source10$ = _slicedToArray(_source10[0], 2); + var _source9 = source.apply(undefined, arguments), + _source10 = _slicedToArray(_source9, 2), + _source10$ = _slicedToArray(_source10[0], 2); const outpoints = _source10$[0]; var _source10$$ = _source10$[1]; _source10$$ = _source10$$ === undefined ? {} : _source10$$; var _source10$$$extension = _source10$$.extension; - const extension = _source10$$$extension === undefined ? 'json' : _source10$$$extension; - const callback = _source10[1]; + const extension = _source10$$$extension === undefined ? 'json' : _source10$$$extension, + callback = _source10[1]; const sets = _lodash2.default.flatten([outpoints]).map(outpoint => { - return `${ outpoint.id }-${ outpoint.index }`; + return `${outpoint.id}-${outpoint.index}`; }).join('/'); - return this.request.getAsync(`/rest/getutxos/checkmempool/${ sets }.${ extension }`).bind(this).then(this.parser.rest).asCallback(callback); + return this.request.getAsync(`/rest/getutxos/checkmempool/${sets}.${extension}`).bind(this).then(this.parser.rest).asCallback(callback); } /** @@ -295,9 +294,8 @@ class Client { */ getMemoryPoolContent() { - var _source11 = source.apply(undefined, arguments); - - var _source12 = _slicedToArray(_source11, 2); + var _source11 = source.apply(undefined, arguments), + _source12 = _slicedToArray(_source11, 2); const callback = _source12[1]; @@ -315,9 +313,8 @@ class Client { */ getMemoryPoolInformation() { - var _source13 = source.apply(undefined, arguments); - - var _source14 = _slicedToArray(_source13, 2); + var _source13 = source.apply(undefined, arguments), + _source14 = _slicedToArray(_source13, 2); const callback = _source14[1]; diff --git a/dist/src/logging/request-logger.js b/dist/src/logging/request-logger.js new file mode 100644 index 0000000..90103d9 --- /dev/null +++ b/dist/src/logging/request-logger.js @@ -0,0 +1,36 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _requestObfuscator = require('./request-obfuscator'); + +var _request = require('request'); + +var _request2 = _interopRequireDefault(_request); + +var _requestLogger = require('@uphold/request-logger'); + +var _requestLogger2 = _interopRequireDefault(_requestLogger); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * Exports. + */ + +exports.default = logger => (0, _requestLogger2.default)(_request2.default, (request, instance) => { + (0, _requestObfuscator.obfuscate)(request, instance); + + if (request.type === 'response') { + return logger.debug({ request: request }, `Received response for request ${request.id}`); + } + + return logger.debug({ request: request }, `Making request ${request.id} to ${request.method} ${request.uri}`); +}); +/** + * Module dependencies. + */ + +module.exports = exports['default']; \ No newline at end of file diff --git a/dist/src/logging/request-obfuscator.js b/dist/src/logging/request-obfuscator.js new file mode 100644 index 0000000..a10bccc --- /dev/null +++ b/dist/src/logging/request-obfuscator.js @@ -0,0 +1,128 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.obfuscate = obfuscate; + +var _methods = require('../methods'); + +var _methods2 = _interopRequireDefault(_methods); + +var _lodash = require('lodash'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * Map all methods to lowercase. + */ + +/** + * Module dependencies. + */ + +const lowercaseMethods = (0, _lodash.mapKeys)(_methods2.default, (value, key) => key.toLowerCase()); + +/** + * Obfuscate the response body. + */ + +function obfuscateResponseBody(body, method) { + const fn = (0, _lodash.get)(lowercaseMethods[method], 'obfuscate.response'); + + if (!fn || (0, _lodash.isEmpty)(body.result)) { + return body; + } + + return (0, _lodash.defaults)({ result: fn(body.result) }, body); +} + +/** + * Obfuscate the response. + */ + +function obfuscateResponse(request, instance) { + if (!(0, _lodash.get)(request, 'response.body')) { + return; + } + + if ((0, _lodash.get)(request, `response.headers['content-type']`) === 'application/octet-stream') { + request.response.body = '******'; + + return; + } + + if (!instance.body) { + return; + } + + const requestBody = JSON.parse(instance.body); + + if ((0, _lodash.isArray)(request.response.body)) { + const methodsById = (0, _lodash.mapKeys)(requestBody, method => method.id); + + request.response.body = (0, _lodash.map)(request.response.body, request => obfuscateResponseBody(request, methodsById[request.id].method)); + + return; + } + + request.response.body = obfuscateResponseBody(request.response.body, requestBody.method); +} + +/** + * Obfuscate the request body. + */ + +function obfuscateRequestBody(body) { + const method = (0, _lodash.get)(lowercaseMethods[body.method], 'obfuscate.request'); + + if (!method) { + return body; + } + + body.params = method(body.params); + + return body; +} + +/** + * Obfuscate the request. + */ + +function obfuscateRequest(request) { + if (!(0, _lodash.isString)(request.body)) { + return; + } + + request.body = JSON.parse(request.body); + + if ((0, _lodash.isArray)(request.body)) { + request.body = (0, _lodash.map)(request.body, obfuscateRequestBody); + } else { + request.body = obfuscateRequestBody(request.body); + } + + request.body = JSON.stringify(request.body); +} + +/** + * Obfuscate headers. + */ + +function obfuscateHeaders(request) { + if (!(0, _lodash.has)(request, 'headers.authorization')) { + return; + } + + request.headers.authorization = request.headers.authorization.replace(/(Basic )(.*)/, `$1******`); +} + +/** + * Export `RequestObfuscator`. + */ + +function obfuscate(request, instance) { + obfuscateHeaders(request); + obfuscateRequest(request); + obfuscateResponse(request, instance); +} \ No newline at end of file diff --git a/dist/src/methods.js b/dist/src/methods.js index 3fa7308..4c6e7f3 100755 --- a/dist/src/methods.js +++ b/dist/src/methods.js @@ -3,115 +3,152 @@ Object.defineProperty(exports, "__esModule", { value: true }); -/* eslint-disable no-inline-comments */ + +var _lodash = require('lodash'); + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } } /* eslint-disable no-inline-comments */ + +/** + * Module dependencies. + */ /** * Export available rpc methods. */ exports.default = { - abandonTransaction: '>=0.12.0', - addMultiSigAddress: '>=0.1.0', - addNode: '>=0.8.0', - addWitnessAddress: '>=0.13.0', - backupWallet: '>=0.3.12', - clearBanned: '>=0.12.0', - createMultiSig: '>=0.1.0', - createRawTransaction: '>=0.7.0', - createWitnessAddress: '>=0.13.0', - decodeRawTransaction: '>=0.7.0', - decodeScript: '>=0.9.0', - disconnectNode: '>=0.12.0', - dumpPrivKey: '>=0.6.0', - dumpWallet: '>=0.9.0', - encryptWallet: '>=0.1.0', - estimateFee: '>=0.10.0', - estimatePriority: '>=0.10.0', - estimateSmartFee: '>=0.12.0', - estimateSmartPriority: '>=0.12.0', - fundRawTransaction: '>=0.12.0', - generate: '>=0.11.0', - generateToAddress: '>=0.13.0', - getAccount: '>=0.1.0', - getAccountAddress: '>=0.3.18', - getAddedNodeInfo: '>=0.8.0', - getAddressesByAccount: '>=0.1.0', - getBalance: '>=0.3.18', - getBestBlockHash: '>=0.9.0', - getBlock: '>=0.6.0', - getBlockCount: '>=0.1.0', - getBlockHash: '>=0.6.0', - getBlockHeader: '>=0.12.0', - getBlockTemplate: '>=0.7.0', - getBlockchainInfo: '>=0.9.2', - getChainTips: '>=0.10.0', - getConnectionCount: '>=0.1.0', - getDifficulty: '>=0.1.0', - getGenerate: '<0.13.0', - getHashesPerSec: '<0.10.0', - getInfo: '>=0.1.0', - getMempoolAncestors: '>=0.13.0', - getMempoolDescendants: '>=0.13.0', - getMempoolEntry: '>=0.13.0', - getMempoolInfo: '>=0.10.0', - getMiningInfo: '>=0.6.0', - getNetTotals: '>=0.1.0', - getNetworkHashPs: '>=0.9.0', - getNetworkInfo: '>=0.9.2', - getNewAddress: '>=0.1.0', - getPeerInfo: '>=0.7.0', - getRawChangeAddress: '>=0.9.0', - getRawMemPool: '>=0.7.0', - getRawTransaction: '>=0.7.0', - getReceivedByAccount: '>=0.1.0', - getReceivedByAddress: '>=0.1.0', - getTransaction: '>=0.1.0', - getTxOut: '>=0.7.0', - getTxOutProof: '>=0.11.0', - getTxOutSetInfo: '>=0.7.0', - getUnconfirmedBalance: '>=0.9.0', - getWalletInfo: '>=0.9.2', - getWork: '<0.10.0', - help: '>=0.1.0', - importAddress: '>=0.10.0', - importPrivKey: '>=0.6.0', - importPrunedFunds: '>=0.13.0', - importPubKey: '>=0.12.0', - importWallet: '>=0.9.0', - keypoolRefill: '>=0.1.0', - listAccounts: '>=0.1.0', - listAddressGroupings: '>=0.7.0', - listBanned: '>=0.12.0', - listLockUnspent: '>=0.8.0', - listReceivedByAccount: '>=0.1.0', - listReceivedByAddress: '>=0.1.0', - listSinceBlock: '>=0.5.0', - listTransactions: '>=0.3.18', - listUnspent: '>=0.7.0', - lockUnspent: '>=0.8.0', - move: '>=0.3.18', - ping: '>=0.9.0', - prioritiseTransaction: '>=0.10.0', - removePrunedFunds: '>=0.13.0', - sendFrom: '>=0.3.18', - sendMany: '>=0.3.21', - sendRawTransaction: '>=0.7.0', - sendToAddress: '>=0.1.0', - setAccount: '>=0.1.0', - setBan: '>=0.12.0', - setGenerate: '<0.13.0', - setTxFee: '>=0.3.22', - signMessage: '>=0.5.0', - signMessageWithPrivKey: '>=0.13.0', - signRawTransaction: '>=0.7.0', - stop: '>=0.1.0', - submitBlock: '>=0.7.0', - validateAddress: '>=0.3.14', - verifyChain: '>=0.9.0', - verifyMessage: '>=0.5.0', - verifyTxOutProof: '>0.11.0', - walletLock: '>=0.1.0', - walletPassphrase: '>=0.1.0', - walletPassphraseChange: '>=0.1.0' + abandonTransaction: { version: '>=0.12.0' }, + addMultiSigAddress: { version: '>=0.1.0' }, + addNode: { version: '>=0.8.0' }, + addWitnessAddress: { version: '>=0.13.0' }, + backupWallet: { version: '>=0.3.12' }, + clearBanned: { version: '>=0.12.0' }, + createMultiSig: { version: '>=0.1.0' }, + createRawTransaction: { version: '>=0.7.0' }, + createWitnessAddress: { version: '>=0.13.0' }, + decodeRawTransaction: { version: '>=0.7.0' }, + decodeScript: { version: '>=0.9.0' }, + disconnectNode: { version: '>=0.12.0' }, + dumpPrivKey: { + obfuscate: { + response: () => '******' + }, + version: '>=0.6.0' + }, + dumpWallet: { version: '>=0.9.0' }, + encryptWallet: { + obfuscate: { + request: params => (0, _lodash.set)([].concat(_toConsumableArray(params)), '[0]', '******') + }, + version: '>=0.1.0' + }, + estimateFee: { version: '>=0.10.0' }, + estimatePriority: { version: '>=0.10.0' }, + estimateSmartFee: { version: '>=0.12.0' }, + estimateSmartPriority: { version: '>=0.12.0' }, + fundRawTransaction: { version: '>=0.12.0' }, + generate: { version: '>=0.11.0' }, + generateToAddress: { version: '>=0.13.0' }, + getAccount: { version: '>=0.1.0' }, + getAccountAddress: { version: '>=0.3.18' }, + getAddedNodeInfo: { version: '>=0.8.0' }, + getAddressesByAccount: { version: '>=0.1.0' }, + getBalance: { version: '>=0.3.18' }, + getBestBlockHash: { version: '>=0.9.0' }, + getBlock: { version: '>=0.6.0' }, + getBlockCount: { version: '>=0.1.0' }, + getBlockHash: { version: '>=0.6.0' }, + getBlockHeader: { version: '>=0.12.0' }, + getBlockTemplate: { version: '>=0.7.0' }, + getBlockchainInfo: { version: '>=0.9.2' }, + getChainTips: { version: '>=0.10.0' }, + getConnectionCount: { version: '>=0.1.0' }, + getDifficulty: { version: '>=0.1.0' }, + getGenerate: { version: '<0.13.0' }, + getHashesPerSec: { version: '<0.10.0' }, + getInfo: { version: '>=0.1.0' }, + getMempoolAncestors: { version: '>=0.13.0' }, + getMempoolDescendants: { version: '>=0.13.0' }, + getMempoolEntry: { version: '>=0.13.0' }, + getMempoolInfo: { version: '>=0.10.0' }, + getMiningInfo: { version: '>=0.6.0' }, + getNetTotals: { version: '>=0.1.0' }, + getNetworkHashPs: { version: '>=0.9.0' }, + getNetworkInfo: { version: '>=0.9.2' }, + getNewAddress: { version: '>=0.1.0' }, + getPeerInfo: { version: '>=0.7.0' }, + getRawChangeAddress: { version: '>=0.9.0' }, + getRawMemPool: { version: '>=0.7.0' }, + getRawTransaction: { version: '>=0.7.0' }, + getReceivedByAccount: { version: '>=0.1.0' }, + getReceivedByAddress: { version: '>=0.1.0' }, + getTransaction: { version: '>=0.1.0' }, + getTxOut: { version: '>=0.7.0' }, + getTxOutProof: { version: '>=0.11.0' }, + getTxOutSetInfo: { version: '>=0.7.0' }, + getUnconfirmedBalance: { version: '>=0.9.0' }, + getWalletInfo: { version: '>=0.9.2' }, + getWork: { version: '<0.10.0' }, + help: { version: '>=0.1.0' }, + importAddress: { version: '>=0.10.0' }, + importPrivKey: { + obfuscate: { + request: () => ['******'] + }, + version: '>=0.6.0' + }, + importPrunedFunds: { version: '>=0.13.0' }, + importPubKey: { version: '>=0.12.0' }, + importWallet: { version: '>=0.9.0' }, + keypoolRefill: { version: '>=0.1.0' }, + listAccounts: { version: '>=0.1.0' }, + listAddressGroupings: { version: '>=0.7.0' }, + listBanned: { version: '>=0.12.0' }, + listLockUnspent: { version: '>=0.8.0' }, + listReceivedByAccount: { version: '>=0.1.0' }, + listReceivedByAddress: { version: '>=0.1.0' }, + listSinceBlock: { version: '>=0.5.0' }, + listTransactions: { version: '>=0.3.18' }, + listUnspent: { version: '>=0.7.0' }, + lockUnspent: { version: '>=0.8.0' }, + move: { version: '>=0.3.18' }, + ping: { version: '>=0.9.0' }, + prioritiseTransaction: { version: '>=0.10.0' }, + removePrunedFunds: { version: '>=0.13.0' }, + sendFrom: { version: '>=0.3.18' }, + sendMany: { version: '>=0.3.21' }, + sendRawTransaction: { version: '>=0.7.0' }, + sendToAddress: { version: '>=0.1.0' }, + setAccount: { version: '>=0.1.0' }, + setBan: { version: '>=0.12.0' }, + setGenerate: { version: '<0.13.0' }, + setTxFee: { version: '>=0.3.22' }, + signMessage: { version: '>=0.5.0' }, + signMessageWithPrivKey: { + obfuscate: { + request: params => (0, _lodash.set)([].concat(_toConsumableArray(params)), '[0]', '******') + }, + version: '>=0.13.0' + }, + signRawTransaction: { + obfuscate: { + request: params => (0, _lodash.set)([].concat(_toConsumableArray(params)), '[2]', (0, _lodash.map)(params[2], () => '******')) + }, + version: '>=0.7.0' + }, + stop: { version: '>=0.1.0' }, + submitBlock: { version: '>=0.7.0' }, + validateAddress: { version: '>=0.3.14' }, + verifyChain: { version: '>=0.9.0' }, + verifyMessage: { version: '>=0.5.0' }, + verifyTxOutProof: { version: '>0.11.0' }, + walletLock: { version: '>=0.1.0' }, + walletPassphrase: { + obfuscate: { + request: params => (0, _lodash.set)([].concat(_toConsumableArray(params)), '[0]', '******') + }, + version: '>=0.1.0' + }, + walletPassphraseChange: { version: '>=0.1.0' } }; module.exports = exports['default']; \ No newline at end of file diff --git a/dist/src/parser.js b/dist/src/parser.js index bf03f32..6de0127 100644 --- a/dist/src/parser.js +++ b/dist/src/parser.js @@ -24,11 +24,11 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de */ function get(body) { - var _ref = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + _ref$headers = _ref.headers; - var _ref$headers = _ref.headers; - let headers = _ref$headers === undefined ? false : _ref$headers; - let response = _ref.response; + let headers = _ref$headers === undefined ? false : _ref$headers, + response = _ref.response; if (!body) { throw new _rpcError2.default(response.statusCode, response.statusMessage); @@ -55,7 +55,7 @@ function get(body) { class Parser { constructor() { - var _ref2 = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; + var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; let headers = _ref2.headers; @@ -69,8 +69,8 @@ class Parser { rpc(_ref3) { var _ref4 = _slicedToArray(_ref3, 2); - let response = _ref4[0]; - let body = _ref4[1]; + let response = _ref4[0], + body = _ref4[1]; // Body contains HTML (e.g. 401 Unauthorized). if (typeof body === 'string' && response.statusCode !== 200) { @@ -100,8 +100,8 @@ class Parser { rest(_ref5) { var _ref6 = _slicedToArray(_ref5, 2); - let response = _ref6[0]; - let body = _ref6[1]; + let response = _ref6[0], + body = _ref6[1]; if (body.error) { throw new _rpcError2.default(body.error.code, body.error.message); diff --git a/dist/src/requester.js b/dist/src/requester.js index cc77b19..343425e 100644 --- a/dist/src/requester.js +++ b/dist/src/requester.js @@ -12,11 +12,11 @@ var _lodash = require('lodash'); class Requester { constructor() { - var _ref = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; + var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, + _ref$unsupported = _ref.unsupported; - var _ref$unsupported = _ref.unsupported; - let unsupported = _ref$unsupported === undefined ? [] : _ref$unsupported; - let version = _ref.version; + let unsupported = _ref$unsupported === undefined ? [] : _ref$unsupported, + version = _ref.version; this.unsupported = unsupported; this.version = version; @@ -29,17 +29,17 @@ class Requester { prepare(_ref2) { let method = _ref2.method; var _ref2$parameters = _ref2.parameters; - let parameters = _ref2$parameters === undefined ? [] : _ref2$parameters; - let suffix = _ref2.suffix; + let parameters = _ref2$parameters === undefined ? [] : _ref2$parameters, + suffix = _ref2.suffix; method = method.toLowerCase(); if (this.version && (0, _lodash.includes)(this.unsupported, method)) { - throw new Error(`Method "${ method }" is not supported by version "${ this.version }"`); + throw new Error(`Method "${method}" is not supported by version "${this.version}"`); } return { - id: `${ Date.now() }${ suffix !== undefined ? `-${ suffix }` : '' }`, + id: `${Date.now()}${suffix !== undefined ? `-${suffix}` : ''}`, method: method, params: parameters }; diff --git a/package.json b/package.json index 4340d7a..d029b1a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bitcoin-core", - "version": "1.1.0", + "version": "1.2.0", "description": "A modern Bitcoin Core REST and RPC client.", "keywords": [ "bitcoin",