- Does something like this work?
Not really.
generateblock
is a test-only RPC that actually mines a block using the internal CPU miner, it does not create a block template. So that has absolutely nothing to do with it.
There are basically two ways to insert a transaction:
- The miner would place the transaction in its own memory pool (and eventually broadcast it) using
sendrawtransaction
. Then they would useprioritisetransaction
artificially set transaction fees so that they appear in a block template generated bygetblocktemplate
. - They use an external block template generator which will do the insertion itself. This software can start with a block template created by
getblocktemplate
but it will also have to implement a lot of the block assembly code itself to verify that the model it ends up producing is valid.
- I imagine the node software is constantly updating the block to maximize the amount of fees received. Does this mean this replaces the transaction I added manually?
If they used method 1, no, the manual transaction would not be rolled back since bitcoind remembers the changed fee and will continue to reflect it until this transaction is confirmed.
For method 2, the external template software does the insertion so it remembers it. This external software can even (re)build the model anyway, so that's essentially what bitcoind does in method 1.
- Is there a UI that allows you to do this? For example, shows the current block model + transactions in the memory pool and allows you to replace the transaction in a block model with a transaction from the memory pool? Otherwise I might try building something this way.
I don't think there is such publicly available software. Nowadays, block models are produced by pools, and these pools often use custom software, so they may have tools to do this. But it would not be accessible to the public.