Extending this question I am interested in parsing the TX_EXTRA_TAG_ADDITIONAL_PUBKEYS.

Here is how the extra looks like:

ix   value byte
  0     1  01
  1    73  49
 32   230  e6
 33     4  04
 34     4  04
 35    35  23
 36   167  a7
161    86  56
162   148  94

where ix is the 0-based index of the particular byte/value in the extra part. In total there are 163 bytes.

First byte (index 0) means next 32 bytes will be the transaction public key (R in the cryptonote paper). This moves us onto position 33 which is where the TX_EXTRA_TAG_ADDITIONAL_PUBKEYS starts. Next byte is \x04 which,I assume, is as a varint telling us that there are 4 extra pubkeys (we know each is 32B). This means we stop parsing at position 162 (the last byte of the extra field).

This seems to make sense, but I'd like to double check that it's the correct way to parse it.

For the sake of completeness here is the whole hexlified extra field (block 282032, transaction 1 on current stagenet)


1 Answer 1


The structure of your whole extra field is:

01 - TX_EXTRA_TAG_PUBKEY (1 byte)
49fa9fbadf1c1a4d054c6cbf918778f869ad02103501d8da7eec8762eb2202e6 - the tx pubkey (32 bytes)
04 - the number of tx additional pubkeys that will follow (varint)
 - the 4 additonal tx pubkeys (32 bytes each)

Note that if you try to parse the tx extra tag and it is 00, that is padding and you can skip forward a byte. If it is anything other than 00, 01 or 04, then after you read the tag, read a varint next, and then skip that number of bytes (as indicated by the varint) to get to the next tx extra tag id to read.

The varint integer representation is defined in section 1.2 of https://tukaani.org/xz/xz-file-format.txt

  • Will it read a 1 byte varint, or follow the varint representation and collect bytes until a byte with the most significant bit equal to 0 is found (or until 8 bytes have been collected, since that's the max size of a Monero varint)?
    – koe
    Jan 6, 2020 at 10:53
  • 1
    @koe The point of varints is that you don't need to know the number of bytes in advance, you just read until you get the byte with the zero significant bit. I'm not sure exactly how it's implemented in the C codebase, so I can't comment on whether there is a max size.
    – knaccc
    Jan 7, 2020 at 0:24

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.