How to event when BitcoinJ instance shut down before the transaction is confirmed?

141 views Asked by At

I'm developing an application which uses bitcoin payment method. And it is using bitcoinj java library. But i have a problem:

I am sending btc to the wallet.

It says transaction recieved, but it has no confirmation of course. I am creating future listener to event for 3rd confirmation of the transaction.

Everything is ok at this point. The problem is, what will happen if the app get down before future listener executed?

It is not eventing it after i restart the app ofcourse. What can i do at this point?

Thanks.

1

There are 1 answers

0
cdecker On

Instead of attaching to an individual transaction you could attach a WalletChangeEventListener (docs). It is called, among other things, when a new block is found and a confirmation is added to a transaction. If registered before the event loop is started it should get called on each block even during the sync with the rest of the network, mimicking being online during the confirmation period.