2

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

2

Extract the tx public key R from the tx extra field, and for each output, it's key K and index i, then using your private view key a and public spend key B, you own the output if:

Hs(8aR||i)G+B == K

To find out how much you received, take the encrypted amount e for that output index from the transaction's ecdhInfo field and decrypt:

xor8(e, keccak("amount"||Hs(8aR||i))

Note, xor8 is XOR'ing the first parameter with the first 8 bytes of the second parameter, the result is the decrypted amount.

|improve this answer|||||
  • Thanks! Does 8 in 8aR stand for scalar multiplication? – emesik Oct 21 '19 at 7:54
  • 1
    It's a point multiplication. (ge_mul8). – jtgrassie Oct 21 '19 at 13:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.