How is the witness reserved value set in a coinbase transaction? In a coinbase transaction the second transaction output seems always to be a 32-byte witness reserved value. Is there any constraint on this value?
The only constraint on this value is that it must be 32 bytes. Otherwise there are no constraints. This is done to allow for a future soft fork to commit to new data and have non-upgraded nodes still be able to store something in the block that commits to the new data. As such, the witness reserved value must remain unconstrained to allow for a future soft fork to work.