<p>A miner will create a special type of transaction known as a Coinbase transaction, as the first transaction in the block. This special transaction pays the block reward (including transaction fees) to the miner (or anyone they choose). But the miner can only put one, valid coinbase transaction in a block because otherwise the block as a whole would be invalid, and all the full nodes would reject it, making the miners work wasted because the block doesn't get onto the valid blockchain and they receive nothing. So miners are forced to play by the rules.</p>

<p>And yes, getblocktemplate includes the coinbase transaction if coinbasetxn is included in the capabilities list</p>

CC BY-SA 3.0
2017-08-30T07:20:02.830Z
Note that a block _must_ contain exactly one coinbase transaction. It's invalid without one as well. ;)
Murch
CC BY-SA 3.0
2017-08-30T10:09:51.597Z
@RafaelMilewski, bitcoin core doesn't currently support coinbasetxn I believe
meshcollider
CC BY-SA 3.0
2017-08-16T00:58:33.970Z
thats right however sending `coinbasetxn` as noted here in the documentation doesnt seens to generate it to me on the result any idea why? https://github.com/bitcoin/bips/blob/master/bip-0022.mediawiki#block-template-request
Rafael Milewski
CC BY-SA 3.0
2017-08-11T07:56:51.283Z
2017-08-11T07:56:51.283Z
meshcollider
<p>After getting the <a href="https://en.bitcoin.it/wiki/Getblocktemplate" rel="nofollow noreferrer">getblocktemplate</a>, hashing it, finding a solution and generating the proper message to submit to the blockchain, if i ever solve a block how does the network knows it was me and properly give the reward to my wallet?</p>

<p>i heard somewhere that i need to append a transaction sending 12.5 BTC to myself before generating the message, if that is true what does prevent anyone of generating more than one transaction and append before solving a block?</p>

<p>Does <strong>getblocktemplate</strong> coming from my bitcoin-cli already generates this transaction for me? </p>

CC BY-SA 3.0
2017-08-11T05:54:40.410Z
related: https://bitcoin.stackexchange.com/q/4571/5406, https://bitcoin.stackexchange.com/q/5543/5406, https://bitcoin.stackexchange.com/q/17999/5406
Murch
<mining-reward><coinbase-transaction><getblocktemplate>
How does bitcoin reward who find the block?
Rafael Milewski
# How does bitcoin reward who find the block?

(Asked by: username_0 on 2017-08-11)

After getting the [getblocktemplate](https://en.bitcoin.it/wiki/Getblocktemplate), hashing it, finding a solution and generating the proper message to submit to the blockchain, if i ever solve a block how does the network knows it was me and properly give the reward to my wallet?

i heard somewhere that i need to append a transaction sending 12.5 BTC to myself before generating the message, if that is true what does prevent anyone of generating more than one transaction and append before solving a block?

Does **getblocktemplate** coming from my bitcoin-cli already generates this transaction for me?

**Tags:** mining-reward, coinbase-transaction, getblocktemplate

> **Comments:**
> **username_1**: related: https://bitcoin.stackexchange.com/q/4571/5406, https://bitcoin.stackexchange.com/q/5543/5406, https://bitcoin.stackexchange.com/q/17999/5406  

---

## 1 answers

### Answer by username_2 on 2017-08-11. Score: 3

A miner will create a special type of transaction known as a Coinbase transaction, as the first transaction in the block. This special transaction pays the block reward (including transaction fees) to the miner (or anyone they choose). But the miner can only put one, valid coinbase transaction in a block because otherwise the block as a whole would be invalid, and all the full nodes would reject it, making the miners work wasted because the block doesn't get onto the valid blockchain and they receive nothing. So miners are forced to play by the rules.

And yes, getblocktemplate includes the coinbase transaction if coinbasetxn is included in the capabilities list

> **Comments:**
> **username_0**: thats right however sending `coinbasetxn` as noted here in the documentation doesnt seens to generate it to me on the result any idea why? https://github.com/bitcoin/bips/blob/master/bip-0022.mediawiki#block-template-request  
> **username_1**: Note that a block _must_ contain exactly one coinbase transaction. It's invalid without one as well. ;)  
> **username_2**: @username_0, bitcoin core doesn't currently support coinbasetxn I believe  

---

