# How come the fees were higher than the actual amount in the bitcoin transaction?

First of all, sorry for the newbie and probably a stupid question, I am so new to the digital currency thing :)

A day ago, I sent \$2.5 worth bitcoin from my coinbase account to the copay wallet for testing. It went through OK, but later when I looked at the transaction details (via Blockcypher) I noticed that the fee shows up way higher than the actual amount: It was 0.004084 BTC (~16 US dollar as of yesterday).

I understand that the miner fees changes based on the demand and the block space of a transaction takes, and nowadays they are quite high. But I didn't get why the transaction went through in the first place if the fees that high, and I didn't pay for them (I think). Maybe I am missing something (probably I am)!

So, can someone kindly explain to me what's happening?

PS: I am also adding the transaction information from coinbase. In that, the fee shows as 0.000316764 where as in the transaction details page via Blockcypher shows the fees as 0.004084. That is the part I am confused about. In other words, the fees don't match, and I was wondering what is the big discrepancy all about!

• The tx id in text will be nice to have, in order to check the tx (to avoid the struggle of copying it from the image). Commented Sep 18, 2017 at 18:21
• Here it is live.blockcypher.com/btc/tx/… Commented Sep 18, 2017 at 18:30

Basic explanation:

Two things are happening here, first, the transaction is quite big (`2903 bytes`). And second, the inputs of the transaction hold really low value ( `27982 Satoshi` each). If we put together this two facts, what happens is what you have seen, that the most of the transaction value is spent in fees.

Extended explanation:

When a previous transaction output (`utxo`) is used to create an input of a new transaction, there is a minimum amount of data that it will add to the transaction. This data can be split in two parts, a `fixed_size` that will be non-dependant of the input type, and a `variable_size`,that will depend on the input type (and therefore in the `utxo` type).

The `fixed_size` can be defined as follows:

``````fixed_size = prev_tx_id + prev_out_index + nSequence = 32 + 4 + 4 = 40
``````

In the transaction you are referencing, all inputs are `P2PKH`, which means that the minimum amount of `variable_size` data that creating an input will contribute to the transaction can be expressed as follows:

``````min_variable_size = scriptSig_len + PUSH signature + signature + PUSH public_key + public_key
``````

Signatures can be `71-73 bytes` depending on their `r` and `s` components, and public keys can be `33/65 bytes`, depending whether they are compressed or uncompressed. If we take the minimum signature size, and compressed public keys, the result is as follow:

``````min_variable_size = 1 + 1 + 71 + 1 + 33 = 107
``````

and therefore:

``````min_size = fixed_size + min_variable_size = 147
``````

Then, if we check how big was the transaction (`2093 bytes`) and how much was paid as fees (`408400` Satoshi) we get that the fee ratio paid is around `141 sat/b`. Now, if we check how much we should pay just for including one of our inputs in the best case we get:

``````min_size * fee_ratio = 107 * 141 = 20727
``````

So, around the `74%` (`20727/27982 * 100`) of each input value is spent just for paying the fees required to spend itself. If you take into account the rest of the transaction (`version`, `outputs` and `nLockTime`), we got that around the `85%` of the inputs value is paid as fee:

``````total_value = 475694
fee = 408400

perc = fee / total_value * 100 = 85.85
``````
• The part that I am confused that I didn't pay for that high transaction fee that's seen in the screenshot. In the coinbase transaction details shows the fee as 0.00031674 BTC (not as 0.004084 BTC). So I wonder, why the transaction details in the Blockcypher shows up a higher fee value for the transaction? Commented Sep 18, 2017 at 19:55
• Notice that there are 17 inputs in the transaction, if each one of the inputs' "owner" payed 0.00031674 BTC, the total fee amount will be 0.00538458, which is even more than what's shown in Blockcypher. Commented Sep 18, 2017 at 19:59
• Thanks so much sr-gi, I really appreciate your explanations, but the part that puzzles me is that I checked the balances both in the Coinbase and the Copay, and I know that I didn't pay that much high transaction fee! The actual fee that I paid was way lower than the one shows up in the transaction details. That's why I am so confused about the 0.004084 fee, because no one paid for that amount. Commented Sep 18, 2017 at 20:06
• Lets move it to the chat to not spam the comments a lot. chat.stackexchange.com/rooms/65802/… Commented Sep 18, 2017 at 20:22
• Hey @omt66, let me know if you enter the chatroom. Commented Sep 18, 2017 at 22:03

The transaction fee is automatically included by most wallets, so you generally don't specify it.

The other thing you need to understand is that the fee is calculated based on the size of the transaction measured in bytes not btc . Since this transaction is large in bytes and small in btc, the fee is higher than the transferred amount.