Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# lightning.space API

API for lightning.space custodial service

Do not merge this state into PRD!
17 changes: 15 additions & 2 deletions infrastructure/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@
1. Execute script: `sudo ./setupDocker.sh`
1. Copy script `infrastructure/scripts/setupEnv.sh` to virtual machine `~/setupEnv.sh`
1. Execute script: `./setupEnv.sh`
1. Copy script `infrastructure/scripts/{env}-docker-compose.sh` to virtual machine `~/docker-compose.sh`
1. Copy file `infrastructure/config/docker/{env}-docker-compose.yml` to virtual machine `~/docker-compose.yml`
1. Create docker network `docker network create lightning-network`
1. Copy script `infrastructure/scripts/docker-compose.sh` to virtual machine `~/docker-compose.sh`
1. Copy file `infrastructure/config/docker/{env}-docker-compose-lightning.yml` to virtual machine `~/docker-compose-lightning.yml`
1. Copy file `infrastructure/config/docker/{env}-docker-compose-nginx.yml` to virtual machine `~/docker-compose-nginx.yml`
1. Copy file `infrastructure/config/docker/{env}-docker-compose-boltz.yml` to virtual machine `~/docker-compose-boltz.yml`
1. Execute Docker Compose (see [below](#docker-compose)) after all other setup steps are done:
1. [Bitcoin Node Setup](#bitcoin-node-setup-bitcoind)
1. [Lightning Node Setup](#lightning-node-setup-lnd)
1. [Taproot Setup](#taproot-setup-tapd)
1. [LNbits Setup](#lnbits-setup)
1. [ThunderHub Setup](#thunderhub-setup)
1. [NGINX Setup](#nginx-setup)
1. [Boltz Setup](#boltz-setup)

# Bitcoin Node Setup (bitcoind)

Expand Down Expand Up @@ -59,6 +63,15 @@

1. Copy content of config file `infrastructure/config/nginx/{env}-default.conf` to virtual machine `~/volumes/nginx/default.conf`

# Boltz Setup

1. Copy content of config file `infrastructure/config/boltz/backend/{env}-boltz.conf` to virtual machine `~/volumes/boltz/backend/boltz.conf`
1. `boltz.conf`: Replace
1. `[POSTGRES_DATABASE]` / `[POSTGRES_USERNAME]` / `[POSTGRES_PASSWORD]`
1. `[RPC_USER]` / `[RPC_PASSWORD]`
1. `[WALLET_NAME]`
1. `[PROVIDER_ENDPOINT]`

# Docker Compose

The complete Bitcoin Blockchain data is loaded after the very first startup of the bitcoin node. Therefore it is recommended to copy already available blockchain data to the `~/volumes/bitcoin/...` directory.
Expand Down
12 changes: 5 additions & 7 deletions infrastructure/config/bitcoin/dev-bitcoin.conf
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
testnet=1
server=1
rest=1
txindex=1

rpcallowip=0.0.0.0/0
rpcbind=0.0.0.0
rpcport=8332
rpcauth=[RPC-AUTH]

zmqpubrawblock=tcp://0.0.0.0:28332
zmqpubrawtx=tcp://0.0.0.0:28333

[test]
wallet=[WALLET]
addresstype=p2sh-segwit

rpcbind=0.0.0.0
rpcport=18332
zmqpubrawblock=tcp://0.0.0.0:28332
zmqpubrawtx=tcp://0.0.0.0:28333
1 change: 1 addition & 0 deletions infrastructure/config/bitcoin/prd-bitcoin.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
server=1
rest=1
txindex=1

rpcallowip=0.0.0.0/0
rpcbind=0.0.0.0
Expand Down
250 changes: 250 additions & 0 deletions infrastructure/config/boltz/backend/dev-boltz.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,250 @@
# Boltz Backend Configuration - Mainnet
# Integration with existing Lightning.space infrastructure

# Network Configuration - MUST be at top level before any sections!
network = "mainnet"

loglevel = "debug"

[api]
host = "0.0.0.0"
port = 9001
allowedCors = ["*"]

[grpc]
host = "0.0.0.0"
port = 9000

# Sidecar Configuration (Rust component)
[sidecar]
[sidecar.grpc]
host = "0.0.0.0"
port = 9003
certificates = "/root/.boltz/sidecar/certificates"

[sidecar.ws]
host = "0.0.0.0"
port = 9004

[sidecar.api]
host = "0.0.0.0"
port = 9005

# PostgreSQL Database
[postgres]
host = "postgres"
port = 5432
database = "[POSTGRES_DATABASE]"
username = "[POSTGRES_USERNAME]"
password = "[POSTGRES_PASSWORD]"

# Redis Cache (optional but recommended)
[cache]
redisEndpoint = "redis://redis:6379"

[swap]
deferredClaimSymbols = ["cBTC"]

# Bitcoin/Lightning Configuration
[[currencies]]
symbol = "BTC"
network = "bitcoinMainnet"

# Wallet balances - adjusted for testing
minWalletBalance = 100_000 # 0.001 BTC (100k sats)
minChannelBalance = 100_000 # 0.001 BTC (100k sats)

# Swap limits
maxSwapAmount = 10_000_000 # 0.1 BTC maximum
minSwapAmount = 2_500 # 2,500 sats minimum (currency level - for all BTC swaps)
maxZeroConfAmount = 0 # Disable 0-conf for security

# Bitcoin Core Configuration
[currencies.chain]
host = "bitcoind"
port = 8332

# RPC Authentication
user = "[RPC_USER]"
password = "[RPC_PASSWORD]"

# ZMQ endpoints for blockchain notifications
zmqpubrawtx = "tcp://bitcoind:28333"
zmqpubrawblock = "tcp://bitcoind:28332"

# Bitcoin wallet name
wallet = "[WALLET_NAME]"

# LND Configuration
[currencies.lnd]
host = "lnd"
port = 10009 # gRPC port (not REST 8080!)

# Credentials - mounted from Docker volumes
certpath = "/root/.lnd/tls.cert"
macaroonpath = "/root/.lnd/data/chain/bitcoin/mainnet/admin.macaroon"

# Swap Pair Configuration: BTC/BTC (Lightning <-> OnChain)
[[pairs]]
base = "BTC"
quote = "BTC"
rate = 1
fee = 0.5 # 0.5% service fee
swapInFee = 0.25 # 0.25% for submarine swaps (chain -> lightning)

# Swap amount limits (in satoshis)
maxSwapAmount = 10_000_000 # 0.1 BTC
minSwapAmount = 2_500 # 2,500 sats (pair level)

# Submarine Swap specific settings (Chain -> Lightning)
[pairs.submarineSwap]
minSwapAmount = 10_000 # Minimum for submarine swaps (needs high limit due to on-chain fees)

# Reverse Swap specific settings (Lightning -> Chain)
[pairs.reverseSwap]
minSwapAmount = 2_500 # Minimum for reverse swaps (lower fees, no input tx)

# Timeout configuration (in minutes!)
[pairs.timeoutDelta]
chain = 1440 # Chain swap timeout (~24 hours = 144 blocks)
reverse = 1440 # ~24 hours for reverse swaps (lightning -> chain)
swapMinimal = 1440 # Minimum timeout for submarine swaps (~24 hours = 144 blocks)
swapMaximal = 2880 # Maximum timeout (~48 hours = 288 blocks)
swapTaproot = 10080 # 1 week for taproot swaps (10080 blocks)

# Swap Pair Configuration: BTC/RBTC (Lightning BTC <-> RSK RBTC)
[[pairs]]
base = "BTC"
quote = "RBTC"
rate = 1
fee = 0.25
swapInFee = 0.1

# Swap amount limits (in satoshis)
maxSwapAmount = 10_000_000 # 0.1 BTC/RBTC
minSwapAmount = 2_500 # 2,500 sats minimum (Rootstock has lower fees)

[pairs.timeoutDelta]
chain = 1440 # Chain swap timeout (~24 hours = 144 blocks)
reverse = 1440 # ~24 hours for reverse swaps (lightning -> chain)
swapMinimal = 1440 # Minimum timeout for submarine swaps (~24 hours = 144 blocks)
swapMaximal = 2880 # Maximum timeout (~48 hours = 288 blocks)
swapTaproot = 10080 # 1 week for taproot swaps (10080 blocks)

[[pairs]]
base = "BTC"
quote = "cBTC"
rate = 1
fee = 0.25
swapInFee = 0.1

maxSwapAmount = 10_000_000 # 0.1 BTC/cBTC
minSwapAmount = 2_500 # 2,500 sats minimum (Citrea Testnet has low fees)

[pairs.timeoutDelta]
chain = 60 # Chain swap timeout (~1 hour, due to fast 2s blocks)
reverse = 180 # Reverse swap timeout (Lightning -> cBTC) - increased for CLTV requirements
swapMinimal = 1440 # Minimum timeout (~13.3 hours) - minimum for Lightning CLTV (80 blocks × 10 min)
swapMaximal = 2880 # Maximum timeout (~16.7 hours) - allows 100 Bitcoin blocks CLTV
swapTaproot = 10080 # Taproot timeout (~16.7 hours)

[[pairs]]
base = "USDT_ETH"
quote = "USDT_CITREA"
rate = 1
fee = 0.25
swapInFee = 0.1

maxSwapAmount = 1_000_000_000 # 1000 USDT_ETH/USDT_CITREA
minSwapAmount = 1_000_000 # 1 USDT_ETH/USDT_CITREA

[pairs.timeoutDelta]
chain = 1440 # Chain swap timeout (~24 hours = 144 blocks)
reverse = 1440 # ~24 hours for reverse swaps (lightning -> chain)
swapMinimal = 1440 # Minimum timeout for submarine swaps (~24 hours = 144 blocks)
swapMaximal = 2880 # Maximum timeout (~48 hours = 288 blocks)
swapTaproot = 10080 # 1 week for taproot swaps (10080 blocks)

[[pairs]]
base = "USDT_POLYGON"
quote = "USDT_CITREA"
rate = 1
fee = 0.25
swapInFee = 0.1

maxSwapAmount = 1_000_000_000 # 1000 USDT_POLYGON/USDT_CITREA
minSwapAmount = 1_000_000 # 1 USDT_POLYGON/USDT_CITREA

[pairs.timeoutDelta]
chain = 1440 # Chain swap timeout (~24 hours = 144 blocks)
reverse = 1440 # ~24 hours for reverse swaps (lightning -> chain)
swapMinimal = 1440 # Minimum timeout for submarine swaps (~24 hours = 144 blocks)
swapMaximal = 2880 # Maximum timeout (~48 hours = 288 blocks)
swapTaproot = 10080 # 1 week for taproot swaps (10080 blocks)

# RSK (Rootstock) Configuration
[rsk]
networkName = "RSK Mainnet"
providerEndpoint = "[PROVIDER_ENDPOINT]"

[[rsk.contracts]]
etherSwap = "0x3d9cc5780CA1db78760ad3D35458509178A85A4A"
erc20Swap = "0x7d5a2187CC8EF75f8822daB0E8C9a2DB147BA045"

[[rsk.tokens]]
symbol = "RBTC"

minWalletBalance = 10_000

# ETH (Ethereum) Configuration
[ethereum]
networkName = "Ethereum Mainnet"
providerEndpoint = "[PROVIDER_ENDPOINT]"

[[ethereum.contracts]]
etherSwap = "0x9ADfB0F1B783486289Fc23f3A3Ad2927cebb17e4"
erc20Swap = "0x2E21F58Da58c391F110467c7484EdfA849C1CB9B"

[[ethereum.tokens]]
symbol = "USDT_ETH"
decimals = 6
contractAddress = "0xdAC17F958D2ee523a2206206994597C13D831ec7"

minWalletBalance = 1_000_000 # 1 USDT_ETH

# POL (Polygon) Configuration
[polygon]
networkName = "Polygon Mainnet"
providerEndpoint = "[PROVIDER_ENDPOINT]"

[[polygon.contracts]]
etherSwap = "0x9ADfB0F1B783486289Fc23f3A3Ad2927cebb17e4"
erc20Swap = "0x2E21F58Da58c391F110467c7484EdfA849C1CB9B"

[[polygon.tokens]]
symbol = "USDT_POLYGON"
decimals = 6
contractAddress = "0xc2132D05D31c914a87C6611C10748AEb04B58e8F"

minWalletBalance = 1_000_000 # 1 USDT_POLYGON

# Citrea Testnet Configuration
[citrea]
networkName = "Citrea Testnet"
providerEndpoint = "https://dev.rpc.testnet.juiceswap.com"

[[citrea.contracts]]
etherSwap = "0xd02731fD8c5FDD53B613A699234FAd5EE8851B65"
erc20Swap = "0xf2e019a371e5Fd32dB2fC564Ad9eAE9E433133cc"

[[citrea.tokens]]
symbol = "cBTC"

minWalletBalance = 100_000

[[citrea.tokens]]
symbol = "USDT_CITREA"
decimals = 6
contractAddress = "0x1Dd3057888944ff1f914626aB4BD47Dc8b6285Fe"

minWalletBalance = 1_000_000 # 1 USDT_CITREA
Loading