diff --git a/integration/index.js b/integration/index.js index 5ffedeb3..c36d50b0 100644 --- a/integration/index.js +++ b/integration/index.js @@ -85,6 +85,9 @@ describe('Basic Functionality', function() { knownHeights.forEach(function(data) { it('block at height ' + data[0], function(done) { bitcoind.getBlock(data[0], function(err, response) { + if (err) { + throw err; + } var block = bitcore.Block.fromBuffer(response); block.hash.should.equal(data[1]); done(); diff --git a/src/bitcoindjs.cc b/src/bitcoindjs.cc index 38e81bd9..3cc49187 100644 --- a/src/bitcoindjs.cc +++ b/src/bitcoindjs.cc @@ -743,6 +743,10 @@ async_get_block(uv_work_t *req) { if (data->height != -1) { pblockindex = chainActive[data->height]; + if (pblockindex == NULL) { + data->err_msg = std::string("Block not found."); + return; + } } else { if (mapBlockIndex.count(hash) == 0) { data->err_msg = std::string("Block not found.");