Skip to content

Add tx fees for added transactions on block page #152

@Sjors

Description

@Sjors

getblocktemplate includes the fee for each transaction, but getblock does not. So we can calculate the fee for omitted transactions, but not for added transactions.

Bitcoin Core v22 adds support for getting the transaction fee via RPC: bitcoin/bitcoin#18772

This is more complicated than it seems: in order to calculate the fee for a transaction, you need to know the output amounts (which are in the current block) and the input amounts (which are in previous blocks). Fortunately Bitcoin Core also tracks those input amounts in the undo data, which is used when rolling back a block. The above PR uses that undo data to get the fee.

Once released (or we can use the master branch) we need to change Node.get_coinbase_and_tx_ids_for_block, Block.find_or_create_block_and_ancestors and Block.find_missing to use getblock with verbosity 2 rather than 1.

This may require additional refactoring, because so far we would fetch the block from whichever node first told us about it. But now we have to always fetch the full block from v22, which may not have it yet. Instead, it might be better to generalise match_missing_pools! to include obtaining fee info.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions