Skip to content

Latest commit

 

History

History
344 lines (248 loc) · 8.08 KB

signetguide_lnd.md

File metadata and controls

344 lines (248 loc) · 8.08 KB

Signet Guide

This guide walks through the steps necessary to run the PeerSwap daemon 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 lnd, 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 PeerSwap daemon.

Bitcoind (signet)

Download the following files to install Bitcoin Core (replace with the latests version).

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/

Create config dir in home

mkdir -p ~/.bitcoin

Add signet config file

cat <<EOF > ~/.bitcoin/bitcoin.conf
signet=1
server=1
daemon=1
zmqpubrawblock=tcp://127.0.0.1:28332
zmqpubrawtx=tcp://127.0.0.1:28333
EOF

Start the Bitcoin daemon in signet mode

bitcoind

Liquid Testnet(optional)

Download the following files to install elementsd (replace with the latests version).

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]
rpcport=18884
rpcuser=admin1
rpcpassword=123
rpcbind=127.0.0.1
trim_headers=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 -rpcport=18884 -rpcuser=admin1 -rpcpassword=123 getchaintips

with the height of the last block on Liquid testnet explorer.

LND

Note: If building from source, be sure to build with the required tags: make install tags="signrpc walletrpc routerrpc invoicesrpc" otherwise Peerswap will not work.

Download the following files (replace with the latests version)

curl https://raw.githubusercontent.com/lightningnetwork/lnd/master/scripts/keys/roasbeef.asc | gpg --import \
wget https://github.com/lightningnetwork/lnd/releases/download/v0.15.5-beta/manifest-roasbeef-v0.15.5-beta.sig && \
wget https://github.com/lightningnetwork/lnd/releases/download/v0.15.5-beta/manifest-v0.15.5-beta.txt && \
wget https://github.com/lightningnetwork/lnd/releases/download/v0.15.5-beta/lnd-linux-amd64-v0.15.5-beta.tar.gz

Verify the release

gpg --verify manifest-roasbeef-v0.15.5-beta.sig manifest-v0.15.5-beta.txt

If the shasums match this command will return

gpg: Good signature from "Olaoluwa Osuntokun <[email protected]>" [ultimate]

Extract the binaries

tar -zvxf lnd-linux-amd64-v0.15.5-beta.tar.gz

Copy the binaries to the system path

sudo cp -vnR lnd-linux-amd64-v0.15.5-beta/* /usr/bin/

Create config dir in home

mkdir -p ~/.lnd

Add signet config file

cat <<EOF > ~/.lnd/lnd.conf
bitcoin.active=true
bitcoin.signet=true
bitcoin.node=bitcoind
listen=0.0.0.0:39735
EOF

Start LND in the background

lnd </dev/null &>/dev/null &

Create a wallet with

lncli -n=signet create

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

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

Move the PeerSwap binaries to the systempath

sudo cp -vnR ~/go/bin/peerswapd /usr/bin/ && \
sudo cp -vnR ~/go/bin/pscli /usr/bin/

Config file

In order to get peerswap running we need a configuration

mkdir -p ~/.peerswap

Add signet config file. REPLACE USERNAME.

BTC swaps only config

cat <<EOF > ~/.peerswap/peerswap.conf
lnd.tlscertpath=/home/<username>/.lnd/tls.cert
lnd.macaroonpath=/home/<username>/.lnd/data/chain/bitcoin/signet/admin.macaroon
EOF

L-BTC swaps config

cat <<EOF > ~/.peerswap/peerswap.conf
lnd.tlscertpath=/home/<username>/.lnd/tls.cert
lnd.macaroonpath=/home/<username>/.lnd/data/chain/bitcoin/signet/admin.macaroon
elementsd.rpcuser=admin1
elementsd.rpcpass=123 
elementsd.rpchost=http://127.0.0.1
elementsd.rpcport=18884
elementsd.rpcwallet=swaplnd
EOF

L-BTC testnet swaps config

cat <<EOF > ~/.peerswap/peerswap.conf
lnd.tlscertpath=/home/<username>/.lnd/tls.cert
lnd.macaroonpath=/home/<username>/.lnd/data/chain/bitcoin/testnet/admin.macaroon
elementsd.rpcuser=admin1
elementsd.rpcpass=123 
elementsd.rpchost=http://127.0.0.1
elementsd.rpcport=18884
elementsd.rpcwallet=swaplnd
EOF

Cleanup

Remove all unnecessary files and folders

rm go1.19.linux-amd64.tar.gz && \
rm lnd-linux-amd64-v0.15.5-beta.tar.gz && \
rm -r lnd-linux-amd64-v0.15.5-beta && \
rm manifest-roasbeef-v0.15.5-beta.sig && \
rm manifest-v0.15.5-beta.txt && \
rm SHA256SUMS && \
rm -r bitcoin-0.21.1/ && \
rm -r elements-elements-0.21.0.2/ && \
rm bitcoin-23.0-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

Run

start the PeerSwap daemon in background:

peerswapd </dev/null &>/dev/null &

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

lncli -n=signet newaddress p2wkh

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

cln node

lncli -n=signet connect 036ba9411c5bc0f07eaefa427d54973d8e06239c30caaef40775b3ac5c512cacf1@95.217.184.148:39375

lnd node

lncli -n=signet 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)

lncli -n=signet openchannel 02d5ee248489d76b54015df2938318a58ee0e35e4746579bd170efc7f1dd62e799 [amt] 

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

lncli -n=signet listchannels | grep  "chan_id"

and try a swap-out

pscli swapout --sat_amt=[sat amount] --channel_id=[chan_id from above] --asset=btc

Note: The asset could also be lbtc. The above command will perform the swap on the Bitcoin signet rather than the Liquid testnet.

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

pscli lbtc-getaddress