This is a technical explanation of how RBF and CPFP work. Sorry, it is not a tutorial because their usage depend on your wallet. Also, note that even if your wallet doesn't support RBF or CPFP, understanding how they work gives you other options.
Replace-By-Fee (RBF)RBF is straightforward. A stuck transaction is replaced by reusing the same coins in a similar transaction that pays a higher fee. A miner can only confirm one of the two transactions, so they will confirm the one that pays the higher fee. If the fee is high enough, they will confirm it immediately. The lower-fee transaction becomes invalid, so it is just discarded. Generally, your wallet must support RBF, because it normally won't allow you to reuse the same coins in another transaction.
Child-Pays-For-Parent (CPFP)First, CPFP is based on an important requirement for confirmation. A transaction is funded by previous transactions, so in order for a transaction to be confirmed, the previous transactions that fund it must be confirmed. For example, suppose address
Y is funded by this transaction:
X ⟶
YThen, in order to confirm a transaction sending from
Y,
Y ⟶
Zthe transaction
X ⟶
Y must be confirmed first. (
Side note: both transactions can be confirmed in the same block).
Now, let's say that you spend the bitcoins at address
A, sending them to an address
B plus a change address
C:
A ⟶
B +
CYou post your transaction,
A ⟶
B +
C, with a low fee.
To speed up the transaction's confirmation, the owner of
B can use
B in a new transaction paying a very high fee, or if the transaction has change,
C, you can do the same with
C.
B ⟶
D, or
C ⟶
EIf the transaction fees for
B ⟶
D or
C ⟶
E are high enough, a miner will want to confirm them immediately. But, the miner must also confirm
A ⟶
B +
C in order to confirm either one of them, so the miner will confirm it also.
In essence, the follow-up transaction is also paying for the previous transaction.
Note: Some wallets do not allow you to spend unconfirmed outputs, i.e. you can't spend B or C until the stuck transaction is confirmed.From: https://www.reddit.com/r/BitcoinBeginners/comments/kwo7b9/explaining_of_cpfp/