# [bitcoin-dev] Why not Child-Pays-For-Parent?

Tier Nolan tier.nolan at gmail.com
Fri Jul 10 16:28:02 UTC 2015

```On Fri, Jul 10, 2015 at 5:09 PM, Richard Moore <me at ricmoo.com> wrote:

> I was also wondering, with CPFP, should the transaction fee be based on
> total transactions size, or the sum of each transaction’s required fee? For
> example, a third transaction C whose unconfirmed utxo from transaction B
> has an unconfirmed utxo in transaction A (all of A’s inputs are confirmed),
> with each A, B and C being ~300bytes, should C’s transaction fee be 0.0001
> btc for the ~1kb it is about to commit to the blockchain, or 0.0003 btc for
> the 3 transactions it is going to commit.
>

It should be whatever gives the highest fee.  In effect, child pays for
parent creates compound transactions.

A: 250 bytes, 0 fee
B: 300 bytes: 0.0005 fee
C: 400 bytes: 0.0001 fee

There are 3 combinations to consider

A: 0 fee for 250 bytes = 0 per byte
A&B: 0.0005 fee for 550 bytes = 0.91 uBTC per byte
A&B&C: 0.0006 fee for 950 bytes = 0.63uBTC per byte

This means that the A&B combination has the best fee per byte value.  A&B
should be added to the memory pool (if 0.91 uBTC per byte is above the
threshold).

Once A&B are added, then C can be reconsidered on its own.

C: 0.0001 for 400 bytes = 0.25 BTC per byte

If that is above the threshold, then C should be added.

In practice, it isn't possible to check every combination.  If there are N
transactions, then checking all triple combinations costs around N cubed.

A 2 pass system could get a reasonably efficient result.

B is 0.0005 fee for 300 bytes = 1.67 uBTC per byte and is assumed to be a
high value transaction.

The algorithm would be

Pass 1:
Process all transactions in order of BTC per byte, until block is full
If the transaction's parents are either already in the pool or a
previous block, add the transaction.

Pass 1:
Process all non-included transactions in order of BTC per byte, until block
is full
If the transaction's parents are either already in the pool or a
previous block, add the transaction.

Otherwise, consider the transaction plus all non-included ancestors as
a single transaction
If this combined transaction has a higher BTC per byte than the
lowest transaction(s),
add the combined transaction
drop the other transaction(s)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxfoundation.org/pipermail/bitcoin-dev/attachments/20150710/68d6acca/attachment.html>
```

More information about the bitcoin-dev mailing list