Skip to content
Draft
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
10 changes: 8 additions & 2 deletions compose/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,16 @@ nano env/{namespace}/lnd.conf
```
If you were already running `robosats-deploy/compose` in another machine and need to recover, simply bring your existing environmental files from your backup.

In `/compose/env/compose...env` there is a variable named `SUFFIX` . This one is used to suffix all of your containers and configuration files. For example if you use `-tn` (for testnet), your bitcoind service will be called `btc-tn`, this is an effective way of creating namespaces. The example configuration in `/compose/env-sample/` uses the prefix `-lndtn`, for a LND testnet coordinator. This way, it is easy to run several coordinator orchestration in the same machine. For example, you can use the `-lndmn` prefix for a LND mainnet coordinator configuration or `-clntn` for a CLN Testnet configuration. You can also create alias shortcuts for each of your orchestration.
In `/compose/env/compose...env` there is a variable named `SUFFIX` . This one is used to suffix all of your containers and configuration files. For example if you use `-tn` (for testnet), your bitcoind service will be called `btc-tn`, this is an effective way of creating namespaces. The example configuration in `/compose/env-sample/` includes:
- `-lndtn` and `-clntn` for testnet3
- `-lndtn4` and `-clntn4` for testnet4
- `-lndmn` for mainnet
This way, it is easy to run several coordinator orchestrations on the same machine. You can also create alias shortcuts for each orchestration.

## Use aliases
Docker commands are lengthy. You can use aliases to make your task of operating a docker compose based robosats coordinator easier. Take a look at `/compose/aliases.sh` for some useful aliases and shortcuts.

## Example commands for a lnd testnet orchestration (-lndtn containers)
## Example commands for a lnd testnet3 orchestration (-lndtn containers)
If you install the aliases you can run the following shortcut commands:

```
Expand Down Expand Up @@ -130,6 +134,8 @@ Create p2wkh addresses

`tn-lncli newaddress p2wkh` (note without alias this command would be ``docker exec -it lnd-lndtn lncli --network=testnet newaddress p2wkh``)

For testnet4 orchestration samples (`lndtn4`/`clntn4`), use `--network=testnet4` in direct `lncli` commands.

Wallet balance

`tn-lncli walletbalance`
Expand Down
19 changes: 18 additions & 1 deletion compose/aliases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,21 @@ alias tn-manage="docker exec -it rs-lndtn python3 manage.py"
# POSTGRESS
# Example postgresql dump and restore. Unsafe!
alias tn-pg-restore='docker exec -i sql-lndtn /bin/bash -c "PGPASSWORD=robotest psql --username postgres postgres" < /home/$(whoami)/backup/testnet/database/backup.sql'
alias tn-pg-backup='docker exec -i sql-lndtn /bin/bash -c "PGPASSWORD=robotest pg_dump --username postgres postgres" > /home/$(whoami)/backup/testnet/database/backup.sql'
alias tn-pg-backup='docker exec -i sql-lndtn /bin/bash -c "PGPASSWORD=robotest pg_dump --username postgres postgres" > /home/$(whoami)/backup/testnet/database/backup.sql'

#################################################################################################################
## ROBOTEST4 Docker-Compose (same aliases as above, but for a testnet4 `lndtn4` orchestration)

alias tn4="docker compose -p lndtest4 --env-file /home/$(whoami)/robosats-deploy/compose/env/lndtn4/compose.env -f /home/$(whoami)/robosats-deploy/compose/docker-compose.yml -f /home/$(whoami)/robosats-deploy/compose/docker-compose.override-lnd.yml"

## Once ROBOTEST4 is up!
# ROBOTEST4 LNCLI COMANDS
alias tn4-lncli="docker exec -it lnd-lndtn4 lncli --network=testnet4"

# DJANGO MANAGE
alias tn4-manage="docker exec -it rs-lndtn4 python3 manage.py"

