Bitcoin Transaction Fees Done Right

It happens ever so often – someone tries to send Bitcoins and the transaction is just stuck with zero confirmations forever. The reason is that the transaction is never mined, because the transaction fee was set too low.

In this article, I am going to explain how you set your transaction fee right, and then I’m going to explain what you can do to get your stuck transaction going again, or how to cancel a transaction.

Why do transactions get stuck?

Each transaction has a certain size, depending on some factors, usually it is between about 200 and 1000 byte. When a miner creates a block, they incorporate transactions into the block and get rewarded the transaction fee. The transaction fee is set by the sender of the transaction (i.e. you).

Now, the block size of Bitcoin is limited to 1MB. And because Bitcoin is so popular and there are many transactions, every block is full. The miners will therefore only incorporate transactions with the highest transaction fees. If you set your fee too low, your transaction might stick around for hours, or days, or even weeks without being mined.

What is the right transaction fee?

So, how is the best transaction fee determined? There are websites which can calculate the fee for you. I like this one: https://bitcoinfees.21.co/ – have a look – it lists the predicted block- and time delay by transaction fee.

The transaction fee is usually shown in Satoshi per Byte. One Satoshi, the smallest unit in Bitcoin, equals 0.00000001 BTC. At the time of writing, the page suggests, if you want your transaction to clear in under one hour, you should set a transaction fee of 331-360 Satoshi per byte.

In the official Bitcoin Client, the transaction fee is configured in BTC per Kilobyte, so that’s Satoshi per byte divided by 100’000; so, to set 360 Satoshi per byte, you would set a transaction fee of 0.0036 – on the command line:

$ bitcoin-cli settxfee 0.0036

Ideally you put this as a default into your bitcoin.conf:

paytxfee=0.0036

So, if your transaction has a size of 250 bytes, your fee would be calculated as 0.0036 * 0.25 = .0009 BTC, which at the time of this writing are about $2.54 – be aware that your transaction size might be bigger, though!

How can I get my stuck transaction going again?

That said, your problem still exists – you have sent a transaction, the money is gone, but it is stuck on the network – what now?

Luckily there is a trick – you can double spend the coins with a higher transaction fee. All you have to do is make your bitcoind “forget” that you already sent your money, and then send it again with a higher fee (calculated and set as described above).

First, you stop your bitcoind. I recommend you make a backup of your wallet.dat. And then start it with:

$ bitcoind -zapwallettxes=2

This removes all transactions from your wallet and re-reads them from the blockchain data. This will take quite some time, as the entire block chain is rescanned.

Now your bitcoind is running again but it “forgot” that you have sent your coins. As your transaction is not on the blockchain yet (because it was never mined), it does not re-appear.

$ bitcoin-cli settxfee 0.0036

Now, don’t forget to set the right transaction fee as described above, and then send the transaction again. Your bitcoind will now broadcast your new transaction. It can take some time until the network picks it up, up to one day in my experience – but when it is mined, the old transaction will be abandoned and forgotten.

Note that this strictly only works when your original transaction was never confirmed.

I hope this helped. If you are happy about the result, feel free to send me some Satoshis – thank you 🙂

Why Nuclear Crypto-Buddha?

Hello dear reader, my name is Daniel, and with this first post I am entering the blogosphere. I am a software engineer based in Zurich, Switzerland. I’m a general science and technology nerd, and in this blog, I am going to talk about and discuss the topics which come up on my way to enlightenment.

My first endeavor was to pick a name, and I came up with this, the Nuclear Crypto-Buddha. The name incorporates three things which concern me quite a bit, but the list is not exhaustive. I’m going to give a quick overview on each of the topics below.

Why Nuclear?

When I was seven years old, the Chernobyl Disaster happened, and the world once again became aware of the dangers of the nuclear age. Being a child, I was not able to understand the problem back then, but I was frightened. I wanted to know everything about it, which turns out to be a good way to handle fear.

So I went and started reading about how nuclear power plants and nuclear bombs work; I read about all the science and all the disasters, the well known and the lesser known ones, some of which I am planning to cover in the blog some day. In 2009, I finally visited Chernobyl myself, which was quite an experience.

Now I can say that I feel safe again, but I have lots of largely useless knowledge about everything nuclear.

Why Crypto?

While cryptology played an important role in many ways along my way of becoming and working as a professional software engineer, my main concern of this topic is based on a relatively new phenomenon, namely cryptocurrencies and the concept of blockchains.

While I heard of the infamous Bitcoin early on and even owned some back when they were of little worth, I only later really grasped the concept and the significance of blockchains. Meanwhile, I have invested some money and also I am running an Ethereum node. The picture on the left shows my original Mt.Gox YubiKey.

I am pretty sure that blockchains will play an important role in the future of information technology, and therefore, some of my hopes rely on crypto.

Why Buddha?

Right after my midlife-crisis it struck me, that in the end, every one of us is striving for happiness. Some may not know it, and many confuse it with wealth, but that is what we all want: we want to be happy.

As it turns out, this is neither an original insight, nor is it an easy to pursue goal to become truly happy. It requires work.

Fortunately, there was one guy who had it all figured out a long time ago. His name was Śhakyamuni Buddha. While this guy is often referred to as”the Buddha”, the original teacher and founder of Buddhism, “Buddha” itself actually is a title for someone who is enlightened, it simply means “the awakened” or “the enlightened”.

There is also the term “Crypto-Buddhist“, which refers to someone who secretly is Buddhist. I’m not going to further comment on this 🙂

The guy in the picture on the right is me, on the second day of a stay in at Wat Tan Dong, a secluded Theravada Buddhist temple in the forest far south west of Chiang Mai, Thailand. I had to use that chair because sitting and sleeping on the floor hurt my bones. By the way, that was before I lost more than ten kilos.

So…?

So it has been quite a ride so far, and I want to share my experience and knowledge with you. The journey has just only begun. Hang on tight!