ruimarinho / bitcoin-core

A modern Bitcoin Core REST and RPC client.
477 stars 186 forks source link

named parameter obfuscate issue in methods.js #61

Closed randydu closed 6 years ago

randydu commented 6 years ago

When calling api with named parameter (such as signRawTransaction), the params is now an object instead of an array, so the obfuscate methods (in dist/src/methods.js) will throw the following exception:

Exception has occurred: TypeError
TypeError: params is not iterable
    at request (/home/randy/blockdev/docker/app/node_modules/bitcoin-core/dist/src/methods.js:346:47)
    at obfuscateRequestBody (/home/randy/blockdev/docker/app/node_modules/bitcoin-core/dist/src/logging/request-obfuscator.js:82:17)
    at obfuscateRequest (/home/randy/blockdev/docker/app/node_modules/bitcoin-core/dist/src/logging/request-obfuscator.js:104:20)
    at obfuscate (/home/randy/blockdev/docker/app/node_modules/bitcoin-core/dist/src/logging/request-obfuscator.js:132:3)
    at /home/randy/blockdev/docker/app/node_modules/bitcoin-core/dist/src/logging/request-logger.js:24:36
    at Request.<anonymous> (/home/randy/blockdev/docker/app/node_modules/@uphold/request-logger/src/index.js:74:9)
    at emitOne (events.js:116:13)
    at Request.emit (events.js:211:7)
    at Request.start (/home/randy/blockdev/docker/app/node_modules/request/request.js:859:8)
    at Request.write (/home/randy/blockdev/docker/app/node_modules/request/request.js:1498:10)
    at end (/home/randy/blockdev/docker/app/node_modules/request/request.js:546:18)
    at Immediate.<anonymous> (/home/randy/blockdev/docker/app/node_modules/request/request.js:575:7)
    at runCallback (timers.js:789:20)
    at tryOnImmediate (timers.js:751:5)
    at processImmediate [as _immediateCallback] (timers.js:722:5)

The obfuscate.request needs to detect the params type (array of object) to support named params calling.

ruimarinho commented 6 years ago

You're right. @pedrobranco are you able to take a look on this one?

pedrobranco commented 6 years ago

Sure.