# POSTGRESS
# Example postgresql dump and restore. Unsafe!
alias tn4-pg-restore='docker exec -i sql-lndtn4 /bin/bash -c "PGPASSWORD=robotest psql --username postgres postgres" < /home/$(whoami)/backup/testnet4/database/backup.sql'
alias tn4-pg-backup='docker exec -i sql-lndtn4 /bin/bash -c "PGPASSWORD=robotest pg_dump --username postgres postgres" > /home/$(whoami)/backup/testnet4/database/backup.sql'
6 changes: 5 additions & 1 deletion compose/env-sample/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Example environment and configuration files
You can think of these as "Namespaces" for your orchestration.
You can find a LND Testnet example (lndtn) in `/compose/env-sample/lndtn` that will create containers suffixed with `-lndtn` and a CLN Testnet example in `/compose/env-sample/clntn` using the suffix `-clntn` .
You can find:
- a LND testnet3 example (`lndtn`) in `/compose/env-sample/lndtn` using suffix `-lndtn`
- a CLN testnet3 example (`clntn`) in `/compose/env-sample/clntn` using suffix `-clntn`
- a LND testnet4 example (`lndtn4`) in `/compose/env-sample/lndtn4` using suffix `-lndtn4`
- a CLN testnet4 example (`clntn4`) in `/compose/env-sample/clntn4` using suffix `-clntn4`
38 changes: 38 additions & 0 deletions compose/env-sample/clntn4/bitcoin.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Reference: https://en.bitcoin.it/wiki/Running_Bitcoin
# https://github.com/bitcoin/bitcoin/blob/master/share/examples/bitcoin.conf

server=1
txindex=1
onion=127.0.0.1:9050
torcontrol=127.0.0.1:9051
rpcuser=robosats_testnet4_bitcoind
rpcpassword=robosats_testnet4_bitcoind
zmqpubrawblock=tcp://127.0.0.1:18501
zmqpubrawtx=tcp://127.0.0.1:18502

# limit upload bandwith (in MB per day)
maxuploadtarget=10
# Allow RPC connections from outside of container localhost
rpcbind=0.0.0.0
# Only connect to typical docker IP addresses (Usually from docker host computer)
rpcallowip=172.0.0.0/255.0.0.0
# Allow access from any IP address (Usually from another computer on LAN)
#rpcallowip=0.0.0.0/0

# Run on the test network instead of the real bitcoin network.
testnet4=1

mempoolfullrbf=1

[main]
# Only run on Tor
onlynet=onion

# Add Tor seed nodes
addnode=i4x66albngo3sg3w.onion:8333

# Some testnet4 settings needed for 0.19, if using testnet4
[testnet4]
# Allow RPC connections from outside of container localhost
onlynet=onion
rpcbind=0.0.0.0
10 changes: 10 additions & 0 deletions compose/env-sample/clntn4/cln_config
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
network=testnet4
proxy=127.0.0.1:9050
bind-addr=127.0.0.1:9736
addr=statictor:127.0.0.1:9051
grpc-port=9999
grpc-hold-port=9998
always-use-proxy=true
important-plugin=/root/.lightning/plugins/cln-grpc-hold
# wallet=postgres://user:pass@localhost:5433/cln
# bookkeeper-db=postgres://user:pass@localhost:5433/cln
69 changes: 69 additions & 0 deletions compose/env-sample/clntn4/compose.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Uncomment the dockerhub tags to override the image versions localy without need to fork the docker-compose.yml

# ROBOSATS_TAG='v0.6.0-alpha@sha256:8cc975ff5942a3fb2a09827b8eaafebea1c851eb3ecf9be1aaac1f238cfa9fc1'
# BITCOIND_TAG='24.0.1-alpine@sha256:624b6fb1c282a3db6438ff35fbb9eed6ae260c66ffbb427ae72edd7da6a0ecdc'
# REDIS_TAG='7.2.1-alpine@sha256:7f5a0dfbf379db69dc78434091dce3220e251022e71dcdf36207928cbf9010de'
# NGINX_TAG='1.25.2-alpine-slim@sha256:1b0cb433e90260a96528c987ee78b797e842d510473935304a0931536d10f50d'
# POSTGRES_TAG='14.2-alpine@sha256:2fb5718f2a23dbac9bd1258e886eee90250a5903785e3136d62dd65e19f34982'

STATIC='/custom_path/testnet4/static'
DATABASE='/custom_path/testnet4/database'

# You can create a cronjob to create PG backups
PG_BACKUP='/custom_path/testnet4/pg_backup'
ROBOSATS_ENVS_FILE='env/clntn4/robosats.env'
THUB_ENVS_FILE='env/clntn4/thunderhub.env'
SUFFIX='-clntn4'
NETWORK='testnet4'

