From 3886ffc72410a03b247d2135d5a396153df47126 Mon Sep 17 00:00:00 2001 From: Pedro Branco Date: Thu, 21 Jul 2022 11:32:54 +0100 Subject: [PATCH] Release 3.1.0 --- CHANGELOG.md | 46 +++++++++++++++++++++----- dist/src/index.js | 12 ++++++- dist/src/logging/request-obfuscator.js | 17 ++++++++++ dist/src/methods.js | 22 ++++++++++-- package.json | 2 +- 5 files changed, 87 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d909d03..09625e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,29 @@ # Changelog -## [3.0.0](https://github.com/ruimarinho/bitcoin-core/tree/3.0.0) (2019-09-27) +## [3.1.0](https://github.com/ruimarinho/bitcoin-core/tree/3.1.0) (2022-07-21) -[Full Changelog](https://github.com/ruimarinho/bitcoin-core/compare/v2.3.0...3.0.0) +[Full Changelog](https://github.com/ruimarinho/bitcoin-core/compare/v3.0.0...3.1.0) + +**Implemented enhancements:** + +- Add support for bitcoin@0.19.0 RPC methods [\#123](https://github.com/ruimarinho/bitcoin-core/pull/123) ([sskender](https://github.com/sskender)) + +**Fixed bugs:** + +- Handle non-JSON response [\#126](https://github.com/ruimarinho/bitcoin-core/pull/126) ([andrewda](https://github.com/andrewda)) **Merged pull requests:** +- Add support for GitHub actions tests [\#131](https://github.com/ruimarinho/bitcoin-core/pull/131) ([pedrobranco](https://github.com/pedrobranco)) +- Update json-bigint@^1.0.0 [\#130](https://github.com/ruimarinho/bitcoin-core/pull/130) ([rabm2k7](https://github.com/rabm2k7)) +- Added support for default wallet functions in multiwallet environment [\#117](https://github.com/ruimarinho/bitcoin-core/pull/117) ([wleev](https://github.com/wleev)) + +## [v3.0.0](https://github.com/ruimarinho/bitcoin-core/tree/v3.0.0) (2019-09-27) + +[Full Changelog](https://github.com/ruimarinho/bitcoin-core/compare/v2.3.0...v3.0.0) + +**Implemented enhancements:** + - Remove bluebird dependency and callbacks support [\#87](https://github.com/ruimarinho/bitcoin-core/pull/87) ([pedrobranco](https://github.com/pedrobranco)) ## [v2.3.0](https://github.com/ruimarinho/bitcoin-core/tree/v2.3.0) (2019-09-27) @@ -39,11 +57,14 @@ [Full Changelog](https://github.com/ruimarinho/bitcoin-core/compare/v2.0.0...v2.1.0) -**Merged pull requests:** +**Fixed bugs:** -- Add support for json extension in rest endpoint [\#78](https://github.com/ruimarinho/bitcoin-core/pull/78) ([pedrobranco](https://github.com/pedrobranco)) - Fix response log obfuscation [\#64](https://github.com/ruimarinho/bitcoin-core/pull/64) ([pedrobranco](https://github.com/pedrobranco)) - Fix obfuscator with named parameters [\#62](https://github.com/ruimarinho/bitcoin-core/pull/62) ([pedrobranco](https://github.com/pedrobranco)) + +**Merged pull requests:** + +- Add support for json extension in rest endpoint [\#78](https://github.com/ruimarinho/bitcoin-core/pull/78) ([pedrobranco](https://github.com/pedrobranco)) - Add support for multiwallet [\#45](https://github.com/ruimarinho/bitcoin-core/pull/45) ([ruimarinho](https://github.com/ruimarinho)) ## [v2.0.0](https://github.com/ruimarinho/bitcoin-core/tree/v2.0.0) (2017-11-27) @@ -77,24 +98,33 @@ [Full Changelog](https://github.com/ruimarinho/bitcoin-core/compare/v1.0.0...v1.1.0) -**Merged pull requests:** +**Implemented enhancements:** - Add support for bitcoind 0.13 [\#18](https://github.com/ruimarinho/bitcoin-core/pull/18) ([ruimarinho](https://github.com/ruimarinho)) +- Improve RPC documentation [\#12](https://github.com/ruimarinho/bitcoin-core/pull/12) ([ruimarinho](https://github.com/ruimarinho)) + +**Merged pull requests:** + - Simplify Docker setup [\#14](https://github.com/ruimarinho/bitcoin-core/pull/14) ([ruimarinho](https://github.com/ruimarinho)) - Update babel-eslint@6.0.0 [\#13](https://github.com/ruimarinho/bitcoin-core/pull/13) ([ruimarinho](https://github.com/ruimarinho)) -- Improve RPC documentation [\#12](https://github.com/ruimarinho/bitcoin-core/pull/12) ([ruimarinho](https://github.com/ruimarinho)) ## [v1.0.0](https://github.com/ruimarinho/bitcoin-core/tree/v1.0.0) (2016-03-06) [Full Changelog](https://github.com/ruimarinho/bitcoin-core/compare/bd98d0a89faae6ddafc71cf547f387c9c74490b1...v1.0.0) -**Merged pull requests:** +**Implemented enhancements:** - Add a better changelog sed [\#10](https://github.com/ruimarinho/bitcoin-core/pull/10) ([ruimarinho](https://github.com/ruimarinho)) - Use async/await on tests [\#9](https://github.com/ruimarinho/bitcoin-core/pull/9) ([ruimarinho](https://github.com/ruimarinho)) - Fix Docker hosts in CI environment [\#8](https://github.com/ruimarinho/bitcoin-core/pull/8) ([ruimarinho](https://github.com/ruimarinho)) - Minor process improvements [\#7](https://github.com/ruimarinho/bitcoin-core/pull/7) ([ruimarinho](https://github.com/ruimarinho)) -- Call `done\(\)` when testing callbacks [\#6](https://github.com/ruimarinho/bitcoin-core/pull/6) ([ruimarinho](https://github.com/ruimarinho)) - Allow extra ips in docker-compose.yml [\#5](https://github.com/ruimarinho/bitcoin-core/pull/5) ([ruimarinho](https://github.com/ruimarinho)) + +**Fixed bugs:** + +- Call `done()` when testing callbacks [\#6](https://github.com/ruimarinho/bitcoin-core/pull/6) ([ruimarinho](https://github.com/ruimarinho)) + +**Merged pull requests:** + - Add support for 0.12 [\#4](https://github.com/ruimarinho/bitcoin-core/pull/4) ([ruimarinho](https://github.com/ruimarinho)) - Add new 0.12 version methods [\#3](https://github.com/ruimarinho/bitcoin-core/pull/3) ([pedrobranco](https://github.com/pedrobranco)) diff --git a/dist/src/index.js b/dist/src/index.js index 7a1f3b0..4c7c2a9 100644 --- a/dist/src/index.js +++ b/dist/src/index.js @@ -55,6 +55,7 @@ const promisify = fn => (...args) => new Promise((resolve, reject) => { class Client { constructor({ agentOptions, + allowDefaultWallet = false, headers = false, host = 'localhost', logger = (0, _debugnyan.default)('bitcoin-core'), @@ -74,6 +75,7 @@ class Client { } this.agentOptions = agentOptions; + this.allowDefaultWallet = allowDefaultWallet; this.auth = (password || username) && { pass: password, user: username @@ -166,10 +168,18 @@ class Client { }); } + let uri = '/'; + + if (multiwallet && this.wallet) { + uri = `/wallet/${this.wallet}`; + } else if (multiwallet && !this.wallet && this.allowDefaultWallet) { + uri = '/wallet/'; + } + return this.parser.rpc((await this.request.postAsync({ auth: _lodash.default.pickBy(this.auth, _lodash.default.identity), body: JSON.stringify(body), - uri: `${multiwallet && this.wallet ? `/wallet/${this.wallet}` : '/'}` + uri }))); } /** diff --git a/dist/src/logging/request-obfuscator.js b/dist/src/logging/request-obfuscator.js index bb8ca52..476492e 100644 --- a/dist/src/logging/request-obfuscator.js +++ b/dist/src/logging/request-obfuscator.js @@ -19,10 +19,23 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de * Map all methods to lowercase. */ const lowercaseMethods = (0, _lodash.mapKeys)(_methods.default, (value, key) => key.toLowerCase()); +/** + * Helper. + */ + +const isJSON = data => { + try { + JSON.parse(data); + return true; + } catch (e) { + return false; + } +}; /** * Obfuscate the response body. */ + function obfuscateResponseBody(body, method) { const fn = (0, _lodash.get)(lowercaseMethods[method], 'obfuscate.response'); @@ -57,6 +70,10 @@ function obfuscateResponse(request, instance) { return; } + if (!isJSON(request.body)) { + return; + } + request.body = JSON.parse(request.body); const requestBody = JSON.parse(instance.body); diff --git a/dist/src/methods.js b/dist/src/methods.js index f7e5bd8..7d86516 100644 --- a/dist/src/methods.js +++ b/dist/src/methods.js @@ -183,9 +183,9 @@ var _default = { generate: { category: 'generating', features: { - multiwallet: '>=0.15.0' + multiwallet: '>=0.15.0 <0.19.0' }, - version: '>=0.11.0' + version: '>=0.11.0 <0.19.0' }, generateToAddress: { category: 'generating', @@ -237,6 +237,13 @@ var _default = { }, version: '>=0.3.18' }, + getBalances: { + category: 'wallet', + features: { + multiwallet: '>=0.19.0' + }, + version: '>=0.19.0' + }, getBestBlockHash: { category: 'blockchain', version: '>=0.9.0' @@ -249,6 +256,10 @@ var _default = { category: 'blockchain', version: '>=0.1.0' }, + getBlockFilter: { + category: 'blockchain', + version: '>=0.19.0' + }, getBlockHash: { category: 'blockchain', version: '>=0.6.0' @@ -714,6 +725,13 @@ var _default = { }, version: '>=0.3.22' }, + setWalletFlag: { + category: 'wallet', + features: { + multiwallet: '>=0.19.0' + }, + version: '>=0.19.0' + }, signMessage: { category: 'wallet', features: { diff --git a/package.json b/package.json index 7951695..15fa4a5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bitcoin-core", - "version": "3.0.0", + "version": "3.1.0", "description": "A modern Bitcoin Core REST and RPC client.", "keywords": [ "bitcoin",