/ln-swap

Lightning Swap

Primary LanguageJavaScript

Installation

(You need nodejs v11 and npm installed)

  1. Download latest lnd, lncli

https://github.com/lightningnetwork/lnd/releases/tag/v0.7.1-beta

wget https://github.com/lightningnetwork/lnd/releases/download/v0.7.1-beta/lnd-darwin-amd64-v0.7.1-beta.tar.gz
tar -xvf lnd-darwin-amd64-v0.7.1-beta.tar.gz
rm -rf lnd-darwin-amd64-v0.7.1-beta.tar.gz
mv lnd-darwin-amd64-v0.7.1-beta bin
  1. Install js dependencies
npm i
  1. Setup and run lnd in light client mode (TESTNET) in a separate terminal window
bin/lnd --bitcoin.active --bitcoin.testnet --bitcoin.node=neutrino --neutrino.connect=btcd-testnet.lightning.computer --neutrino.feeurl=https://nodes.lightning.computer/fees/v1/btc-fee-estimates.json

Mainnet (neutrino is not supported on v0.7.1 yet, build with experimental flag from master)

bin/lnd \
  --bitcoin.active \
  --bitcoin.mainnet \
  --bitcoin.node=neutrino \
  --neutrino.connect=btcd-mainnet.lightning.computer \
  --neutrino.feeurl=https://nodes.lightning.computer/fees/v1/btc-fee-estimates.json \
  --neutrino.assertfilterheader=230000:1308d5cfc6462f877a5587fd77d7c1ab029d45e58d5175aaf8c264cee9bde760
  1. Create a new wallet, follow console instructions
bin/lncli --network=testnet create
  1. Copy credentials and certificate
mkdir data

# On Windows, Linux:
export LND_HOME=~/.lnd

# on Mac:
# export LND_HOME=~/Library/Application\ Support/Lnd

cp $LND_HOME/tls.cert ./data/
cp $LND_HOME/data/chain/bitcoin/testnet/admin.macaroon ./data/
  1. Copy rpc.proto from latest sources
wget https://github.com/lightningnetwork/lnd/blob/master/lnrpc/rpc.proto
mv rpc.proto ./data/

Comment this line or it won't work

// import "google/api/annotations.proto";
  1. Wait until lnd synces

Running

  1. Run nodejs script to operate your lnd node.
node lnd.js

IN DEVELOPMENT:

  1. Create invoice
node create-invoice.js
  1. Send QTUM
node send-qtum.js