# Postgresql Database (Should match with those in robosats-tn.env)
POSTGRES_NAME='postgres'
POSTGRES_USER='postgres'
POSTGRES_PASSWORD='example'

BITCOIND_VERSION='24.0.1-alpine'

NGINX_CONFD='./nginx/tn.conf.d'
WELLKNOWN='./nginx/tn.well-known'

# Port and number of HTTP server workers for the robosats backend
WEB_LOCAL_PORT=8001
GUNICORN_WORKERS=2

BU_DIR1='/backup'
BU_DIR2='/custom_path/backup'
BU_DIR3='/custom_path/backup2'

BITCOIN_DATA='/custom_path/testnet4/bitcoin'
BITCOIN_CONF='./env/clntn4/bitcoin.conf'
CLN_DATA='/custom_path/testnet4/cln'
CLN_CONF='./env/clntn4/cln_config'
LIT_DATA='/custom_path/testnet4/lit'

GUEST_BITCOIN=/home/bitcoin/.bitcoin

TOR_DATA='./env/lndtn4/tor'
TOR_CONFIG='./env/lndtn4/torrc'

GUEST_LND_RPC_PORT=10009
GUEST_LND_REST_PORT=8080

HOST_LND_RPC_PORT=10009
HOST_LND_REST_PORT=8080

THUB_LOCAL_PORT=3001
THUB_ACCOUNTS='./env/clntn4/thunderhub-accounts.yml'
# THUB_ACCOUNTS_CONFIG_PATH must match thub...env
THUB_ACCOUNTS_CONFIG_PATH='/config/accounts.yml'




LIT_LOCAL_PORT=4001
LIT_PASSWORD=999999999

LND_BACKUP_PATH='/custom_path/testnet4/lnd-backup'
NODE_ALIAS='🤖RoboSats⚡(Testnet4)'
NODE_COLOR='#4126a7'

LND_AUTOUNLOCK_PWD='./env/clntn4/lnd_autounlock_pwd'
183 changes: 183 additions & 0 deletions compose/env-sample/clntn4/robosats.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
# Coordinator Alias (Same as longAlias)
COORDINATOR_ALIAS="coordinator_NAME_CLN"
# Lightning node vendor: CLN | LND
LNVENDOR='CLN'

# LND configuration (only needed if LNVENDOR='LND')
# LND directory to read TLS cert and macaroon
#LND_DIR='/lnd/'
#MACAROON_PATH='data/chain/bitcoin/testnet4/admin.macaroon'

# If LND directory is not specified, cert and macaroon can be provided as base64 strings
# base64 ~/.lnd/tls.cert | tr -d '\n'
#LND_CERT_BASE64='LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNLVENDQWRDZ0F3SUJBZ0lRQ0VoeGpPZXY1bGQyVFNPTXhKalFvekFLQmdncWhrak9QUVFEQWpBNE1SOHcKSFFZRFZRUUtFeFpzYm1RZ1lYVjBiMmRsYm1WeVlYUmxaQ0JqWlhKME1SVXdFd1lEVlFRREV3d3dNakJtTVRnMQpZelkwTnpVd0hoY05Nakl3TWpBNE1UWXhOalV3V2hjTk1qTXdOREExTVRZeE5qVXdXakE0TVI4d0hRWURWUVFLCkV4WnNibVFnWVhWMGIyZGxibVZ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VhZBIFd3JpdGUaFgoHb25jaGFpbhIEcmVhZBIFd3JpdGUaFAoFcGVlcnMSBHJlYWQSBXdyaXRlGhgKBnNpZ25lchIIZ2VuZXJhdGUSBHJlYWQAAAYgMt90uD6v4truTadWCjlppoeJ4hZrL1SBb09Y+4WOiI0='

# CLN directory (only needed if LNVENDOR='CLN')
CLN_DIR='/cln/testnet4/'
CLN_GRPC_HOST='localhost:9999'
CLN_GRPC_HOLD_HOST='localhost:9998'

# Bitcoin Core Daemon RPC, used to validate addresses
BITCOIND_RPCURL = 'http://127.0.0.1:48332'
BITCOIND_RPCUSER = 'robosats_testnet4_bitcoind'
BITCOIND_RPCPASSWORD = 'robosats_testnet4_bitcoind'

# Auto unlock LND password. Only used in development docker-compose environment.
# It will fail starting up the node without it.
# To disable auto unlock, comment out 'wallet-unlock-password-file=/tmp/pwd' from 'docker/lnd/lnd.conf'
LND_GRPC_HOST='localhost:10009'

