A Solution
So, what can we do about Alice’s transaction? Is it stuck indefinitely, or can we help to incentivize miners to confirm her transaction? It turns out we can help Alice in this situation using a strategy that relies on economic incentives called Child Pays for Parent, or CPFP.Before explaining CPFP, let’s first briefly look at how Bitcoin transactions are structured. Simplified, a Bitcoin transaction is nothing more than a series of inputs and outputs, where inputs represent some value (in bitcoin) that is being “spent” by the sender. When a recipient wants to then spend the bitcoin that they received, one or more of the outputs that they control will become an input to a new transaction. This new transaction is then a “child” of the previous “parent” transaction. Additionally, a typical Bitcoin transaction includes what’s known as a change output. This change output is generally sent back to the original sender so that they can use it in a future transaction. This concept is no different than if you were to pay for a $5 coffee with a $10 bill and receive $5 in change from the cashier. When you are spending inputs with a fixed amount (in bitcoin or in dollars), there is generally change that you collect from the transaction. This change output is what we will utilize to enable CPFP.Figure 3. Example Diagram showing Parent and Child Transactions with Change OutputsNow that we understand what a child and a parent transaction are, let’s look at how CPFP works. Remember, miners always choose which transactions they want to include in a block based on relative rewards. The Bitcoin protocol does not allow for a child transaction to be included in a block before its parent transactions have been added — it must be included in either the same or a later block because later transactions depend on earlier ones.Building on that fact, whenever there are dependent transactions pending at the same time (parents and children), Bitcoin mining software will actually look at those transactions as a group and compute their corresponding fee rate over the entire set, rather than individually. This makes sense for miners to do so, since those transactions are really only valid when confirmed together. Since miners compute the fee rate over this group of dependent transactions, we can submit a child transaction (spending change outputs that we control) that has a higher fee rate than its parent(s), thus boosting the overall fee rate of the group. This is exactly how CPFP works. Essentially we are making a more profitable transaction available to miners, but the structure of this transaction requires the miners to also pick up some less profitable transactions. To take advantage of this and give our customers a better experience, we built a feature that automates this process of bidding up a stuck transaction.