Two questions about segwit implementation



Summary:

Recently, Aymeric Vitte realized that his segwit implementation was incorrect due to a mistake in reading the specs. He thought that scriptsig would go into witness data as it was; however, op_pushdata is replaced by varlen. Vitte questioned why OP_0 is 00 in witness data and not 0100 and if this applies to other op_codes. The answer lies in the fact that op_pushdata allows for unsigned integers, so the extra byte is used to specify that. Additionally, Vitte asked why there is a 00 length in segwit data for non-segwit inputs. This is because the witness data length is assumed to be the same as the inputs length, and for non-segwit inputs, the 00 is needed to specify that it is empty.


Updated on: 2023-06-13T19:09:35.216223+00:00