A Bitcoin transaction can fail to confirm, or become “stuck,” for many reasons. Stuck transactions may be confirmed after several days, but sometimes waiting isn’t an option. Fortunately, many stuck transactions can be cleared using nothing more than a Web browser. This article shows how.
The procedure described here should not be used by beginners trying to clear a stuck transaction of significant value. Doing so can lead to loss of money.
This article describes a practical technique for creating and clearing a stuck transaction, but using this technique effectively takes practice and understanding. To get the most out of it, consider following the article as written and only commit a trivial amount of money.
If any step describes a concept that doesn’t make sense, find a way to understand it. Leave a comment at the bottom of the article. Ask a knowledgeable friend. Post a question to BitcoinBeginners, Bitcoin Subreddit, or Bitcoin Stack Exchange. Whatever happens, be sure you undertand, at a high level, the procedure described here before using it to clear a high-value transaction.
Why Transactions Become Stuck
The most common cause for a stuck transaction is that it carries a fee that was set too low.
Bitcoin fees are a complicated topic, but the most important number to keep in mind is your transaction’s fee density. Fee density is calculated by dividing the transaction fee (in satoshis) by the length of the transaction (in bytes).
Fees make up a tiny fraction of miner revenue today, but miners already act as if they’re trying to maximize revenue from fees. The process begins by isolating transactions that don’t qualify for a fee waiver. These transactions are then sorted by fee density. Next, the transaction with the highest fee density is added to a candidate block. Then the transaction with the second highest fee density is added, and so on.
When block capacity exceeds transaction demand, all waiting transactions can be added to a candidate block. But during times of high transaction volume such as those that have recently taken place, then some transactions will be left behind. To a first approximation, miners don’t consider the time a transaction has already waited. This means that newer transactions can cut to the front of the line if they have a higher fee density than yours.
The problem is a bit like a diver collecting items from the bottom of a lake. High density items thrown in will sink to the bottom and will be eventually be collected. Less dense items won’t sink to the bottom and so can’t be collected no matter how many of them are thrown in.
The technique we’ll use to clear the stuck transaction is known as double spending. Double spending occurs when the same coin is spent more than once. Recall that Bitcoin is an electronic cash system in which users move value around by transferring ownership of digital tokens called “coins”.
A successful double spend invalidates a stuck transaction, thereby clearing it. Double spending an unconfirmed transaction is conceptually the same thing as double spending a confirmed transaction, but orders of magnitude easier.
Specifically, we’ll be relying on a mode of operation known as First-Seen-Safe Replace-by-Fee (FSS RBF). In a nutshell, FSS RBF is a node policy that replaces one unconfirmed sibling with another, provided that the second sibling pays a higher fee and routes payments through all of the same addresses.
Create a Stuck Transaction
The best time to learn how to clear a stuck transaction is before it becomes critical to do so. This section describes how to place a dummy transaction into limbo so that it can later be cleared.
Stuck transactions are easiest to create during times of high transaction volume. One way to determine if this condition holds is to use a fee monitoring tool such as Cointape.
Begin by creating two key pairs. The first will serve as a source and second will serve as a destination for a transaction with an uncompetitive fee density. This can be done by opening a browser tab and loading Bitaddress. Generate two unencrypted addresses without artwork.
Route four payments totaling ฿0.001 through the first address using transactions with high fee density. Alternatively, a four-output transaction can split payments totaling ฿0.001 among the same address. Copy the first address to the clipboard, and keep Bitaddress tab open. The purpose of making four payments is to later produce a child transaction that can easily be given a fee density of approximately 1 satoshi/byte and an absolute fee of 1,000 satoshis, the minimum required for transaction relay.
Open a new browser tab and load the Blockchain block explorer. Paste the address you copied into the search box and click the button labeled “Search.” Wait until refreshing the page shows that all four deposits received at least one confirmation. Keep this tab open.
After your deposits have been confirmed, create a transaction that spends them with a fee density close to 1 satoshi/byte. To do so, open a third browser tab and load Coinbin. Coinbin is a convenient tool for creating custom transactions. Load Coinbin’s Transaction page by selecting the “Transaction” option from the tab labeled “New.”
Begin by pasting the address on the clipboard into the first field of the Coinbin Transaction page. Click the button labeled “Load.” After a few seconds, you should see a message informing you that unspent outputs have been retrieved. Next, copy the payment address from the Bitaddress tab (it should be the second one listed). Return to the Coinbin tab, then scroll down until a field labeled “Address” becomes visible. Paste the payment address into the text field. Use an amount of ฿0.00099. The field directly below the payment address, labeled “Transaction Fee,” should read ฿0.00001. If network transaction volume is too low, a fee of zero satoshis can be set by spending the entire balance on the sending address. Generate the unsigned transaction by pressing the button labeled “Submit.” Copy the raw hex bytes to the system clipboard.
The transaction can now be signed. Scroll to the top of the Coinbin page, then click the “Sign” tab. Paste the raw transaction bytes into the second text area. From the Bitaddress browser tab, copy the private key for the first address. Then open the Coinbin tab and paste this private key into the field labeled “Private key.” Generate the signed transaction by pressing the button labeled “Submit.” A new section labeled “Signed transaction” should appear. If signed correctly, the transaction’s hex byte sequence should be longer than the hex byte sequence of the unsigned transaction. Next, copy the hex byte sequence of the signed transaction.
The signed transaction can now be published. Scroll to the top of the Coinbin page and click the tab labeled “Broadcast.” Paste the signed transaction raw hex bytes into the text area. Publish the transaction by clicking the button labeled “Submit.” Coinbin should present a success message with the transaction’s ID.
Confirm that your new transaction has propagated by clicking on the Blockchain browser tab. After refreshing the page, a second transaction should appear. Click on the transaction ID link, and verify that the amount of the transaction and fee are ฿0.00099 and ฿0.00001, respectively. The latter value is 1,000 satoshis. Dividing it by the size of the transaction in bytes should give a number just over 1, the minimum fee density required by the network.
This transaction may be confirmed as you’re completing the next steps. However, if you’re performing this test during a time of high transaction volume, it’s likely to remain stuck for several blocks at least. Checking for the transaction ID on several block explorers is informative. Some block explorers may not report having seen the transaction, a consequence of poor network propagation. That’s what we’re aiming for.
Clear a Stuck Transaction
Having produced a stuck transaction, its double spending sibling can now be created. Return to the Coinbin browser tab. Click on the “New” tab and select the “Transaction” option. Coinbin should have remembered the information you previously entered. All that’s needed is to update the payment amount. Replace it with ฿0.0006. Coinbin should simultaneously update the fee to ฿0.0003, a 70-fold increase. Scroll down to the button labeled “Submit” and press it. Coinbin should update the raw transaction byte sequence. Copy the new raw byte sequence, scroll to the top of the page, and then click the “Sign” tab.
Sign the double spending transaction as before. Replace the existing raw byte sequence with the one you just copied. There should be no need to update the private key. Scroll to the bottom of the page and click the button labeled “Submit.” Coinbin should update the signed transaction byte sequence. Copy it.
We can’t publish this new transaction using Coinbin because it will be rejected as a double spend. Instead, we need to find another node that will accept it. A list of “pushtx” URLs can be found on the Bitcoin Wiki. As of mid-2015, one of the pushtx services listed there was found to accept transactions of the kind we’re about to publish, the Localbitcoins block explorer. Open a new browser tab to this page.
Now publish the sibling transaction by pasting the raw transaction bytes into the text field and click the button labeled “Send transaction.” If successful, you’ll receive a message along with a new transaction hash.
Verify the propagation of the sibling transaction by opening a new browser tab pointing to Blockchain. Paste the ID for the sibling transaction into the search box. A transaction summary page should appear. Double spending should be indicated with two warning messages in red. You should see confirmation of the sibling transaction within one or two blocks.
Localbitcoins may stop accepting transactions of the kind you’ve just created at some point in the future. If this happens, a new service will need to be found. A starting point would be to try each service listed on the Bitcoin Wiki page. Alternatively, Bitcoin XT nodes relay double spends. If you can connect to one, it should relay the sibling transaction for you.
A Safer Alternative
The above procedure exposes private keys to a network-connected computer. To avoid this unsafe practice, an alternative signing procedure can be used. This procedure is identical to the original, except that the signing step is performed on an offline computer.
Begin by creating an offline copy of Coinbin. Download the offline bundle by clicking on the “download” link at the bottom of the Coinbin home page. Save the archive file to a trustworthy removable medium.
To run Coinbin offline, boot into an offline session. Open your removable medium and extract the Coinbin archive. Coinbin can be run offline by clicking on the file named
index.html in the
Using this setup, transactions can be created online, saved to a removable medium, signed offline, then published online. To minimize the risk of obtaining a malicious copy of Coinbin that re-routes payments, transactions can be independently parsed and validated using a block explorer. For example, Blockr can decode and check a transaction before publication from its Raw transaction push page.
Clearing a stuck transaction isn’t difficult given the right tools and some practice. This article shows how using a procedure that only requires a Web browser.