REDIS_URL='redis://localhost:6379/1'

# Postgresql Database (These are fed from STACK-XX.env)
# Deprecated
POSTGRES_NAME='postgres'
# New
POSTGRES_DB='postgres'
POSTGRES_USER='postgres'
POSTGRES_PASSWORD='example'
POSTGRES_HOST='127.0.0.1'
POSTGRES_PORT='5432'

# Tor proxy for remote calls (e.g. fetching prices or sending Telegram messages)
USE_TOR='True'
TOR_PROXY='127.0.0.1:9050'

# Local nostr relay
STRFRY_HOST = 'localhost'
STRFRY_PORT = '7778'

# List of market price public APIs. If the currency is available in more than 1 API, will use median price.
MARKET_PRICE_APIS = 'https://blockchain.info/ticker, https://api.yadio.io/exrates/BTC'

# Host e.g. 'robotesta15gf7845r4rgksb4nmmr43fh77bzn2ia2eucduyeafnyd.onion'
HOST_NAME = 'robotestagw3dcxmd66r4rgksb4nmmr43fh77bzn2ia2eucduyeafnyd.onion'
HOST_NAME2 = '*' # Do not change
I2P_ALIAS = ''
I2P_LONG = ''
LOCAL_ALIAS = ''
ONION_LOCATION = 'robotestagw3dcxmd66r4rgksb4nmmr43fh77bzn2ia2eucduyeafnyd.onion'

# Geoblocked countries (will reject F2F trades).
# List of A3 country codes (see fhttps://en.wikipedia.org/wiki/ISO_3166-1_alpha-3)
# Leave empty '' to allow all countries.
# Example 'NOR,USA,CZE'.
GEOBLOCKED_COUNTRIES = 'ABW,AFG,AGO'

# Link to robosats alternative site (shown in frontend in statsfornerds so users can switch mainnet/testnet4)
ALTERNATIVE_SITE = 'RoboSats6tkf3eva7x2voqso3a5wcorsnw34jveyxfqi2fu7oyheasid.onion'
ALTERNATIVE_NAME = 'RoboSats Mainnet'

SECRET_KEY= 'n098eafh82390fu9283uyt9yf023uf'

# Link to robosats mainnet/testnet4 (shown on frontend in statsfornerds so users can switch mainnet/testnet4)
THE_OTHER_ROBOSATS = 'robosats6tkf3eva7x2voqso3a5wcorsnw34jveyxfqi2fu7oyheasid.onion'

# Telegram bot token
TELEGRAM_TOKEN = ''
TELEGRAM_BOT_NAME = ''
# Telegram chat id to receive admin notifications
TELEGRAM_COORDINATOR_CHAT_ID = 'AdminNotificationChatId'
# Notify new messages in-chat app (fiat exchange step) if at least X minutes has passed since the last chat message.
CHAT_NOTIFICATION_TIMEGAP = 5

# Maintainance notice or and other coordinator messages on client start
# Style of the notice on the client app, use None for no notice: 'None' | 'Warning' | 'Success' | 'Error' | 'Info'
NOTICE_SEVERITY = 'info'
NOTICE_MESSAGE = 'This is a coordinator message with <a href="http://duck.com">LINK</a>'

# Lightning node open info, url to amboss and 1ML
NETWORK = 'testnet4'
NODE_ALIAS = '🤖RoboSats⚡(Coordinator_NAME)'
NODE_ID = '028.....'

# Total trade fee as fraction
FEE = 0.002
# Maker/taker fee split. As seen in https://bisq.wiki/Trading_fees . It is implicit that TAKER_FEE_SPLIT = (1 - MAKER_FEE_SPLIT)
# Shall incentivize order making
MAKER_FEE_SPLIT=0.125

# Time out penalty for canceling takers in SECONDS
PENALTY_TIMEOUT = 60
# Time between routing attempts of buyer invoice in MINUTES
RETRY_TIME = 1

# Store Order Logs in DB. Verbose logging for each order as property of the order object in DB. Useful for debugging and for learning
# the order flow for new robosats coordinators (prints a pretty timestamped table on the coordinator panel on each order). But a bit heavy
# on write operations and can potentially affect performance for every request.
DISABLE_ORDER_LOGS = False

