The method 'listtransactionsofblock' lists all transactions (from the wallet) which are in block with blockhash <hash>
It can be used this way: (pseudo-code)
ScanTransactions() {
Database.TransactionBegin()
long lastBlock = BitcoinRPC.getLastBlockNr()
long lastScannedBlock = Database.getLastScannedBlock()
while (lastBlock - lastScannedBlock > targetConfirms) {
lastScannedBlock++;
string hash = BitcoinRPC.getHashOfBlock(lastScannedBlock)
list<Transaction> list = BitcoinRPC.getTransactionsOfBlock(hash)
for (Transaction t : list)
{
// do something
// at this point, you can absolutely be sure to see only transactions
// with <targetconfirms> confirms.
// and you only have to scan each block exactly once
}
}
Database.saveLastScannedBlock()
Database.TransactionCommit()
}
This is an easy example how payments can reliably be received.
Explained here: #2565