Get Confirmation detail of TRX hash - always returns 0

HI All

Running Bitcore 4.1

When we run the GETConfirmation - bitcore node 3.1.1 we always get “0” as response - which is incorrect.

Any advice would be appreciated


Where is that being called from?

var bitcore = require('bitcore-node');
var Insight_Api = require('insight-api');
var Bitcoin =;
var Web =;
var node = new bitcore.Node({
    network: 'livenet',
    services: [
            name: 'bitcoind',
            module: Bitcoin,
            config: {
                spawn: {
                    "datadir": "/root/.bitcore/data",
                    "exec": "/root/.nvm/versions/v0.12.10/lib/node_modules/bitcore/node_modules/bitcore-node/bin/bitcoind"
            name: 'web',
            module: Web,
            config: {
                port: 3001
            name: 'insight-api',
            module: Insight_Api,
            config: {
                port: 3001
node.start(function (err) {
    if (err) {
        console.log("Start Error", err)
        node.stop(function () {
            console.log('shutdown the node')


node.on('ready', function () {
    console.log('Bitcoin Node Ready');
    MongoClient.connect(config.db11, function (err, db) {
        assert.equal(null, err);
        console.log("Connected correctly to Db");
        var mainDb = db.collection('transactions_re');
        mainDb.createIndex({"hash": 1}, {unique: true});'tx', function (transactionBuffer) {
            var trx = bitcore_lib.Transaction().fromBuffer(transactionBuffer);

  , function (err, transaction) {



node.on('error', function (err) {

The methods with underscores are not intended to be used externally, and the method accepts a transaction (with a height property), and not the hash of a transaction. Please see:

The confirmations can be calculated using:

var confirmations = - transaction.height + 1;

For readability, I’ve edited the code block above to have three backticks before and after so it displays properly.

Hi All,

We have tried the following but again we got only “0”:

for(var i = 0; i< inputs.length; ++i){[i].prevTxId, function(err, transaction) {
    var tx = new Transaction(transaction)

Also, when I want to calculate height, using:

var confirmations = - transaction.height + 1;

I get transaction height by default.

Please advice,

Edited the above code block for readability.

The result from getTransaction does not have a height property.

Thanks for answer,

Could you tell which function result has height?

Just to clarify - which function would have a height property that we can use to get the confirmations ?



Hi Braydon,

Thank you for your reply. That is very true that function has height but the problem is from time to time I get the following error:

`AssertionError: null == { [RPCError: Bitcoin JSON-RPC: Work queue depth exceeded] code: 429 }
    at /root/myNode/app.js:176:40
    at /root/myNode/node_modules/async/lib/async.js:726:13
    at /root/myNode/node_modules/async/lib/async.js:52:16
    at done (/root/myNode/node_modules/async/lib/async.js:241:17)
    at /root/myNode/node_modules/async/lib/async.js:44:16
    at /root/myNode/node_modules/async/lib/async.js:723:17
    at /root/myNode/node_modules/async/lib/async.js:167:37
    at /root/myNode/app.js:158:46
    at /root/myNode/node_modules/async/lib/async.js:52:16
    at done (/root/myNode/node_modules/async/lib/async.js:241:17)

Could you advice please?

also I have get flowing error.
TypeError: Cannot read property ‘toString’ of null
at Array.types.str (/root/myNode/node_modules/bitcore-node/node_modules/bitcoind-rpc/lib/index.js:260:17)
at RpcClient. (/root/myNode/node_modules/bitcore-node/node_modules/bitcoind-rpc/lib/index.js:236:35)
at /root/myNode/node_modules/bitcore-node/lib/services/bitcoind.js:1956:14
at retry (/root/myNode/node_modules/bitcore-node/lib/services/bitcoind.js:443:5)
at /root/myNode/node_modules/bitcore-node/node_modules/async/lib/async.js:651:21
at /root/myNode/node_modules/bitcore-node/node_modules/async/lib/async.js:718:13
at iterate (/root/myNode/node_modules/bitcore-node/node_modules/async/lib/async.js:262:13)
at async.forEachOfSeries.async.eachOfSeries (/root/myNode/node_modules/bitcore-node/node_modules/async/lib/async.js:281:9)
at _parallel (/root/myNode/node_modules/bitcore-node/node_modules/async/lib/async.js:717:9)
at Object.async.series (/root/myNode/node_modules/bitcore-node/node_modules/async/lib/async.js:739:9)

In my case this code is not that accurate because its not getting the latest block. I accomplished this using getInfo’s block.

For Example (Getting Confirmations):

function getConfirmation(args, opt, callback) {"<hash here>", function(err, transaction) {
    var txHeight = 0;
    if(err) {
      //return error message here ...
    } else {, info) {
        if(transaction.height + 1 > 0) {
          txHeight = info.blocks - transaction.height + 1
        // return total confirmation(s)
        callback(null, (err ? err : {
          hash : args,
          confirmation : txHeight

txHeight has the total amount of the confirmation…

Maybe this will help… :slight_smile: