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 🙂