Bitcoin Transaction within source code
You can make use of the -blocknotify=&lt;cmd&gt; facility as described under: https://en.bitcoin.it/wiki/Running_Bitcoin.

This is a nice example of how to use -walletnotify: https://bitcoin.stackexchange.com/a/24483/11221, -blocknotify can be configured in exactly the same way.