3⃣
Deploy Backend

Backend App

LN-STX Bridge has very few requirements and can be installed by running below commands as detailed in the github repository readme.
1
// ensure you have node-14 installed
2
​
3
// clone the repo, install requirements and compile
4
git clone https://github.com/pseudozach/lnstxbridge.git
5
cd lnstxbridge && npm i && npm run compile
Copied!
Note that in order to start the app and serve swaps, there are still many requirements like opening Lightning channels from your node and funding the swap provider signer account with STX and BTC funds.

Contracts

Each bridge instance should run its own swap contracts for both transparency purposes and to make it easy for the bridge backend to track the swaps.
Easiest way to deploy the swap contracts is to launch explorer sandbox, copy/paste contents of the latest version of the contracts and click deploy!

Signer Account

As a swap provider, lnstxbridge will need access to private keys for a stacks account that has STX (and any other SIP10 you plan to serve).
Generate a new stacks account using any available method (hiro wallet or stx cli) send STX funds into this account and place the mnemonic seed of this account on the server at ~/.lnstx/seed.dat

Configuration

Once the app is ready and contracts are deployed, it's time to build the configuration file that feeds this data to the app.
Data in this file is mostly personal choice and depend on operator's environment. Feel free to join #developers channel in our discord and ask if anything is unclear.
1
vim ~/.lnstx/boltz.conf
2
​
3
# required if you want to enable sponsored transactions
4
prepayMinerFee=true
5
​
6
# Backend supports sending messages to Discord after successful and failed
7
# Swaps and if the wallet or channel balance is underneath a configurable threshold
8
# 1. create a bot at https://discord.com/developers/applications
9
# 2. add the bot to any private channel in your discord server
10
# 3. give bot sendmessage access and copy/paste token here
11
[notification]
12
token = ""
13
channel = "secret-lnswapbot-channel"
14
prefix = "lns"
15
# Interval in minutes at which the wallet and channel balances should be checked
16
interval = 10
17
# Some Discord commands (like withdraw) require a TOTP token
18
# This is the path to the secret of that TOTP token
19
otpsecretpath = "/home/workspace/.lnstx/otpSecret.dat"
20
​
21
# Backend supports balancing account funds via centralized exchange (currently OKCoin)
22
# Both automated and on-demand balancing is supported
23
[balancer]
24
apiUri = "https://www.okcoin.com"
25
apiKey = ""
26
secretKey = ""
27
passphrase = ""
28
tradePassword = ""
29
minSTX = 10
30
minBTC = 1000000
31
overshootPercentage = 0
32
autoBalance = false
33
​
34
[dashboard]
35
username = "admin"
36
password = "admin"
37
​
38
[[pairs]]
39
base = "BTC"
40
quote = "STX"
41
fee = 5
42
timeoutDelta = 1_240
43
​
44
# if you do not want to serve USDA sip10 token swaps, you can delete this pair
45
[[pairs]]
46
base = "BTC"
47
quote = "USDA"
48
fee = 5
49
timeoutDelta = 1_240
50
​
51
[[currencies]]
52
symbol = "BTC"
53
network = "bitcoinRegtest"
54
minWalletBalance = 10_000_000
55
minChannelBalance = 10_000_000
56
maxSwapAmount = 4_294_967
57
minSwapAmount = 10_000
58
maxZeroConfAmount = 10_000_000
59
​
60
[currencies.chain]
61
host = "127.0.0.1"
62
port = 18_443
63
cookie = "docker/regtest/data/core/cookies/.bitcoin-cookie"
64
rpcuser = "kek"
65
rpcpass = "kek"
66
​
67
[currencies.lnd]
68
host = "127.0.0.1"
69
port = 10_009
70
certpath = "docker/regtest/data/lnd/certificates/tls.cert"
71
macaroonpath = "docker/regtest/data/lnd/macaroons/admin.macaroon"
72
​
73
[stacks]
74
providerEndpoint = "http://localhost:3999"
75
# you need to replace these contract addresses
76
# with the ones you have deployed in the previous step.
77
stxSwapAddress = "ST30VXWG00R13WK8RDXBSTHXNWGNKCAQTRYEMA9FK.stxswap_v8"
78
sip10SwapAddress = "ST30VXWG00R13WK8RDXBSTHXNWGNKCAQTRYEMA9FK.sip10swap_v1"
79
​
80
[[stacks.tokens]]
81
symbol = "STX"
82
maxSwapAmount = 1_294_967000
83
minSwapAmount = 10000
84
​
85
# if you are serving another SIP10 token you can replace/add below lines
86
[[stacks.tokens]]
87
symbol = "USDA"
88
​
89
maxSwapAmount = 1_294_967000
90
minSwapAmount = 10000
91
contractAddress = "SP2C2YFP12AJZB4MABJBAJ55XECVS7E4PMMZ89YZR.usda-token"
92
decimals = 6
Copied!

Ready to Launch!

Now that you've prepared all the requirements you can deploy your backend!
1
cd lnstxbridge
2
npm run start
Copied!
It's suggested to use process managers like pm2 because there can be many reasons your server might crash, restart and you should always try to ensure high uptime for your bridge.
You can also use an online monitoring tool like cronitor or uptime-kuma to receive alerts if your instance goes down.