# Robosats Development Fund donation as fraction. 0.2 = 20% of successful orders proceeds are donated via keysend.
# Donations to the devfund are important for the sustainabilty of the project, however, these are totally optional (you
# can run a coordinator without donating devfund!). Coordinators with higher devfund donations % will be more prominently
# displayed (and have special badges), while coordinators that do not donate might eventually lose frontend/client support.
# Leaving the default value (20%) will grant the DevFund contributor badge.
DEVFUND = 0.2

# Coordinator activity limits
MAX_PUBLIC_ORDERS = 100

# Trade limits in satoshis
MIN_TRADE = 20000
MAX_TRADE = 5000000

# For CLTV_expiry calculation
# Assume 8 min/block assumed
BLOCK_TIME = 8
# Safety multiplier in case of mining speed up (CLTV expiry will be times X larger than real time needs for locked bonds/escrow)
MAX_MINING_NETWORK_SPEEDUP_EXPECTED = 1.7

# Expiration time for locking collateral in SECONDS
EXP_MAKER_BOND_INVOICE = 300
EXP_TAKER_BOND_INVOICE = 200

# ROUTING
# Proportional routing fee limit (fraction of total payout: % / 100)
PROPORTIONAL_ROUTING_FEE_LIMIT = 0.001
# Base flat limit fee for routing in Sats (used only when proportional is lower than this)
MIN_FLAT_ROUTING_FEE_LIMIT_REWARD = 2
# Routing timeouts
REWARDS_TIMEOUT_SECONDS = 30
PAYOUT_TIMEOUT_SECONDS = 90
DEBUG_PERMISSIONED_PAYOUTS = False

# Allow self keysend on keysend function (set true to debug keysend functionality)
ALLOW_SELF_KEYSEND = False

# REVERSE SUBMARINE SWAP PAYOUTS
# Disable on-the-fly swaps feature
DISABLE_ONCHAIN = False
# Shape of fee to available liquidity curve. Either "linear" or "exponential"
SWAP_FEE_SHAPE = 'exponential'
# EXPONENTIAL. fee (%) = MIN_SWAP_FEE + (MAX_SWAP_FEE - MIN_SWAP_FEE) * e ^ (-LAMBDA * onchain_liquidity_fraction)
SWAP_LAMBDA = 8.8
# LINEAR. 4 parameters needed: min/max fees and min/max balance points. E.g. If 25% or more of liquidity
# is onchain the fee for swap is 2% (minimum), if it is 12% fee is 6%, and for 0% fee is 10%.
# Minimum swap fee as fraction (1%)
MIN_SWAP_FEE = 0.008
# Liquidity split point (LN/onchain) at which we use MIN_SWAP_FEE
MIN_SWAP_POINT = 0.35
# Maximum swap fee as fraction (~10%)
MAX_SWAP_FEE = 0.1
# Liquidity split point (LN/onchain) at which we use MAX_SWAP_FEE
MAX_SWAP_POINT = 0
# Min and Max amount allowed for Swap
MIN_SWAP_AMOUNT = 10000
MAX_SWAP_AMOUNT = 1000000
# Spend Unconfirmed UTXOS (more capital efficient, more risky)
SPEND_UNCONFIRMED = False
# Mining fee confirmation target
SUGGESTED_TARGET_CONF = 4
MINIMUM_TARGET_CONF = 24

# Fraction rewarded to user from the slashed bond of a counterpart.
# It should not be close to 1, or could be exploited by an attacker trading with himself to DDOS the LN node.
SLASHED_BOND_REWARD_SPLIT = 0.5

# Username for HTLCs escrows
ESCROW_USERNAME = 'admin'

#Social
NOSTR_NSEC = 'nsec1vxhs2zc4kqe0dhz4z2gfrdyjsrwf8pg3neeqx6w4nl8djfzdp0dqwd6rxh'
Empty file.
12 changes: 12 additions & 0 deletions compose/env-sample/clntn4/torrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Log notice file /var/log/tor/notices.log

## The directory for keeping all the keys/etc. By default, we store
## things in $HOME/.tor on Unix, and in Application Data\tor on Windows.
DataDirectory /var/lib/tor
DataDirectoryGroupReadable 1

## Enable ControlPort
ControlPort 9051
CookieAuthentication 1
CookieAuthFileGroupReadable 1
CookieAuthFile /var/lib/tor/control_auth_cookie
Loading