- Does it work something like this?
No, not really.
generateblock
is a testing only RPC that actually mines a block using the internal CPU miner, itt does not make a block template. So it's completely irrelevant to this.
There are basically two ways of inserting a transaction:
- The miner would put the transaction in their own mempool (and possibly end up broadcasting it) by using
sendrawtransaction
. Then they would use prioritisetransaction
to artificially set the transaction's fee so that it will appear in a block template generated by getblocktemplate
.
- They are using some external block template generator that will do the insertion itself. This software may begin with a block template created by
getblocktemplate
, but it will have to also implement a lot of the block assembly code itself to verify that the template it ends up producing is valid.
- I imagine the node software is constantly updating the block to maximize the amount of fees received. Does it mean it overrides the transaction I added manually?
If they used method 1, no there would not be any overriding of the manual transaction since bitcoind remembers the modified fee and will continue to account for it until that transaction is confirmed.
For method 2, the external template software is doing the insertion so it will remember. That external software may even be (re)building the template anyways, so it's basically what bitcoind is doing in method 1.
- Is there some UI that allows you to do this? E.g. displays the current block template + transactions in mempool and allows you to replace transaction in a block template with transaction from the mempool? If not, I might attempt to build something in that fashion.
I don't think there are any such software that is publicly available. These days, block templates are produced by pools, and these pools often use custom software, so they may have tooling that does this. But it would not be available to the public.