How to confirm a stuck transaction using Child Pays for Parent (CPFP). The easy way.

in #cryptocurrency5 years ago

This article is written based on a Bitcoin transaction. However, the principles and steps should remain the same for coins derived from the Bitcoin code base. E.g. Litecoin, Dogecoin etc.

Don't waste your time using and certainly don't pay for a premium 'accelerator' service. Use the CPFP method by following the below guide.


Introduction

Child Pays for Parent or CPFP for short is an effective method to move a transaction that is stuck in the mempool. The method outlined here is independent of your wallet provider. To do a CPFP transaction you just need a proper wallet, by which I mean one that lets you access your private keys.

In order for a transaction to be confirmed, it requires a satisfactory transaction fee. These incentives the miners to add your transaction to a mined block. This is usually expressed in satoshis/byte. If you send a transaction with a significantly low fee then your node will broadcast it to the network, and it will sit in the mempool of your node and other nodes that it was broadcast too. It will then stay in the mempool until such time that i) the going-rate fee reduces and the tx is included in a mined block, or ii) the tx essentially times-out and drops out other nodes' mempool. The second option may take multiple days to weeks depending on the configuration of the nodes that have knowledge of your tx. It will take even longer if your wallet keeps rebroadcasting the transaction, keep that in mind.

For as long as network nodes have your stuck transaction in their mempool these funds will not be spendable. It's worth mentioning that even if you use any wallet options such as transaction abandoning, zapping, sweeping or clearing it won't make your funds spendable again. The network knows about it and any attempt to cancel the transaction and spend the same input funds again will likely be rejected.

When you send a transaction the following happens: inputs are used to provide the funds to be sent and outputs are created. Usually, 2 outputs are created - to the destination address and to the change address. The change amount is the extra balance from the inputs that exceed the sum of the specified fee and the amount you are sending to the recipient, we'll come back to this.

It is this change address that is critical to the CPFP method. In order to get your stuck low fee transaction to move, we will use the change address as an input in a new transaction. This is an essential part of this process. By using the change address as the sender, a miner that includes this new transaction in a block must then also include the stuck transaction. Why? Because the input being used is an output of the stuck tx, therefore a 'parent'. By mining the new tx it will pull through the stuck.

Take this example:

Inputs:
X1→0.04
X2→0.02
X3→0.02
X4→0.03
Transaction fee→ 0.000045
Outputs:
0.1→ A1
0.009955→ A2

Now look closely at the above. The number of inputs which was determined by my sending wallet is 4 as this makes up at least the desired amount of 0.1 BTC and the 0.000045 BTC transaction fee. However, the sum of the inputs is more than required. So I will have change.

Think of it this way, I'm getting a pizza delivered and it's $16 plus $1.50 delivery charge. 🍕 Pizza guy comes to my >house and I've only got 4 x $5 notes. I give him these four notes and I get $2.50 change back. This is what the A2 output is in the above.

I am the owner of the A2 address. A2 is going to be used in a CPFP transaction to push through the earlier transaction to A1. Like so:

A2 → 0.00995
Transaction fee → 0.009
0.00095 → A3

And that's it. I put a large transaction fee on this because it's covering the size of my stuck transaction and the new transaction. I am the owner of A2 and A3 so I will get back the 0.00095. Here I'm just sending money to myself, I'm not sending any extra money to A1. The transaction is a child of the earlier low fee parent as the inputs are linked.
The large fee second transaction is going to be very attractive to miners and it will be confirmed very quickly. When that happens, the 0.1 BTC going to A1 will go through also.


A real world example.

Let's look at this screenshot below on a transaction on a public blockchain explorer. It has 4 inputs and 2 outputs, and it's 668 bytes in size. The fee used is 5 sats/byte. It's been sitting in the mempool for over 8 hours.

Now, let's look at a Bitcoin fee estimation for this transaction. Given the network condition at the time of writing this article the average fee is closer to 48 sats/byte, we have less than 10% of an ideal fee.
you can see bitcoin mempool and fee stats here How can you fix this?

First, we annotate the image of the public blockchain explorer so we can refer to these address in the same style as above.

Now make a note of the A2 address, here it is the one starting 1AEs

How to send the CPFP transaction

Open https://coinb.in and go to the menu option New → Transaction.
In the 'Address, WIF key or Redeem Script' box paste the A2 address and click Load.
Click on the input tab and you will see that change balance is now an input. That is to say, the value in the Amount box should be exactly the value of the A2 amount.
Now go to the output tab, use your wallet to generate a new address and paste it in here (this is A3 ). You will notice that by default, the entire input amount - in this example 0.01328719 BTC is being used as the transaction fee. We don't want to do that. So on your Outputs tab, in the amounts box, add a value here such that you are decreasing the fee amount and increasing the amount you are sending to yourself. I will go ahead and and make the Output to A3 as amount 0.010 BTC , therefore making the fee a juicy 0.00328719 BTC which at the time of writing is about $14 USD (converted at coin circus price list ) . This is very high and probably too high, you can use a fee estimation website to get a the going-rate as discussed earlier based on the summation of the transaction size in bytes of the stuck tx and this new one you are creating.

Now press submit, copy the output raw transaction to your clip board and head over to the Sign menu item and paste your raw transaction here.

Next, for the Private Key input box you will need to fetch the private key of A2 . The way to do this is dependent on what sort of wallet you are using. In Bitcoin Core, go to the Debug window and then console. Type in the console dumpprivkey A2 - obviously substituting A2 for your real A2 address. Copy this key and use it to Sign the transaction by following the coinb.in instructions. After that - head to Broadcast and send it to the network.

Given the fee is higher and appropriate - both transactions will get confirmed quickly.

Sort:  

Congratulations @coincircus! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You published your First Post
You got a First Vote

Click here to view your Board
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @steemitboard:

Christmas Challenge - Send a gift to to your friends

Support SteemitBoard's project! Vote for its witness and get one more award!

Thank you so much for sharing this amazing post with us!

Have you heard about Partiko? It’s a really convenient mobile app for Steem! With Partiko, you can easily see what’s going on in the Steem community, make posts and comments (no beneficiary cut forever!), and always stayed connected with your followers via push notification!

Partiko also rewards you with Partiko Points (3000 Partiko Point bonus when you first use it!), and Partiko Points can be converted into Steem tokens. You can earn Partiko Points easily by making posts and comments using Partiko.

We also noticed that your Steem Power is low. We will be very happy to delegate 15 Steem Power to you once you have made a post using Partiko! With more Steem Power, you can make more posts and comments, and earn more rewards!

If that all sounds interesting, you can:

Thank you so much for reading this message!

Congratulations @coincircus! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 1 year!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!

is there a way to do this, by pasting the transaction in your own wallet and signing there, so you will know what is done ?

Coin Marketplace

STEEM 0.31
TRX 0.12
JST 0.034
BTC 64742.01
ETH 3172.49
USDT 1.00
SBD 4.10