3

During blockchain scanning I need to do:

P − Hs(aR)G

with every output in order to determie whether it is mine, or not.

Where in tx_json are P and R stored?

jtgrassie
  • 19,601
  • 4
  • 17
  • 54
ivanahepjuk
  • 149
  • 5

1 Answers1

3

The full math you have to do is:

D = P - Hs(8aR || i)G, where i is a varint representing the index of the output. You then check whether D matches your main public spend key or any of your subaddress public spend keys. if it does, the output is destined for you.

The output public key P is in the json as vout.target.key. The transaction public key R is not separately listed, so you'll need to parse the extra field in the json and locate the txpubkey subfield.

The txextra field format is documented here: https://cryptonote.org/cns/cns005.txt

It's the "Tx public key" field mentioned in that document that you are interested in.

Also note that to support transactions with multiple subaddress recipients, there is also a new TX_EXTRA_TAG_ADDITIONAL_PUBKEYS field. If this field is present, then you'll need to check each output against the corresponding additional txpubkey listed in that field.

knaccc
  • 8,518
  • 17
  • 23