Making a service like webservice using Bitcoinj library

In my project I need three type of monitoring on Blockchain network:

  1. Monitor all the transactions
  2. Monitor all new blocks
  3. Calculate confirmations for each hash exactly does the same thing, but it’s not very stable sometimes and I need to apply my own to customization also.

1) Using Bitcoinj, monitoring transactions is easy:

NetworkParameters params = MainNetParams.get(); BlockStore blockStore = new MemoryBlockStore(params); BlockChain chain = new BlockChain(params, blockStore); PeerGroup peerGroup = new PeerGroup(params, chain); peerGroup.start(); peerGroup.addPeerDiscovery(new DnsDiscovery(params)); peerGroup.waitForPeers(5).get(); peerGroup.addOnTransactionBroadcastListener((peer, transaction) -> {     // Get all the transactions here (There is an issue here, this listener calls for each transaction two times) }); 

However this one has an issue, it is called two times for each transaction (I have no idea why).

2) I did not find anything to monitor all the blocks.

3) Also, I don’t hove how to calculate confirmations properly.

I would appreciate if anyone could help me. API response is coming with a big delay

I’m using API on my shop. Everything was fine until about 2 weeks ago. The whole procedure and the issue is: – When a customer place an order, a btc address is created and customer must send a certain amount of funds to this address. – When funds are received on this wallet, is sending a response to my site that funds are paid. – Automatic confirmation emails are sent to the customer when I receive this confirmation from

About 10 days ago, I noticed that the “paid” reply comes with a big delay from Log shows that there is a difference of about 4 hours between creating the invoice and paid responce. At the same time, I see that customer paid his order (3 confirmations) in 25 minutes (for example) after invoice was created.

As to mention, there were no such issue before. Something changed and I cant understand where.