I created a light wallet which can receive and send transactions. It works fine in normal situation.
My (first) question is what are the situations where things can go wrong ? Is there a reference explaining the life cycle of a transaction with all the possibilities ?
Example: the wallet is notified when it receives bitcoins. If the fees are very low or even zero, the transaction can stay for few days in the mempool. Eventually, after 2 weeks (right?), if the tx is not included in a block, the tx will be discarded.
I have a script which scans the mempool and another one which scans all new blocks. The first one will see the tx but the second one will never see it.
How can I know for sure that the tx is discarded so I can notify the wallet ? My guess: save the unconfirmed tx with a date and make another cron job that will go through those tx and check if the tx is older than 2 weeks and is not anymore in bitcoind (mempool or block).