Let's assume I have an address, a secret view key for it, and a transaction. The transaction has been checked by a daemon to be valid.
How do I figure out if the transaction pays something (and how much) to the address? What are the operations I need to perform?
PS: I'm asking only about v11 and v12 protocol.
Additional info:
It's not obvious in the explanation below that some transactions have more than one pubkey. Specifically, it happens when the tx pays out to multiple subaddresses. A good explanation of what additional data should be processed is in this question