Skip to content

ca-ruz/bumpit

Repository files navigation

BumpIt Plugin

A Core Lightning plugin to create CPFP (Child Pays For Parent) transactions for opening lightning channels.

Prerequisites

  • Python 3.7+
  • Core Lightning 24.11+
  • Bitcoin Core
  • txindex in Bitcoin Core

Note: This plugin does not work with lightning version 24.08 because it uses the listaddresses rpc call, which was introduced in version 24.11.

Installation

  1. Clone the repository:
git clone https://github.com/ca-ruz/bumpit.git
cd bumpit
  1. Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate
  1. Install dependencies:
# Install plugin dependencies
pip install -r requirements.txt

# Install test dependencies
pip install -r requirements-dev.txt

Usage

  1. Make sure you are running Bitcoin Core and Core Lightning

  2. Start the plugin:

lightning-cli plugin start $PWD/bumpit.py
  1. Find a peer ID you want to open a channel with

  2. Open a channel:

lightning-cli fundchannel <peer_id> <amount_in_sats> [feerate]
  1. Get the funding transaction txid and change vout:
l1-cli listfunds | jq '
  [ .channels[] | select(.state | test("AWAITING")) | .funding_txid ] as $target_txids
  | [ .outputs[] | select(.txid as $output_txid | $target_txids | index($output_txid)) ]
'
  1. Create a CPFP transaction:
lightning-cli bumpchannelopen <txid> <vout> <amount> [yolo]

Note: amount is the fee/feerate, should be specified in either sat/vB, e.g.'5satvb' or sats e.g. '1000sats'

Optional: Type the word yolo as an argument after the amount or use -k with yolo=yolo if you want the plugin to broadcast the transaction for you.

Running Tests

The test suite uses Core Lightning's test framework and requires a regtest environment. You need to run the following commands inside of the plugin directory.

  1. To run all tests:
pytest -vs
  1. To run an individual test:
pytest -vs <name_of_the_test_file.py>

Manual Testing in Regtest

Note: By default, the fund_nodes command in regtest will automatically mine a block, this will confirm the funding transaction. We need to change this in the config, otherwise we wouldn't be able to test the plugin.

Steps to deactivate minning the block automatically

  1. Navigate to Core Lightning's contrib directory:
cd ~/code/lightning/contrib
  1. Open the config:
nano startup_regtest.sh 
  1. Look for the fund_nodes function and comment out this lines:
#		"$BCLI" -datadir="$BITCOIN_DIR" -regtest generatetoaddress 6 "$ADDRESS" > /dev/null
#
#		printf "%s" "Waiting for confirmation... "
#
#		while ! "$LCLI" -F --lightning-dir=$LIGHTNING_DIR/l"$node1" listchannels | grep -q "channels"
#		do
#			sleep 1
#		done
  1. Save & exit

Steps for testing

  1. Start the regtest environment:
source startup_regtest.sh
start_ln
  1. Fund the nodes:
fund_nodes
  1. Start the plugin (from the plugin directory):
l1-cli plugin start $PWD/bumpit.py
  1. Get the funding transaction txid and change vout:
l1-cli listfunds | jq '
  [ .channels[] | select(.state | test("AWAITING")) | .funding_txid ] as $target_txids
  | [ .outputs[] | select(.txid as $output_txid | $target_txids | index($output_txid)) ]
'
  1. Create a CPFP transaction:
l1-cli bumpchannelopen <txid> <vout> <amount> [yolo]

Note: amount is the fee/feerate, should be specified in either sat/vB e.g.'5satvb' or sats e.g. '1000sats'

Optional: Type the word yolo as an argument after the amount or use -k with yolo=yolo if you want the plugin to broadcast the transaction.

Plugin Configuration

The plugin accepts the following configuration options:

  • bump_brpc_user: Bitcoin RPC username
  • bump_brpc_pass: Bitcoin RPC password
  • bump_brpc_port: Bitcoin RPC port (default: 18443)
  • yolo: Set to 'yolo' to broadcast the transaction automatically.

Contributing

  1. Fork the repository
  2. Create a new branch for your feature
  3. Make your changes
  4. Run the test suite to ensure everything works
  5. Submit a pull request

About

Plugin to create cpfp transaction for opening lightning channels

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages