bitcoin.conf:-
rpcpassword=Hellno
maxconnections=1000
checklevel=4
keypool=10000
rpcallowip=127.0.0.1
server=1
blocknotify=/home/bitcoin/block.sh %s
walletnotify=/home/bitcoin/wallet.sh %s
alertnotify=/home/bitcoin/alert.sh %s
Then the .sh's are as follows:-
alert.sh:-
curl "http://127.0.0.1:9485/alert" -d "$@"
block.sh:-
curl "http://127.0.0.1:9485/block" -d "$@"
wallet.sh:-
curl "http://127.0.0.1:9485/wallet" -d "$@"
In the program itself, I listen on local host like this:-
var http = require('http');
var httpServer = http.createServer(function (req, res) {
dealWithHTTP(req, res);
}).listen("9485", "127.0.0.1", 511, function (err) {
if(err) {
console.log("HTTP ERROR:-", err);
}
});
Then the 'dealwithhttp' is basically a switch statement based on /alert, /block, or, /wallet. /Alert sends me a message directly, /wallet (I.E. payment incoming) applies an update to the DB based on the arguments (Post data), and, messages me also (I like to know!), finally, /block looks for any unconfirmed addresses, and, rechecks them with the bitcoind. Maybe not the best way of doing it, but, a way. As you said you didn't want to do another RPC call, I can't help you, but, least this is a starting place.
From what I've seen, once when it receives a payment, once when it receives the first confirmation (I.E. first time it sees it past the broadcast), and once when you send a payment.