Bitcore call method

(ra2637) #1

Hello everyone,

I have a problem for the bitcore call command.

I tried the example bitcore call getBlock xxxx and it works. But when I tried to query the block count by bitcore call getBlockCount, it show me error as following.

According to the website it seems can take bitcoin client API call. Do I misunderstand it? If so, is there any documentation for the API method?

Thanks!!

/home/bitcoin/mynode/node_modules/bitcore-node/lib/cli/main.js:139
          throw err;
          ^

Error: Method Not Found
    at Socket.<anonymous> (/home/bitcoin/mynode/node_modules/bitcore-node/lib/scaffold/call-method.js:30:21)
    at Socket.onack (/home/bitcoin/mynode/node_modules/bitcore-node/node_modules/socket.io-client/lib/socket.js:304:9)
    at Socket.onpacket (/home/bitcoin/mynode/node_modules/bitcore-node/node_modules/socket.io-client/lib/socket.js:227:12)
    at Manager.<anonymous> (/home/bitcoin/mynode/node_modules/bitcore-node/node_modules/socket.io-client/node_modules/component-bind/index.js:21:15)
    at Manager.Emitter.emit (/home/bitcoin/mynode/node_modules/bitcore-node/node_modules/socket.io-client/node_modules/component-emitter/index.js:131:20)
    at Manager.ondecoded (/home/bitcoin/mynode/node_modules/bitcore-node/node_modules/socket.io-client/lib/manager.js:325:8)
    at Decoder.<anonymous> (/home/bitcoin/mynode/node_modules/bitcore-node/node_modules/socket.io-client/node_modules/component-bind/index.js:21:15)
    at Decoder.Emitter.emit (/home/bitcoin/mynode/node_modules/bitcore-node/node_modules/socket.io-client/node_modules/socket.io-parser/node_modules/component-emitter/index.js:134:20)
    at Decoder.add (/home/bitcoin/mynode/node_modules/bitcore-node/node_modules/socket.io-client/node_modules/socket.io-parser/index.js:247:12)
    at Manager.ondata (/home/bitcoin/mynode/node_modules/bitcore-node/node_modules/socket.io-client/lib/manager.js:315:16)
(Braydon Fuller) #2

The API methods are documented in the services section, for example: https://bitcore.io/api/service/address The documentation is largely focused on using the methods within a Node.js process however there are methods that are exposed via getAPIMethods for each service, for example: https://github.com/bitpay/bitcore-node/blob/master/lib/services/address/index.js#L138

It’s possible to use JSON-RPC from bitcoind directly, however you need to enable it in bitcoin.conf with server=1 and then use a client such as https://www.npmjs.com/package/bitcoind-rpc or bitcoin-cli command line utility.

(ra2637) #3

Thank you for the answer !

But I think the bitcoin-cli doesn’t work well on bitcore. Some commands are broken. e.g., bitcoin-cli getinfo gave me response but for btcoin-cli gettransaction xxxxx returned error as following:

error: {"code":-32601,"message":"Method not found"}

the same command for gettransaction works proplerly when I start the bitcoin server by bitcoind instead of bitcored. And I don’t realize why this happened. Is this related to wallet service?

Thanks!