Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tx fees for added transactions on block page #152

Open
Sjors opened this issue Mar 17, 2021 · 0 comments
Open

Add tx fees for added transactions on block page #152

Sjors opened this issue Mar 17, 2021 · 0 comments

Comments

@Sjors
Copy link
Collaborator

Sjors commented Mar 17, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant