How does CTxWitness know size of vtxinwit? #9109

issue kallewoof opened this issue on November 9, 2016
  1. kallewoof commented at 2:39 AM on November 9, 2016: member

    Looking at the source code, I am confused about the serialization of CTxWitness. Specifically, at https://github.com/bitcoin/bitcoin/blob/master/src/primitives/transaction.h#L258 the following lines:

            for (size_t n = 0; n < vtxinwit.size(); n++) {
                READWRITE(vtxinwit[n]);
            }
    

    This works fine for serialization but I see nowhere vtxinwit.resize() calls which would be necessary for deserialization. Is deserialization even possible with this implementation? How does a deserializer determine vtxinwit.size()?

  2. sipa commented at 3:29 AM on November 9, 2016: member

    How does a deserializer determine vtxinwit.size()?

    All callers of CTxWitness's serializer resize vtxinwit to be equal to vin beforehand.

  3. sipa closed this on Nov 9, 2016

  4. bitcoin locked this on Sep 8, 2021
Contributors

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-20 06:55 UTC