It's fairly straightforward in that you examine all notes, and correlate notes referencing others involving kind 9734 and 9735, parse out the amount from bolt invoice and tally.
The caveat is you need to do this for each note, and may not have all relevant notes based on the relays retrieving from.
So simple, but still kind of brute force retrieval and parsing. That's a lot of notes to index and cross reference.