Skip to content

Latest commit

 

History

History
266 lines (191 loc) · 6.41 KB

signetguide_cln.md

File metadata and controls

266 lines (191 loc) · 6.41 KB

Signet Guide

This guide walks through the steps necessary to run the PeerSwap plugin on Bitcoin signet and Liquid testnet. This guide was written and tested under Ubuntu-20.04 but the same procedure also applies to different Linux distributions.

Install dependencies

PeerSwap requires core-lightning, bitcoind and an elementsd installation if testing Liquid L-BTC swaps. If you already have all of these installed you can let them run in signet, or testnet mode and skip to the section about using the plugin.

Bitcoind (signet)

Download the following files to install Bitcoin Core. Make sure to download the latest release.

wget https://bitcoincore.org/bin/bitcoin-core-23.0/bitcoin-23.0-x86_64-linux-gnu.tar.gz && \
wget https://bitcoincore.org/bin/bitcoin-core-23.0/SHA256SUMS.asc && \
wget https://bitcoin.org/laanwj-releases.asc

Verify the downloaded data

gpg --import laanwj-releases.asc && \
gpg --verify SHA256SUMS.asc && \
grep bitcoin-23.0-x86_64-linux-gnu.tar.gz && \
sha256sum -c SHA256SUMS.asc 2>&1 

If the shasums match this command will return

bitcoin-0.23.0-x86_64-linux-gnu.tar.gz: OK

Extract the binaries

tar -zvxf bitcoin-23.0-x86_64-linux-gnu.tar.gz

Copy the binaries to the system path

sudo cp -vnR bitcoin-23.0/* /usr/

Start the Bitcoin daemon in signet mode

bitcoind --signet --daemon

Liquid testnet (optional)

Download the following files to install elementsd. Make sure to download the latest release.

wget https://github.com/ElementsProject/elements/releases/download/elements-0.21.0.2/elements-elements-0.21.0.2-x86_64-linux-gnu.tar.gz && \
wget -O ELEMENTS-SHA256SUMS.asc https://github.com/ElementsProject/elements/releases/download/elements-0.21.0.2/SHA256SUMS.asc

Verify the downloaded data

gpg --keyserver hkps://keyserver.ubuntu.com --recv-key "DE10E82629A8CAD55B700B972F2A88D7F8D68E87" && \
gpg --verify ELEMENTS-SHA256SUMS.asc && \
sha256sum -c ELEMENTS-SHA256SUMS.asc 2>&1 | grep OK

If the shasums match this command will return

elements-elements-0.21.0.2-x86_64-linux-gnu.tar.gz: OK

Extract the binaries

tar -zvxf elements-elements-0.21.0.2-x86_64-linux-gnu.tar.gz

Copy the binaries to the system path

sudo cp -vnR elements-elements-0.21.0.2/* /usr/

Create config dir in home

mkdir -p ~/.elements

Add testnet config file (avoid to override existing config files)

cat <<EOF > ~/.elements/elements.conf
chain=liquidtestnet
# Liquid Testnet (liquidtestnet) settings:
[liquidtestnet]

listen=1
txindex=1
validatepegin=0
fallbackfee=0.00000100
daemon=1
rpcport=18884
rpcuser=admin1
rpcpassword=123
rpcbind=127.0.0.1
EOF

Start the daemon in testnet node

elementsd --daemon

Wait for sync

The elements node now has to be synced on Liquid testnet for the plugin to work. To check this, compare the height value from

elements-cli getchaintips

with the height of the last block on Liquid testnet explorer

Core Lightning

Follow the build instructions here.

Create config dir in home

mkdir -p ~/.lightning

Add signet config file

cat <<EOF > ~/.lightning/config
signet
bitcoin-datadir=$HOME/.bitcoin
addr=0.0.0.0:39375
log-level=debug
log-file=$HOME/.lightning/log
EOF

Peerswap

Build

Install golang from https://golang.org/doc/install

wget https://go.dev/dl/go1.19.linux-amd64.tar.gz && \
sudo rm -rf /usr/local/go && \
sudo tar -C /usr/local -xzf go1.19.linux-amd64.tar.gz && \
export PATH=$PATH:/usr/local/go/bin

Clone into the PeerSwap repository and build the plugin

git clone [email protected]:elementsproject/peerswap.git && \
cd peerswap && \
make cln-release

Cleanup

Remove all unnecessary files and folders

rm go1.17.3.linux-amd64.tar.gz && \
rm SHA256SUMS && \
rm -r bitcoin-0.21.1 && \
rm -r elements-elements-0.21.0/ && \
rm bitcoin-0.21.1-x86_64-linux-gnu.tar.gz && \
rm elements-elements-0.21.0.2-x86_64-linux-gnu.tar.gz && \
rm ELEMENTS-SHA256SUMS.asc && \
rm laanwj-releases.asc && \
rm SHA256SUMS.asc

Config (Enable Liquid)

PeerSwap will try to detect the elementsd cookie file at the default location. If you use a different data fir for elementsd you need to add the connection options to the PeerSwap config file in order to enable Liquid swaps.

mkdir -p $HOME/.lightning/signet/peerswap
touch $HOME/.lightning/signet/peerswap/peerswap.conf
echo '[Liquid]
rpcuser="admin1"
rpcpassword="123"
rpchost="http://localhost" # the http:// is mandatory
rpcport=18884
rpcwallet="swap"' > $HOME/.lightning/signet/peerswap.conf

To disable Liquid swaps you can add the following to the PeerSwap config file:

[Liquid]
disabled=true

Run

Start the CLN daemon with:

lightningd --daemon \
        --plugin=$HOME/peerswap/peerswap 

Create a new signet address and receive some sats from https://signet.bc-2.jp/

lightning-cli newaddr

Now connect to another node that has the PeerSwap plugin running, for example these development nodes run by @sputn1ck

cln node

lightning-cli -n=signet connect 0 36ba9411c5bc0f07eaefa427d54973d8e06239c30caaef40775b3ac5c512cacf1@95.217.184.148:39375

lnd node

lightning-cli connect 0369aba787f74feb6c1ef1b7984569723b9eb88a1a7bc7323e67d796711d61a7d4@49.12.106.176:39735

Fund a channel to the connected peer, e.g. @sputn1ck node (replace the nodes pubkey and amount to your needs)

lightning-cli fundchannel 0369aba787f74feb6c1ef1b7984569723b9eb88a1a7bc7323e67d796711d61a7d4 [amt] 

Get a new testnet L-BTC address and then generate some L-BTC to the address via https://liquidtestnet.com/faucet

lightning-cli peerswap-lbtc-getaddress

Add the peer to the allowlist

lightning-cli peerswap-addpeer 0369aba787f74feb6c1ef1b7984569723b9eb88a1a7bc7323e67d796711d61a7d4

After the channel has been funded and is in CHANNELD_NORMAL state get the short channel id per

lightning-cli listfunds | grep short_channel_id

and try a swap-out

lightning-cli peerswap-swap-out [amt] [short_channel_id] lbtc

Note: The asset could also be btc. This will perform the swap on the Bitcoin signet rather than the Liquid testnet.