Skip to content

Instantly share code, notes, and snippets.

@TrezorHannes
Last active November 6, 2023 07:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TrezorHannes/9caa88cb8d287cc6ab6a9cb5fb892195 to your computer and use it in GitHub Desktop.
Save TrezorHannes/9caa88cb8d287cc6ab6a9cb5fb892195 to your computer and use it in GitHub Desktop.
Quick Child Pays for Parent (CPFP) calculator in Bash to ensure you use the right fee to bump an unconfirmed transaction

Instructions

  • Download the script to your node with wget https://gist.githubusercontent.com/TrezorHannes/9caa88cb8d287cc6ab6a9cb5fb892195/raw/b77d2688b809bf5ac4e00a9b7d080dc6b7b2653f/CPFP-Fee-Calculator.sh
  • Execute it with bash CPFP-Fee-Calculator.sh
  • Add the details of your parent tx weight from mempool explorers like Mempool
#!/bin/bash
echo "This estimates how many sats/vbyte you need to bump your child tx to get your desired parent fee"
#x= targetChildFee
#x = (sat/vB_effective * (vB_parent + vB_child) - current_parent_fee) / vB_child
read -p "Enter the total amount of sats your current(parent) tx cost? " currentFee
read -p "What fee do you want your tx to be in sats/vbyte? " effectiveFee
read -p "Enter Virtual size of Parent? " vBParent
read -p "Enter Virtual size of child? " vBChild
x=$(echo "scale=2; (($effectiveFee * ($vBParent + $vBChild)) - $currentFee) / $vBChild" | bc)
echo -e "Your Child tx needs to be \033[32m$x\033[0m sats/vByte for your parent tx to be \033[32m$effectiveFee\033[0m sats/vByte"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment