<p>The coinbase transaction is not generated automatically from bitcoin core, you need to generate it yourself with the <code>createrawtransaction</code> command.</p>
<p>For the <code>setgenerate</code> is no longer available in the options and you can't use it.</p>

CC BY-SA 4.0
2021-12-07T22:30:36.563Z
So once I generate the **coinbase** using the `createrawtransaction` command, is it safe to assume that it has been added to the list of transactions unique to my `getblocktemplate` rpc call??  And if that's the case, would I have to redo the entire step each time I attempt to mine a new block?
AncientTides
CC BY-SA 4.0
2021-12-09T14:04:45.760Z
when you generate your coinbase transaction you will need it to build your `merkleroot`,  with `getblocktemplate` you will receive other data to build your blockheader
Hamita
CC BY-SA 4.0
2021-12-09T23:50:15.323Z
@[Hamita](https://bitcoin.stackexchange.com/users/106775/hamita) Thanks a great deal. This answers my first 2 questions. I would love to select this as the answer but it only solves half of it. What do you think I should do?
AncientTides
CC BY-SA 4.0
2021-12-10T00:07:13.623Z
And If you wouldn't mind helping your greenhorn friend overhere....... How do I insert the height of block to mined into the coinbase transaction?? I know its stored in hex format and is the starting point of the coinbases's scriptsig -> [Your Answer To a question relating to the creation of the coinbase](https://bitcoin.stackexchange.com/a/98334/127251)
AncientTides
CC BY-SA 4.0
2021-12-12T09:36:38.707Z
For the actual block height The scriptsig begin with ```0350e40a```, the 03 for the next 150 years will remain the same, 50e40a The height of the block in little endian, note that you must include the size before that, and it can't not be greater that 100 bytes
Hamita
CC BY-SA 4.0
2021-12-26T06:49:46.920Z
It would be great if you could combine these comments into your answer @Hamita :)
meshcollider
CC BY-SA 4.0
2021-12-05T14:18:02.217Z
2021-12-05T14:18:02.217Z
Hamita
<p>Regarding question 4, you need to manually create/request a new address each time you need one.</p>

CC BY-SA 4.0
2021-12-28T01:23:16.510Z
Thanks for taking the time to answer my question
AncientTides
CC BY-SA 4.0
2021-12-26T06:45:43.060Z
2021-12-26T06:45:43.060Z
meshcollider
<p>I'm working on a mining script and i just want to really be certain for sure as I wouldn't want to waste Time &amp; resources.</p>
<p><strong>Q1</strong> - Is the coinbase transaction automatically generated by the <strong><code>getblocktemplate</code></strong> or do i have to implement it myself.</p>
<p><strong>Q1(b).</strong> If the inclusion of the <strong>coinbase</strong> transaction is not done automatically and as such is not the first transaction on the list of transactions returned by the <strong><code>getblocktemplate</code></strong> <strong>(as it should be)</strong>...... How would I go around generating the
<strong>coinbase</strong>? Is there a function in the main bitcoin source code that handles this, something I can crop out and make a portable function?</p>
<hr />
<p><strong>Q2.</strong> Assuming <strong><code>coinbase transaction</code></strong> <strong>has</strong> been provided via blockchains protocol to ensure empty blocks are never created again, Is it safe to assume that the coinbase has been generated with the bitcoin address linked to my full node?</p>
<p><strong>Q2(b).</strong> If it has been created and my address set to recieve the rewards, what happens when I currently have more than 1 btc wallet address linked to my wallet?? Is there a way I can specify the address to be used for mining within my <strong>bitcoin.conf</strong>  file ?</p>
<hr />
<hr />
<p><strong>&quot;The hashing/mining tests to be carried out are being spearheaded by a CPU System. To be more specific, A Custom Dynamic Multi-Processor Mining Rig, being fed data and instructions via CPU. The CPU does a bit of mining itself using a different merkleHash generated.&quot;</strong></p>
<hr />
<hr />
<p><strong>Q3.</strong> The <strong><code>generate=1</code></strong> option within the <strong>bitcoin.conf</strong> file, does it mean that my cpu begins mining internally or is it an option that has to be turned ON if a user(miner) intends to mine with their CPU(either alone or with mining rigs handling the hashing process)??</p>
<p><strong>What I'm asking is.. If the <strong><code>generate</code></strong> parameter is not defined or is <strong><code> = 0</code></strong> within <em>bitcoin.conf</em>, does that mean that all mining efforts are wasted ?? or is it only related to the internal mining script deemed to be inefficient?</strong></p>
<hr />
<p>And lastly.....</p>
<p><strong>Q4.</strong> Miners are advised to use different addresses for a level of privacy and anonymity. The question,  Would I have to manually create new addresses at every successful block mined or is there an option to automatically handle that or a button that toggles such a feature off/on within the GUI?</p>
<p>I do hope these questions can be answered by someone.... It's extremely important.. Thanks so much in advance.</p>
<hr />
<h2>UPDATE !! 10/12/2021   01:10AM</h2>
<p><a href="https://bitcoin.stackexchange.com/users/106775/hamita">Hamita</a> successfully answered Questions 1,2 &amp; 3.</p>
<p>Question 4 remains unanswered but since majority of questions have been answered, I'll accept <a href="https://bitcoin.stackexchange.com/a/111108/127251">Hamita's</a> answer as a valid answer to my posted question.</p>

<bitcoin-core><bitcoind><client><block>
Is the coinbase automatically generated by the getblocktemplete rpc call?
AncientTides
# Is the coinbase automatically generated by the getblocktemplete rpc call?

(Asked by: username_0 on 2021-12-03)

I'm working on a mining script and i just want to really be certain for sure as I wouldn't want to waste Time & resources.

**Q1** - Is the coinbase transaction automatically generated by the **`getblocktemplate`** or do i have to implement it myself.

**Q1(b).** If the inclusion of the **coinbase** transaction is not done automatically and as such is not the first transaction on the list of transactions returned by the **`getblocktemplate`** **(as it should be)**...... How would I go around generating the
**coinbase**? Is there a function in the main bitcoin source code that handles this, something I can crop out and make a portable function?

---

**Q2.** Assuming **`coinbase transaction`** **has** been provided via blockchains protocol to ensure empty blocks are never created again, Is it safe to assume that the coinbase has been generated with the bitcoin address linked to my full node?

**Q2(b).** If it has been created and my address set to recieve the rewards, what happens when I currently have more than 1 btc wallet address linked to my wallet?? Is there a way I can specify the address to be used for mining within my **bitcoin.conf** file ?

---

---

**"The hashing/mining tests to be carried out are being spearheaded by a CPU System. To be more specific, A Custom Dynamic Multi-Processor Mining Rig, being fed data and instructions via CPU. The CPU does a bit of mining itself using a different merkleHash generated."**

---

---

**Q3.** The **`generate=1`** option within the **bitcoin.conf** file, does it mean that my cpu begins mining internally or is it an option that has to be turned ON if a user(miner) intends to mine with their CPU(either alone or with mining rigs handling the hashing process)??

**What I'm asking is.. If the **`generate`** parameter is not defined or is  **`= 0`** within *bitcoin.conf*, does that mean that all mining efforts are wasted ?? or is it only related to the internal mining script deemed to be inefficient?**

---

And lastly.....

**Q4.** Miners are advised to use different addresses for a level of privacy and anonymity. The question, Would I have to manually create new addresses at every successful block mined or is there an option to automatically handle that or a button that toggles such a feature off/on within the GUI?

I do hope these questions can be answered by someone.... It's extremely important.. Thanks so much in advance.

---

## UPDATE !! 10/12/2021 01:10AM

[username_1](https://bitcoin.stackexchange.com/users/106775/username_1) successfully answered Questions 1,2 & 3.

Question 4 remains unanswered but since majority of questions have been answered, I'll accept [username_1's](https://bitcoin.stackexchange.com/a/111108/127251) answer as a valid answer to my posted question.

**Tags:** bitcoin-core, bitcoind, client, block


---

## 2 answers

### Answer by username_1 on 2021-12-05. Score: 1 | Accepted answer

The coinbase transaction is not generated automatically from bitcoin core, you need to generate it yourself with the `createrawtransaction` command.

For the `setgenerate` is no longer available in the options and you can't use it.

> **Comments:**
> **username_0**: So once I generate the **coinbase** using the `createrawtransaction` command, is it safe to assume that it has been added to the list of transactions unique to my `getblocktemplate` rpc call??  And if that's the case, would I have to redo the entire step each time I attempt to mine a new block?  
> **username_1**: when you generate your coinbase transaction you will need it to build your `merkleroot`,  with `getblocktemplate` you will receive other data to build your blockheader  
> **username_0**: @[username_1](https://bitcoin.stackexchange.com/users/106775/username_1) Thanks a great deal. This answers my first 2 questions. I would love to select this as the answer but it only solves half of it. What do you think I should do?  
> **username_0**: And If you wouldn't mind helping your greenhorn friend overhere....... How do I insert the height of block to mined into the coinbase transaction?? I know its stored in hex format and is the starting point of the coinbases's scriptsig -> [Your Answer To a question relating to the creation of the coinbase](https://bitcoin.stackexchange.com/a/98334/127251)  
> **username_1**: For the actual block height The scriptsig begin with ```0350e40a```, the 03 for the next 150 years will remain the same, 50e40a The height of the block in little endian, note that you must include the size before that, and it can't not be greater that 100 bytes  
> **username_2**: It would be great if you could combine these comments into your answer @username_1 :)  

---

### Answer by username_2 on 2021-12-26. Score: 1

Regarding question 4, you need to manually create/request a new address each time you need one.

> **Comments:**
> **username_0**: Thanks for taking the time to answer my question  

---

