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.
- When to Use This Method
- Why Transactions Become Stuck
- Create a Stuck Transaction
- Clear a Stuck Transaction
- A Safer Alternative
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 understand, at a high level, the procedure described here before using it to clear a high-value transaction.
For demonstration purposes, this guide instructs you to enter a private key into a live Web form. An attacker can intercept this information and steal funds. Private keys should generally only be handled within a safe computing environment. However, given the small amounts of money involved in this demo, the risk is minor. A description of a more secure alternative appears before the conclusions to this post.
When to Use This Method
You can clear a stuck transaction with the method described here whenever you control one or more of its outputs. If you don’t control at least one output, the network won’t permit you to complete the necessary steps.
Fortunately, you will control at least one output in many situations. If you are the payee, then by definition you’ll control one output at least. However, even a payer controls one output in many transactions due to the need to collect change.
If your wallet supports child-pays-for-parent (CPFP), the method described here may be less convenient and secure. Similarly, if your wallet supports replace-by-fee (RBF), and you’ve marked a stuck transaction as replaceable, then the approach described here is likely to be more expensive and less secure than bumping the fee through your wallet.
In other words, use the method here when a transaction is stuck, you own at least one output, replace-by-fee is not an option, and your wallet doesn’t support child-pays-for-parent.
Why Transactions Become Stuck
The most common reason for a stuck transaction is that it carries a fee that was set too low.
Bitcoin transaction fees can be difficult to understand because they touch on many concepts. An important number to keep in mind is your transaction’s fee density. Fee density (d) is calculated by dividing the transaction fee (f, in satoshis) by its size (s, in bytes):
d = f/s
In Bitcoin’s early days, fees represented a negligible fraction of miner revenue. Today, things are very different. Fees make up an increasingly large part of total revenue, so miners try to optimize the fees they collect from every block.
Pending transactions are selected by first sorting them in reverse order of fee density. The top transaction is removed from the list and added to a candidate block. This step is repeated until the block is full. At that point any remaining transactions will need to wait for the next block to become candidates for inclusion.
Most blocks are completely full today, meaning that some or even most transactions will be left behind. To a first approximation, miners don’t consider a transaction’s current wait time. This means that newer transactions can cut to the front of the line if they pay a higher fee density than yours.
The technique we’ll use to clear the stuck transaction is known as child-pays-for-parent (CPFP). Recall that Bitcoin is an electronic cash system in which users exchange value by transferring ownership of digital tokens. These tokens are called either “coins” or “outputs,” depending on context. A transaction mediates the transfer, which will remain incomplete for as long as a transaction remains stuck.
Fortunately, a miner will consider not only the fees of a pending transaction, but the fees carried by any children.
For example, imagine that Alice pays Bob 5 mBTC using a fee of 0.125 mBTC (12,500 satoshis). The transaction size is 250 bytes, yielding a fee density of 50 satoshis/byte. The market fee density, as determined by estimatefee.com, is 150 satoshis/byte. Bob’s inbound transaction is stuck because Alice’s fee is 1/3 of the competitive market fee.
Bob can clear the transaction by spending one of its outputs with a transaction that pays not only for itself (the child), but the original (the parent).
Imagine that Bob’s child transaction, like the parent, has a size of 250 bytes. The total size of parent and child is therefore 500 bytes. The total fee that must be paid by the child transaction can be found with the following equation:
fc = d×b - fp
where fc is the fee to be paid by the child, d is the current market fee density, b is the length of both transactions in bytes, and fp is the fee already paid by the parent.
The market fee density (d) is 150 satoshis/byte. The combined size of both transactions (b) is 500 bytes. The fee paid by Alice’s original transaction (fp) is 12,500 satoshis. Therefore, the fee that Bob’s child transaction must carry is 62,500 satoshis (150 satoshis/byte×500 bytes - 12,500 satoshis), or 0.625 mBTC. Bob publishes this transaction, causing both it and its parent to be confirmed in the next block.
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 low-value transaction into limbo so that it can later be cleared. Users only interested in clearing a stuck transaction should read this section nevertheless because it discusses the tool that will be used to clear the stuck transaction.
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 estimatefee.com.
Begin by creating three paper wallets. The first will serve as a source, and the second will serve as a destination for a parent transaction with an uncompetitive fee density. The third will serve as the destination for a child transaction that pays for itself and its parent. This can be done by opening a browser tab and loading Bitaddress. Click the Paper Wallet tab and generate three unencrypted addresses without artwork.
First, route a ฿0.002 payment into the first wallet using a competitive fee. Wait for at least one confirmation.
Next, create a stuck transaction paying the second wallet from the first using the browser-based utility Coinb.in. Browse to the site, then select the Transaction option from the New menu. Into the first address field, paste the address of the first wallet, then click Load. Into the second address field, paste the address of the second wallet. Adjust the amount to yield a fee of 386 satoshis (฿0.00199614). Your signed transaction will have a size of about 193 bytes. Therefore, your fee corresponds to a density of about 2 satoshis/byte.
Click Submit when ready. Coinbin will present your unsigned transaction in hex-encoded form. Copy the text to the clipboard.
First, verify your transaction. Scroll to the top of the Coinbin page and click the Verify tab. Paste your clipboard’s contents into the text field and click Submit. Coinbin will show your transaction’s details. Pay close attention to the Outputs section. Ensure that the address matches your “Stuck Parent” wallet address, and that the amount matches your intended payment.
When satisfied with the unsigned transaction, sign it. Scroll to the top of the Coinbin page and click the Sign tab. Paste your raw transaction into the lower text box. Then copy and paste the private key from your wallet Deposit Address into the upper text field. Click Submit. Coinbin will generate a signed transaction in a new text field. Copy the text to your system clipboard.
Finally, publish your signed transaction. From the top of the Coinbin page, click the Broadcast tab. Paste your signed transaction into the text box and click Submit. Coinbin will display your transaction ID (“txid”) with which you can track the status of your transaction.
Use a block explorer such as Tradeblock to prove that your transaction is stuck (“Unconfirmed”). Paste your transaction ID into the text field at the top of the page. Tradeblock is especially useful because it shows the fee density under the heading “Fee/size” in satoshis/byte. Your transaction should have a fee density close to 2 satoshis/bytes. If things have gone according to plan, your transaction will remain unconfirmed for hours.
Clear a Stuck Transaction
Use Coinbin to create a child transaction spending your unconfirmed stuck payment. The procedure is nearly identical to the one described above for creating a stuck parent transaction. From the New menu choose Transaction. Enter the address containing the stuck payment into the first text field, then click Load. Even though your transaction is unconfirmed, Coinbin should display the value of the pending payment. Enter the address that you’ll use to receive your unstuck payment in the second text field.
Choose a payment amount that leaves a fee large enough to pay for both the current transaction and its stuck parent. Use the formula introduced above to guide you:
fc = d×b - fp
For example, if both transactions contain one input and one output, their combined size (b) will be about 382 bytes (2×193 bytes). Your parent transaction already paid 382 satoshis (fp). If the market fee density is currently 141 satoshis/byte, then you’ll need to pay 53,480 satoshis, or 0.53480 mBTC.
Choose a payment amount that leaves an appropriate fee, then click Submit. You may receive a warning about a high fee. Click “OK, I’ve got it!” to continue. Coinbin will generate an unsigned transaction encoded in hex format. Copy it to your system clipboard.
Next, verify your transaction. From the top of the Coinbin page, select Verify. Paste your unsigned transaction into the text field.
After verifying your payment address and amount, sign your transaction. Click the Sign tab. Paste your unsigned transaction into the bottom text field. Into the top text field, paste the private key controlling your Stuck Parent wallet address. Be sure to use the correct private key; using the wrong private key won’t generate an error at this stage, but rather when you attempt to publish the transaction. Click Submit to sign the transaction. Copy the text from the field labeled “Signed transaction.”
Finally, publish your transaction. Click the Broadcast tab at the top of Coinbin. Paste your signed transaction into the text field. Click Submit. Coinbin will respond by displaying your new transaction (“txid”).
Use a block explorer to monitor the confirmation of child and parent. If all went well, both should confirm within the next block or two.
The above procedure has been tested and was found to work as described. Keep in mind, however, that fee densities will fluctuate over time — sometimes quite sharply. Fees reported here may be out-of-date when your transaction becomes stuck. Fee densities can even change during the time it takes to read this post. Be sure your child transaction pays a sufficiently high fee or it too will become stuck.
Nodes have limited capacity to store pending transactions. When no more space is available, transactions are evicted in reverse order of fee density. A parent transaction paying a very low fee may therefore not be available when you try to publish your child transaction. If that happens, you’ll need to re-publish your parent transaction in addition to publishing the child.
A Safer Alternative
The above procedure exposes private keys on a network-connected computer. To avoid this unsafe practice, an alternative signing procedure can be used. It’s 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 about page. Save the archive file to a trustworthy removable medium.
To run Coinbin offline, boot into an offline session such as Tails. 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, Blockchain and Blockcypher can decode and check a transaction before publication.
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. To recap, CPFP can be used to clear a stuck Bitcoin transaction using the following procedure:
- Obtain an address into which you’d like to collect the stuck payment.
- Find the market fee density using estimatefee.com.
- Compute the fee required to pay for both child and parent transactions using the formula fc = d×b - fp, where fc is the child transaction’s fee, d is the market fee density in satoshis/byte, b is the combined size of parent and child in bytes, and fp is the fee paid by the parent transaction.
- Create a child transaction that pays the fee you computed.
- Sign and publish the child transaction.