Repository: bitcoin
Issue: `generateblock` RPC Not Collecting Transaction Fees
Labels: Tests

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Current behaviour

The `generateblock` RPC does not properly collect transaction fees when creating a block. Instead of including the fees in the block reward, the block is created with only the block subsidy, leaving out the fees from transactions included in the block.

### Expected behaviour

The block reward should include both the block subsidy and the transaction fees from all transactions included in the block.

### Steps to reproduce

1. Start a Bitcoin Core node in regtest mode.
2. Generate 101 blocks to fund a wallet.
3. Create a transaction with a fee.
4. Call the `generateblock` RPC with the transaction above.
5. Inspect the resulting block to confirm that the block reward does not include the fee.

### Relevant log output

```
$ bitcoin-cli -regtest getblock 05fe640f818d46b9ba931d8f4179562a0d042008abe4b9ed98072d0bca449f30 2`
```
```json
{
  "hash": "05fe640f818d46b9ba931d8f4179562a0d042008abe4b9ed98072d0bca449f30",
  "confirmations": 1,
  "height": 102,
  "version": 536870912,
  "versionHex": "20000000",
  "merkleroot": "ac0b08a969181b07d5d08a1dedce2aeeea2d30f050b837cd4a90b73846875ecc",
  "time": 1737237217,
  "mediantime": 1737237198,
  "nonce": 5,
  "bits": "207fffff",
  "difficulty": 4.656542373906925e-10,
  "chainwork": "00000000000000000000000000000000000000000000000000000000000000ce",
  "nTx": 2,
  "previousblockhash": "38a851e21e26dc54159198e8eda06c0fb94debb1316dd504b74bb5114f9273fe",
  "strippedsize": 295,
  "size": 440,
  "weight": 1325,
  "tx": [
    {
      "txid": "065d28a4a15b90fc052b613e5db7540f1e5164159ca17fe88f27cfdb857c811d",
      "hash": "ad545fbff90d4ddf126dc835bec6f50fc51a7e72c6b6c9f16bf240e464d68810",
      "version": 2,
      "size": 168,
      "vsize": 141,
      "weight": 564,
      "locktime": 0,
      "vin": [
        {
          "coinbase": "016600",
          "txinwitness": [
            "0000000000000000000000000000000000000000000000000000000000000000"
          ],
          "sequence": 4294967295
        }
      ],
      "vout": [
        {
          "value": 50.00000000,
          "n": 0,
          "scriptPubKey": {
            "asm": "0 a41424b6995beeaef7cbc9a4ebcf91b71793983d",
            "desc": "addr(bcrt1q5s2zfd5et0h2aa7texjwhnu3kute8xpaqgz39r)#qxc0s854",
            "hex": "0014a41424b6995beeaef7cbc9a4ebcf91b71793983d",
            "address": "bcrt1q5s2zfd5et0h2aa7texjwhnu3kute8xpaqgz39r",
            "type": "witness_v0_keyhash"
          }
        },
        {
          "value": 0.00000000,
          "n": 1,
          "scriptPubKey": {
            "asm": "OP_RETURN aa21a9ed3dde4089261cfff17418209ef46ed64df4d49543df0daeafc6fc41ce09766229",
            "desc": "raw(6a24aa21a9ed3dde4089261cfff17418209ef46ed64df4d49543df0daeafc6fc41ce09766229)#hu88gsq4",
            "hex": "6a24aa21a9ed3dde4089261cfff17418209ef46ed64df4d49543df0daeafc6fc41ce09766229",
            "type": "nulldata"
          }
        }
      ],
      "hex": "020000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff03016600ffffffff0200f2052a01000000160014a41424b6995beeaef7cbc9a4ebcf91b71793983d0000000000000000266a24aa21a9ed3dde4089261cfff17418209ef46ed64df4d49543df0daeafc6fc41ce097662290120000000000000000000000000000000000000000000000000000000000000000000000000"
    },
    {
      "txid": "f66ffdec54562ec07aac05c2c25d91937a0059ffebf802705be31f59be76f3e9",
      "hash": "567df936509935ee19841e9b717668cb6d419eeaba41f9c05ab0351a56c3293f",
      "version": 2,
      "size": 191,
      "vsize": 110,
      "weight": 437,
      "locktime": 0,
      "vin": [
        {
          "txid": "f5dc14e8b10b94b038ce9d6a789a12e3428e5acfd07de7ea461762f6c23f267e",
          "vout": 0,
          "scriptSig": {
            "asm": "",
            "hex": ""
          },
          "txinwitness": [
            "304402206b532fdf2ca4111872a8c8c322ab68e21e079253862c3c95cf86d18efcdb143d022039514e377cbac97c3ec1459aec7c9584a56c1c527588600c0435483c7b96535c01",
            "03fc3c5d0caa493055f57d5f3098b42555543a5219519ab90a22b20ddea49f1515"
          ],
          "sequence": 4294967293
        }
      ],
      "vout": [
        {
          "value": 39.99998900,
          "n": 0,
          "scriptPubKey": {
            "asm": "0 a41424b6995beeaef7cbc9a4ebcf91b71793983d",
            "desc": "addr(bcrt1q5s2zfd5et0h2aa7texjwhnu3kute8xpaqgz39r)#qxc0s854",
            "hex": "0014a41424b6995beeaef7cbc9a4ebcf91b71793983d",
            "address": "bcrt1q5s2zfd5et0h2aa7texjwhnu3kute8xpaqgz39r",
            "type": "witness_v0_keyhash"
          }
        }
      ],
      "fee": 10.00001100,
      "hex": "020000000001017e263fc2f6621746eae77dd0cf5a8e42e3129a786a9dce38b0940bb1e814dcf50000000000fdffffff01b4236bee00000000160014a41424b6995beeaef7cbc9a4ebcf91b71793983d0247304402206b532fdf2ca4111872a8c8c322ab68e21e079253862c3c95cf86d18efcdb143d022039514e377cbac97c3ec1459aec7c9584a56c1c527588600c0435483c7b96535c012103fc3c5d0caa493055f57d5f3098b42555543a5219519ab90a22b20ddea49f151500000000"
    }
  ]
}
```

### How did you obtain Bitcoin Core

Compiled from source

### What version of Bitcoin Core are you using?

Bitcoin Core daemon version v28.99.0-ae69fc37e4ff

### Operating system and version

Ubuntu 24.04.1 LTS

### Machine specifications

_No response_