This blog is going to calculate the transaction fees of each non-coinbase transaction in a specific block via Python-Bitcoinlib v0.9.0. By the way, Bitcoin transactions have two types: coinbase transactions and non-coinbase transactions, where the coinbase transactions have no transaction fees while non-coinbase transactions have certain transaction fees to pay.
The first example is going to calculate the transaction fees of each non-coinbase transaction in a specific block via Python-Bitcoinlib v0.9.0.
First, we get a specific block.
Second, we go through all transactions in the block.
Third, we sum up the inputs of each transaction, sum up the outputs of each transaction, and calculate the transaction fee via a simple subtraction operation.
Fourth, the source code is named