<p>In short, no such RPCs exist, though there are a few related ones.</p>
<p>There is the &quot;production&quot; mining interface <code>getblocktemplate</code>, which is used by mining software (pools, solo, ...). It gathers transactions from the mempool to be included in a block, and gives information about it. It does not compute a coinbase transaction (to pay out the mining rewards), and thus also cannot determine the Merkle root (as that depends on the coinbase).</p>
<p>For testing purposes, there are &quot;all-at-onces&quot; RPCs like <code>generatetoaddress</code>, which gather transactions, construct a coinbase transaction to pay out the reward, compute the Merkle root of the resulting transactions, and then grind the block nonce in order to construct a fully valid block.</p>
<p>It sounds like you're looking for something in between, which is everything that <code>generatetoaddress</code> does, but without the grinding. This doesn't exist, and it doesn't seem very useful to me. For production use, you want the coinbase to be constructed on the mining side (because modern ASICs are so fast that they need thousands of new coinbases per second, which just wouldn't be feasible to do inside Bitcoin Core), and for testing purposes it generally suffices to either do everything at once, or do something so custom that the entire process is done within test code.</p>

CC BY-SA 4.0
2024-09-04T21:22:20.570Z
2024-09-04T21:22:20.570Z
Pieter Wuille
<p>Trying to get some commands that can construct the block body for me, and then output that along with the Merkle root, based on an input address.</p>
<p>It's fine if they are done as two separate commands, like &quot;savebody&quot; and &quot;getmerkle&quot; or something, I've just been looking through the API and I'm not sure what will do these functions.</p>

CC BY-SA 4.0
2024-09-04T10:11:43.313Z
This question is similar to: [How to hash data from 'getblocktemplate' request](https://bitcoin.stackexchange.com/questions/13394/how-to-hash-data-from-getblocktemplate-request). If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem.
RedGrittyBrick
CC BY-SA 4.0
2024-09-04T10:12:05.267Z
I believe the "normal" processes are described at

https://en.bitcoin.it/wiki/Getblocktemplate

which I think too long to quote here in full.
RedGrittyBrick
CC BY-SA 4.0
2024-09-04T19:14:11.103Z
In case you are not looking for the [`getblocktemplate`](https://bitcoincore.org/en/doc/27.0.0/rpc/mining/getblocktemplate/) RPC or the `generatetoaddress` RPC, could you perhaps elaborate what you are trying to achieve?
Murch
CC BY-SA 4.0
2024-09-04T19:46:24.940Z
@murch im not sure how else to make it more understandable. Just a function that blocks together transactions. and another one that outputs a merkle root
CoinZwischenzug
<transactions><bitcoind><block><bitcoin-cli><getblocktemplate>
Is there a Bitcoin Core RPC that creates a block including merkle root and coinbase based on my address?
CoinZwischenzug
# Is there a Bitcoin Core RPC that creates a block including merkle root and coinbase based on my address?

(Asked by: username_0 on 2024-09-03)

Trying to get some commands that can construct the block body for me, and then output that along with the Merkle root, based on an input address.

It's fine if they are done as two separate commands, like "savebody" and "getmerkle" or something, I've just been looking through the API and I'm not sure what will do these functions.

**Tags:** transactions, bitcoind, block, bitcoin-cli, getblocktemplate

> **Comments:**
> **username_1**: This question is similar to: [How to hash data from 'getblocktemplate' request](https://bitcoin.stackexchange.com/questions/13394/how-to-hash-data-from-getblocktemplate-request). If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem.  
> **username_1**: I believe the "normal" processes are described at  https://en.bitcoin.it/wiki/Getblocktemplate  which I think too long to quote here in full.  
> **username_2**: In case you are not looking for the [`getblocktemplate`](https://bitcoincore.org/en/doc/27.0.0/rpc/mining/getblocktemplate/) RPC or the `generatetoaddress` RPC, could you perhaps elaborate what you are trying to achieve?  
> **username_0**: @username_2 im not sure how else to make it more understandable. Just a function that blocks together transactions. and another one that outputs a merkle root  

---

## 1 answers

### Answer by username_3 on 2024-09-04. Score: 1

In short, no such RPCs exist, though there are a few related ones.

There is the "production" mining interface `getblocktemplate`, which is used by mining software (pools, solo, ...). It gathers transactions from the mempool to be included in a block, and gives information about it. It does not compute a coinbase transaction (to pay out the mining rewards), and thus also cannot determine the Merkle root (as that depends on the coinbase).

For testing purposes, there are "all-at-onces" RPCs like `generatetoaddress`, which gather transactions, construct a coinbase transaction to pay out the reward, compute the Merkle root of the resulting transactions, and then grind the block nonce in order to construct a fully valid block.

It sounds like you're looking for something in between, which is everything that `generatetoaddress` does, but without the grinding. This doesn't exist, and it doesn't seem very useful to me. For production use, you want the coinbase to be constructed on the mining side (because modern ASICs are so fast that they need thousands of new coinbases per second, which just wouldn't be feasible to do inside Bitcoin Core), and for testing purposes it generally suffices to either do everything at once, or do something so custom that the entire process is done within test code.


---

