Skip to content

Instantly share code, notes, and snippets.

@felixcheruiyot
Forked from Stadicus/setup_clightning.md
Created December 29, 2022 11:41
Show Gist options
  • Select an option

  • Save felixcheruiyot/7a1656c075e7b8cf957faa0df8d6a805 to your computer and use it in GitHub Desktop.

Select an option

Save felixcheruiyot/7a1656c075e7b8cf957faa0df8d6a805 to your computer and use it in GitHub Desktop.
Setup c-lightning on Digital Ocean

E-Commerce c-lightning node on Digital Ocean

Prerequisites

  • based on small VPS with Ubuntu 16.04

sPRUNED

https://github.com/gdassori/spruned

$ sudo apt-get install libleveldb-dev python3-dev git virtualenv gcc g++
$ sudo adduser bitcoin
$ sudo su - bitcoin

# bitcoin user session
$ git clone https://github.com/gdassori/spruned.git
$ cd spruned
$ virtualenv -p python3.5 venv
$ . venv/bin/activate
$ pip install -r requirements.txt
$ python setup.py install
$ exit

$ sudo nano /etc/systemd/system/spruned.service

# sPRUNED: systemd unit
# /etc/systemd/system/spruned.service

[Unit]
Description=sPRUNED Bitcoin node
After=network.target

[Service]
ExecStart=/home/bitcoin/src/venv/bin/spruned --network bitcoin.mainnet --rpcuser xxx --rpcpassword xxx
Type=simple
User=bitcoin
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target

Start & enable

$ sudo systemctl daemon-reload
$ sudo systemctl start spruned
$ sudo systemctl status spruned
$ sudo systemctl enable spruned

bitcoin-cli

https://bitcoin.org/en/download

# admin user session

$ mkdir download && cd download
$ wget https://bitcoin.org/bin/bitcoin-core-0.16.1/bitcoin-0.16.1-x86_64-linux-gnu.tar.gz
$ tar -xvf bitcoin-0.16.1-x86_64-linux-gnu.tar.gz
$ sudo install -m 0755 -o root -g root -t /usr/local/bin bitcoin-0.16.1/bin/bitcoin-cli

$ mkdir /home/bitcoin/.bitcoin
$ sudo nano /home/bitcoin/.bitcoin/bitcoin.conf
# Connection settings
rpcuser=xxx
rpcpassword=xxx

c-lightning

https://github.com/ElementsProject/lightning

# admin user session

$ sudo apt-get update
$ sudo apt-get install -y \
  autoconf automake build-essential git libtool libgmp-dev \
  libsqlite3-dev python python3 net-tools zlib1g-dev
$ cd 
# bitcoin user session
$ git clone https://github.com/ElementsProject/lightning.git
$ cd lightning
$ git tag -l
$ git checkout tags/v0.6
$ ./configure
$ make
$ sudo make install

Create systemd unit
$ sudo nano /etc/systemd/system/lightning.service

# c-Lightning: systemd unit
# /etc/systemd/system/lightning.service

[Unit]
Description=c-Lightning daemon
Requires=spruned.service
After=spruned.service

[Service]
ExecStart=/usr/local/bin/lightningd --pid-file=/home/bitcoin/.lightning/lightning.pid --daemon
PIDFile=/home/bitcoin/.lightning/lightning.pid
User=bitcoin
Type=forking
Restart=on-failure
RestartSec=10

# Hardening measures
####################

# Provide a private /tmp and /var/tmp.
#PrivateTmp=true

# Mount /usr, /boot/ and /etc read-only for the process.
#ProtectSystem=full

# Disallow the process and all of its children to gain
# new privileges through execve().
#NoNewPrivileges=true

# Use a new /dev namespace only populated with API pseudo devices
# such as /dev/null, /dev/zero and /dev/random.
#PrivateDevices=true

# Deny the creation of writable and executable memory mappings.
#MemoryDenyWriteExecute=true

[Install]
WantedBy=multi-user.target

Start and enable unit

$ sudo systemctl daemon-reload
$ sudo systemctl start lightning
$ sudo systemctl status lightning
$ sudo systemctl enable lightning
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment