BIP 141 defines the commitment structure here
What i am unsure about is the location of this data. I know it will be in scriptPubKey.
Does this mean Coinbase tx will have more than one output?
Also is there a testnet block with an example of a Coinbase tx with witness commitment?
2 Answers
The witness commitment is in an OP_RETURN output of the coinbase transaction. This means that the coinbase transaction will likely have more than 1 output (although not necessarily as a miner could send the block reward to the OP_RETURN output, but they would be stupid to do so). Here is a testnet block with a witness commitment: https://live.blockcypher.com/btc-testnet/block/00000000000007972a6f786179cb42dbc59f167aafd757b203e6c2eb80d49455/. All testnet blocks should have one as segwit has activated on testnet.
The commitment can be in any of the coinbase's outputs. The coinbase is allowed (and has always been allowed) to contain multiple outputs. SegWit just requires that one of them has a scriptPubKey that starts with 0x6a24aa21a9ed, and that it commits to the witness root.