Skip to content
This repository has been archived by the owner on Dec 4, 2018. It is now read-only.

Error: Invalid params, response status code: 500 #40

Open
SeanHai opened this issue Oct 31, 2018 · 0 comments
Open

Error: Invalid params, response status code: 500 #40

SeanHai opened this issue Oct 31, 2018 · 0 comments

Comments

@SeanHai
Copy link

SeanHai commented Oct 31, 2018

when I use the node-bitcoin to access the running bitcoin-core node, I get this error. I use a loop to request 100 or more blocks through the JSON-RPC api.

The bitcoind.conf is:
server=1 daemon=1 rpcthreads=10 txindex=1 rpcuser=bitcoin rpcpassword=bitcoin rpctimeout=3600
The main code is :
`var bitcoin = require('bitcoin');
var client = new bitcoin.Client({
host: 'localhost',
port: 8332,
user: 'bitcoin',
pass: 'bitcoin'
});
var fs = require("fs");
fs.readFile('block_num', function (err, data) {
if (err) {
return console.error(err);
}
var i = Number(data)
var k = i+100
for (i ; i < k; i++){
client.getBlockHash(i, function(err, hash, resHeaders) {
if (err) return console.log(err);

            client.getBlock(hash, (2), function(err, block){
                    if (err) return console.log(err);
                    fs.appendFile('blocks/blk'), JSON.stringify(block,null,2)+"\n",  function(err) {
                            if (err) {
                            return console.error(err)
                            }
                            })
                    })
            })
    }
    fs.writeFile('block_num', i , function (err) {
          if (err) {
             return console.error(err);
            }
    })

});
The error is:{ Error: Invalid params, response status code: 500
at IncomingMessage. (/home/sean/Downloads/node-bitcoin/node_modules/bitcoin/lib/jsonrpc.js:110:17)
at IncomingMessage.emit (events.js:187:15)
at endReadableNT (_stream_readable.js:1094:12)
at process._tickCallback (internal/process/next_tick.js:63:19) code: -32602 }
`

How can I fix it? thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant