I want to implement a client similar to SPV client.
The client will download block headers and coinbase transactions.
There is an api of downloading block headers such as getheaders.
However, it seemed that there is no api of downloading only a coinbase transaction.

Can I download only a coinbase transaction at a specified height without downloading all transactions at the same block height?

1 Answer
1

The Bitcoin p2p network doesn't provide any methods for downloading transactions at a specific index (in this question, zero) within a block. SPV clients aren't able to perform any sort of validation of transactions that aren't their own, and only basic validation of ones paying to them, so this sort of method isn't provided. Bitcoin Core additionally doesn't maintain indexes of transactions on disk so this would require an additional one to be built for the purpose, or have the node load entire blocks and re-parse them to find transaction positions.