How do you create a "coinbase tx"? Can it be built via createrawtransaction or can it only be created in code? Then I don't fully understand how to build this transaction.
Create it manually: createrawtransaction doesn't allow you to set the script of the input.
version: 02000000
marker: 00
flag: 01
txIns:
num: 01
in-1:
txid: 0000000000000000000000000000000000000000000000000000000000000000
index: ffffffff
script:
length: 31
block-height-BIP34: 03 ed630c
extra-nonce: 04a95e29652f466f756e6472792055534120506f6f6c202364726f70676f6c642f1a0727769676000000000000
sequence: ffffffff
txOuts:
num: 02
out-1:
value: 46edf02500000000
script:
length: 16
P2SH: 00 14 35f6de260c9f3bdee47524c473a6016c0c055cb9
out-2:
value: 0000000000000000
script:
length: 26
OP_RETURN: 6a
OP_PUSH_38: 24
commitment-header: aa21a9ed
commitment-hash: 95c53abf59b8c6df571b1ca9ff8ad0e6f77a82b2b59c229463cda7a0281a4caf
witness:
count: 01
witness-1:
length: 20
data: 0000000000000000000000000000000000000000000000000000000000000000
locktime: 00000000