I am sending bitcoin transaction in node js via bitcore-lib and bitcore-explorers.

I realized that when i call the function .broadcast to send the transaction to network and returns value, it means that the transaction is broadcasted but not completed.

What I want to ensure that when the transaction is in bitcoin network , I will need to write the status into local database (pending, success or fail).

I am thinking of looping and keep calling the transaction detail by txid until it is completed only it write to database. But thinking that bitcoin network transaction will take up to 30 minutes it might not be a good approach because the node server might take up a lot of resources in keep querying the transaction detail.

Any idea on what's the best practice to ensure that local database transaction detail and status in sync with the bitcoin network?

And what function should i use to get transaction detail? I seems to not able to find query of transaction detail in bitcore library.


Since you aren't running your own node, the best way would be to simply check each new block for your transaction. Since transactions can only be mined if a new block is generated, you don't need to poll for a status chain between blocks.

  • Not really understand it ... especially on poll for a status chain between blocks. can you further explain about that. – vincentsty Jun 3 '18 at 0:53
  • You don't need to do that. You simply need to check each new block. A transaction will not be mined unless there is a new block from when you last checked, so there is no need to do anything in between blocks – Raghav Sood Jun 3 '18 at 0:56
  • I see. But a new block only guaranteed a transaction is mined, does not guarantee a transaction is success right? It still could be a success or fail transaction. Between which function i can call to check new block / new transaction. I can't find it in bitcore librarly – vincentsty Jun 3 '18 at 0:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.