Bitcoin Fees – How to calculate and free stuck transactions


Why are there Bitcoin transaction fees? How much do I need to pay to get my transaction
to go through quickly? What happens if I don’t pay
enough of a fee? Can my transaction get stuck? Is there a way for me to pay less in fees
than most other people do? If you’re looking for
easy to understand answers, stick around, here on Bitcoin Whiteboard Tuesday, we’ll answer these questions
and more. When talking about fees
in the context of Bitcoin we usually are referring to the amount bitcoin owners
pay to bitcoin miners whenever they send funds
to another bitcoin address. In order to truly understand
fees in detail we first need to understand what happens when you send Bitcoins
to another address. After you send a Bitcoin transaction, the first step it goes through is
transaction verification. This means the transaction
is checked by every computer holding a copy of
the Bitcoin blockchain for validity. These computers are called nodes. Basically, at this stage the nodes are checking Bitcoin’s history to make sure that you actually have
the Bitcoins in your account balance that you want to spend. After a transaction is deemed valid it goes into the Mempool,
short for Memory Pool. This is sort of a ‘waiting room’ where the transaction sits and waits
for a miner to pick it up and pack it into a block of transactions. In other words, even though the transaction is valid, we still haven’t updated it into
the global ledger of Bitcoin transaction. At this point the transaction is considered
an “unconfirmed transaction” or a “zero confirmation transaction”. Finally, once a miner picks up
the transaction and includes it
in a successfully mined block the transaction is considered
to be confirmed and the process of sending the funds
is complete. Now here’s the thing – A block can only hold
a finite amount of transactions, so at times when the network
is crowded and there are a lot of transactions
waiting to be confirmed the miner will prioritize
which transactions to pick up based on the fee
attached to the transaction. So fees are a way of
signalling to the miner how urgent your transaction is. If you want to get confirmed faster
you’ll attach a larger fee. If you’re not so time sensitive
you can do with a smaller fee. One thing to keep in mind is that fees are always paid for
by the sender of the transaction. In the past, fees had different rules
than what they do today. You could send transactions for free if your transaction was
small enough in size or if it had “priority”. Today however, things have changed, and every transaction requires a fee
in order to get mined. Calculating the appropriate
Bitcoin transaction fee isn’t as straightforward as it seems. Every transaction has a size,
just like a file size on your computer. Since miners want to
maximize their profit, they will prioritize
transactions that have a larger fee to size ratio,
or feerate for short. Let’s explain with an example
from a different market. When shopping for a home
or an apartment, the price of the home is calculated
in terms of cost per square foot. While the apartment’s price
is comparable to the total transaction fee you pay, in order to measure
the apartment’s value, you need to calculate how much you would need to pay
per square foot. Feerate is Bitcoin’s cost per square foot. Feerate is measured in Satoshis per byte. It basically means how many Satoshis or the smallest unit of account
in Bitcoin that you are willing to pay for every byte or unit of size
of your transaction. This rate varies depending on how much the network is crowded
with transactions, much like the cost of
an apartment varies depending on the demand
for living space in the area you want to live. There are several websites that list
the estimated feerate in order to get your transaction
included into the next block. So how is the transaction size calculated? Well, a transaction size depends on
a number of different factors, let’s go over the most significant ones. The first factor is the number of inputs. Each Bitcoin you own, at its core, is just a reference to past transactions
that were sent to you, adding up to the amount you own. These references are known as inputs. When you send Bitcoins to someone you are basically selecting
different inputs sent to you in the past and forwarding them to the recipient
as outputs. The more inputs
your transaction is comprised of, the bigger its size. For example,
let’s say you own one Bitcoin. That Bitcoin is actually comprised of many references to transactions
sent to you in the past, assuming you accumulated
that one Bitcoin from several sources. When you send this one Bitcoin
to someone else, your transaction will be composed of
all of these previous references. The second factor is
the number of outputs. Simply put, outputs are the number of addresses
you’re paying to. For example, if you’re only paying to one address, it’s highly likely you’ll actually
generate two outputs. One for the address you’re sending to,
and another one to “pay yourself back” the change from your initial payment. For an explanation about change, take a look at our
‘Bitcoin change explained’ video. The last significant factor
in determining your transaction size is the script complexity. Some transactions use special features which we won’t go into in this video
like multisig. These features increase
the transaction size. As you may imagine, it is very difficult for the average user
to calculate the transaction size based on these factors. Luckily, your Bitcoin wallet will do this for you
and suggest the fee you should pay, based on the average feerate
at the moment of transaction. As a side note, you should know that
the Bitcoin blockchain doesn’t list the fee paid
for each transaction explicitly. The only way to deduce what fee
was paid by the sender is to calculate the difference between
how many Bitcoins were sent minus how many were received and how many were returned
as change. Here’s an example to illustrate this: In the transaction
you see on the screen, the input is 10 Bitcoins. The outputs are 1.9995 Bitcoins
for the receiving address and 8 Bitcoins have been returned
as change. From this we can calculate that
the missing amount or 0.0005 Bitcoins has been paid as a fee. Let’s move on and explore ways for
paying less in transaction fees. For starters, you can avoid sending transactions
when the network is busy. When the Bitcoin network
is extremely busy, for example, when the price spikes and many people are looking
to buy Bitcoin, users will bid up their fees in order to
prioritize their transactions. This can cause fees
to become ridiculously expensive. If you can delay a transaction to a time
when the network is less crowded you may be able to save
a lot of money on fees. Another option would be to use
a wallet that supports SegWit. SegWit, short for Segregated Witness, is a Bitcoin protocol upgrade
which configures the transaction’s data in such a way as to create
a file that is smaller in size. Many wallets already
support this feature and it can cut costs substantially. Grouping your inputs is a more
advanced method for optimizing fees. The more inputs you need
to create your transaction, the bigger its size, meaning the more fees
you’ll need to pay for it. If you want to keep fees low, every once in a while you can
consolidate your inputs. This is done by sending many
small inputs to an address you own at a time when fees are low. This way, you will significantly reduce
your future fees since you will only have one input. Aside from consolidating inputs you can also group multiple outputs
or payments to one transaction. Not all wallets support this feature,
but if your wallet allows this, you will be able to send payments
to several addresses in one transaction which will reduce the required fee. Now let’s talk about
how Bitcoin wallets deal with fees. Wallets attempt to recommend
a reasonable fee, based on the current and recent
levels of activity of the bitcoin network. Some wallets and services
manage fees poorly and overbid fees, which in turn drives up the fees
for everyone else as well. Most wallets allow you to
adjust your fees or at least set a general fee preference
like low, medium, or high. As I mentioned earlier, to choose the right fee you’ll first need to know
your transaction size. If your wallet supplies you
with that info, you can then use
a feerate estimation table to figure out how much
you need to pay in order to be included
in the next block. Here’s an example: If your transaction size is 16,000 bytes and at the moment of transaction the average feerate to be included
in the next block is 10 Satoshis per byte, then you’ll need to pay 10 X 16,000
or 160,000 Satoshis as a transaction fee, for a good chance to be included
in the next block. Up until now we’ve covered what happens
if you pay enough fees, but what happens if you don’t? While what I’m sharing with you
in this video sheds some light on the topic of fees, most Bitcoin users aren’t “fee experts”. Therefore, more often than not and especially when the price rallies, and the network is crowded, you’ll hear of people complaining that their transaction is stuck
as unconfirmed or pending. There are two things
that can get a transaction stuck, so to speak : #1 You didn’t pay a high enough fee so miners prioritize other transactions
over your own. or #2 You are trying to send coins
from a transaction you received that hasn’t been confirmed yet, and yes, some wallets allow this. So what can you do? Well, here are your options: The first option would be
just to wait it out. If your transaction isn’t urgent, take a break, and forget about it
for at least 72 hours. There’s a good chance that it’ll
sort itself out one way or another. Another option would be to use
the Replace By Fee feature or RBF. RBF allows a wallet to rebroadcast
a transaction with a higher fee. Bear in mind that
not all wallets support RBF, and in certain wallets
RBF is an opt-in feature. If your wallet does support RBF, it can save you a lot of
fee-related headaches, and there’s really no downside
to using it. You can also try
transaction accelerators. There are different
transaction accelerators which are operated by mining pools. They’ll add your transaction
to the next block they mine if they have the capacity to do so. Some are free, while others are free
below certain size limits, some mining pools charge upfront, while there are others that request tips. If all else fails you are left with
two final options: Try to double spend the transaction or use “Child Pays for Parent” Double-spending
sends the same transaction again, but with a higher fee. It’s much like RBF, but with one big difference: RBF transactions
conform to agreed rules, and are incorporated
in several wallet designs. On the other hand, double-spending is explicitly considered
something you shouldn’t do. It’s actually one of the major problems
that Bitcoin was created to solve and that all wallets
are designed to prevent. Child Pays for Parent or CPFP means you essentially spend coins
that are incoming but are yet unconfirmed, which is something
I previously advised against. The idea behind this is that the fees on a new outgoing transaction will be high enough to cover both themselves and the unconfirmed
incoming transactions they depend on. A miner may be enticed to mine
the old, low-fee unconfirmed transaction, in order to claim the new,
high-fee CPFP transaction, as it’s impossible to claim
the new transaction before the old one is confirmed. Both these processes
are rather difficult procedures which may place your funds at risk and are not intended
for the average user so we won’t go over them in this guide. Many people often ask us, can my transaction get stuck forever? Well the short answer is no. The Correct answer is probably not, but it depends. Earlier in this video I talked about the transaction
waiting in the mempool to get picked up by a miner. Well, the mempool doesn’t exist
in just one place. Each computer or node
that validates transactions has a part in its hard drive that is dedicated for storing
pending transaction. So different nodes have different
versions of the mempool, depending on which transactions
they know about and remember. If a transaction is not confirmed
for a long period of time, it will eventually be erased
from a node’s mempool. The current default time period
for deletion is 72 hours but nodes may set their own duration. This is why waiting
for at least 72 hours will probably yield one of two results: Either your transaction
will get confirmed, or it will get erased from
all of the mempools in the network and the funds will be returned
to your wallet. Having said that, it’s possible that a certain node
will never forget about your transaction, and may even occasionally
rebroadcast it, which reminds other nodes about it. In that case, your transaction can be stuck forever unless you use some of the methods
I’ve mentioned earlier. As you can see the issue of fees is pretty complex and can be a topic
for a lot of controversy. Keeping fees low is important since having a cheap
peer to peer payment system is one of the goals
Bitcoin was created to achieve, but as always
there are other considerations to take into account,
aside of low fees. As Bitcoin grows in popularity, more and more people
will begin using it and the network needs to find
new solutions to handle the demand. One promising candidate for such
a solution is the Lightning Network. While it’s not quite ready
for mainstream adoption, the Lightning Network promises
nearly instant, free transactions to all Bitcoiners but that’s a topic for a different video. Hopefully by now you better
understand the topic of fees and how they act as a method of
prioritizing Bitcoin transactions. You may still have some questions. If so, just leave them
in the comment section below. And if you’re watching this video
on YouTube, and enjoy what you’ve seen, don’t forget to hit the like button. Then make sure to subscribe
to the channel and click that bell so that you’ll be notified
as soon as we post new episodes. Thanks for joining me
here at the Whiteboard. For 99Bitcoins.com, I’m Nate Martin, and I’ll see you… in a bit.

Leave a Reply

Your email address will not be published. Required fields are marked *