I was trying to understand the structure of coinbase transaction. I tried a few sources but I still have a few doubts regarding the structure with exactly 1 output. Here is what iI know and the doubts are marked by a ?:
[PARAMETER] [SIZE] [ENDIANNESS] [ALLOWED VALUES]
- version - 4 Bytes - LE - 01000000
- input count - 1 Bytes - xx - 01
- prev tx - 32 Bytes - xx - 0000000000...0000
- prev out n - 4 Bytes - xx - ffffffff (outpoint index or fake index)
- coinbase script length (LCS) - <?> Bytes - <?> - <what is value range of LCS i.e. min and max Bytes?>
length (LCS)
- coinbase script - LCS Bytes :
1 Bytes - xx - 03 (Size of Block Height in next 3 Bytes)
3 Bytes - LE - __ (Valid Block Height in LE for Block being mined)
[LCS-4 Bytes] - xx - xx (ANY binary string is Valid. ANY STRING!!!!)
- sequence - 4 Bytes - xx - ffffffff
- output count - 1 Bytes - xx - 01
- value - <?> Bytes - LE - __ (mining reward + transaction fee of all other included transactions in Satoshi)
- script length (SL) - 1 Bytes - xx - (what is value range of SL i.e. min and max bytes, or is it fixed size?)
- pubkey script - SL Bytes - <?> - __ (What is this?! Is it the wallet address or the public key or something else - of the person who recieves the funds in 'value'?)
- locktime - 4 Bytes - xx - 00000000
Notation:
LE - Little Endian.
BE - Big Endian.
xx - Endianness doesn't matter.
__ - User input.
<..?> - Unclear.'''
Q1: Can someone please address the doubts marked by ? and validate if rest of the structure is correct?
Q2: Does coinbase script have any additional structure, rules or constraints that I missed including here (other than above) that can make the transaction invalid?
Q1: Can someone please address the doubts marked by ? and validate if rest of the structure is correct?
Q2: Does coinbase script have any additional structure, rules or constraints that I missed including here (other than above) that can make the transaction invalid?