diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9be129b..c486756 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,5 +7,7 @@ jobs: - uses: actions/checkout@v2 - name: Run tests run: | - chmod +x ./regtest - ./regtest + git clone https://github.com/lnbits/lnbits + docker build -t lnbits/lnbits lnbits + chmod +x ./start-regtest + ./start-regtest diff --git a/README.md b/README.md index 0514e7c..035436a 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,12 @@ -![TESTS](https://github.com/BoltzExchange/legend-regtest-enviroment/actions/workflows/ci.yml/badge.svg) +![TESTS](https://github.com/lnbits/legend-regtest-enviroment/actions/workflows/ci.yml/badge.svg) # nodes -* lnd-1: for locally testing +* lnd-1: for locally testing your current lnbits * lnd-2: used for boltz backend -* cln-1: for locally testing +* lnd-3: used for lnbits inside docker +* cln-1: for locally testing your current lnbits +* cln-2: used for clightning-REST +* eclair-1: for locally testing your current lnbits # Installing regtest get the regtest enviroment ready @@ -62,9 +65,6 @@ source docker-scripts.sh # use bitcoin core, mine a block bitcoin-cli-sim -generate 1 -# use elements, mine a liquid block -bitcoin-cli-sim -generate 1 - # use c-lightning nodes lightning-cli-sim 1 newaddr | jq -r '.bech32' # use node 1 lightning-cli-sim 2 getinfo # use node 2 @@ -78,6 +78,7 @@ lncli-sim 2 listpeers # urls * boltz api: http://localhost:9001/ * lnd-1 rest: http://localhost:8081/ +* lnbits: http://localhost:5001/ # debugging docker logs ```sh diff --git a/data/boltz/boltz.conf b/data/boltz/boltz.conf index 7aeae2e..1652513 100755 --- a/data/boltz/boltz.conf +++ b/data/boltz/boltz.conf @@ -46,21 +46,6 @@ minSwapAmount = 10_000 swapMaximal = 1050 swapTaproot = 300 -[[pairs]] -base = "RBTC" -quote = "BTC" -rate = 1 -fee = 0.5 - -maxSwapAmount = 4_294_967 -minSwapAmount = 10_000 - - [pairs.timeoutDelta] - reverse = 1440 - swapMinimal = 1000 - swapMaximal = 1050 - swapTaproot = 1440 - [[currencies]] symbol = "BTC" network = "bitcoinRegtest" @@ -98,18 +83,3 @@ maxZeroConfAmount = 40_294_967 cookie = "/root/.elements/liquid.cookie" zmqpubrawtx = "tcp://elementsd:31000" zmqpubhashblock = "tcp://elementsd:31002" - - -[rsk] -providerEndpoint = "http://anvil:8545" - -etherSwapAddress = "0x5fbdb2315678afecb367f032d93f642f64180aa3" -erc20SwapAddress = "0xe7f1725e7734ce288f8367e1bb143e90bb3f0512" - - [[rsk.tokens]] - symbol = "RBTC" - - maxSwapAmount = 4_294_96700 - minSwapAmount = 10000 - - minWalletBalance = 100_000_000 diff --git a/docker-compose.yml b/docker-compose.yml index de35273..fc7b9d4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,11 +6,9 @@ services: image: lnbits/lnbits restart: on-failure user: "0:0" - entrypoint: "sh -c 'sleep 30; poetry run lnbits'" environment: - HOST: lnbits - PORT: 5001 - DEBUG: true + LNBITS_HOST: lnbits + LNBITS_PORT: 5001 LNBITS_BACKEND_WALLET_CLASS: "LndRestWallet" LNBITS_DATA_FOLDER: "./data" LND_REST_ENDPOINT: "https://lnd-3:8081/" @@ -25,7 +23,7 @@ services: bitcoind: hostname: bitcoind restart: always - image: boltz/bitcoin-core:24.0.1 + image: boltz/bitcoin-core:27.1 command: - -regtest - -fallbackfee=0.00000253 @@ -34,6 +32,13 @@ services: - -txindex - -rpcallowip=0.0.0.0/0 - -rpcbind=0.0.0.0 + # eclair + # - -rpcuser=lnbits + # - -rpcpassword=lnbits + # - -dbcache=2048 + # - -rpcworkqueue=128 + # - -rpcclienttimeout=30 + expose: - 18444 ports: @@ -57,6 +62,8 @@ services: - 18884:18884 volumes: - ./data/elements/elements.conf:/home/elements/.elements/elements.conf + volumes_from: + - bitcoind:ro clightning-1: hostname: clightning-1 @@ -87,17 +94,28 @@ services: clightning-2: hostname: clightning-2 - restart: always depends_on: - bitcoind - image: boltz/c-lightning:22.11.1 - entrypoint: "sh -c 'sleep 15 && lightningd --large-channels --network regtest --grpc-port 9737 --bind-addr=0.0.0.0:9735 --bitcoin-rpcconnect=bitcoind --bitcoin-rpcport=18443 --bitcoin-rpcuser=lnbits --bitcoin-rpcpassword=lnbits'" + image: boltz/c-lightning:23.08.1 + command: + - --large-channels + - --network + - regtest + - --bind-addr=0.0.0.0:9735 + - --bitcoin-rpcconnect=bitcoind + - --bitcoin-rpcport=18443 + - --grpc-port=9736 + - --dev-bitcoind-poll=3 + - --dev-fast-gossip + - --experimental-offers + - --experimental-dual-fund expose: - 9735 - ports: - - 9737:9737 + - 9736 volumes: - ./data/clightning-2:/root/.lightning/ + volumes_from: + - bitcoind:ro clightning-2-rest: hostname: clightning-2-rest @@ -134,7 +152,7 @@ services: - 9735 - 9736 volumes: - - ./data/clightning-2:/root/.lightning/ + - ./data/clightning-3:/root/.lightning/ volumes_from: - bitcoind:ro @@ -161,9 +179,6 @@ services: - 8081 - 9735 - 10009 - ports: - - 8081:8081 - - 10009:10009 volumes: - ./data/lnd-1:/root/.lnd/ volumes_from: @@ -191,10 +206,11 @@ services: expose: - 8081 - 9735 - ports: - - 11009:10009 + - 10009 volumes: - ./data/lnd-2:/root/.lnd/ + volumes_from: + - bitcoind:ro lnd-3: hostname: lnd-3 @@ -202,31 +218,45 @@ services: - bitcoind image: boltz/lnd:0.17.4-beta restart: on-failure - entrypoint: "sh -c 'sleep 20; lnd --listen=lnd-3:9735 --rpclisten=lnd-3:10009 --restlisten=lnd-3:8081 --bitcoin.active --bitcoin.regtest --bitcoin.node=bitcoind --bitcoind.rpchost=bitcoind --bitcoind.zmqpubrawtx=bitcoind:29000 --bitcoind.zmqpubrawblock=bitcoind:29001 --bitcoind.rpcuser=lnbits --bitcoind.rpcpass=lnbits --noseedbackup --protocol.wumbo-channels'" - ports: - - 8081:8081 - - 10009:10009 + command: + - --listen=lnd-3:9735 + - --rpclisten=lnd-3:10009 + - --restlisten=lnd-3:8081 + - --bitcoin.active + - --bitcoin.regtest + - --bitcoin.node=bitcoind + - --bitcoind.rpchost=bitcoind + - --bitcoind.zmqpubrawtx=bitcoind:29000 + - --bitcoind.zmqpubrawblock=bitcoind:29001 + - --bitcoind.rpccookie=/root/.bitcoin/regtest/.cookie + - --noseedbackup + - --protocol.wumbo-channels expose: - 8081 - 9735 - 10009 + ports: + - 8081:8081 + - 10009:10009 volumes: - ./data/lnd-3:/root/.lnd/ + volumes_from: + - bitcoind:ro - eclair: - hostname: eclair - depends_on: - - bitcoind - image: boltz/eclair:0.8.0 - restart: on-failure - entrypoint: "sh -c 'JAVA_OPTS=-Xmx512m /eclair-node/bin/eclair-node.sh -Declair.datadir=/root/eclair -Declair.printToConsole'" - ports: - - 8082:8080 - expose: - - 9735 - - 8080 - volumes: - - ./data/eclair:/root/eclair + # eclair: + # hostname: eclair + # depends_on: + # - bitcoind + # image: boltz/eclair:0.8.0 + # restart: on-failure + # entrypoint: "sh -c 'JAVA_OPTS=-Xmx512m /eclair-node/bin/eclair-node.sh -Declair.datadir=/root/eclair -Declair.printToConsole'" + # ports: + # - 8082:8080 + # expose: + # - 9735 + # - 8080 + # volumes: + # - ./data/eclair:/root/eclair boltz: hostname: boltz @@ -325,5 +355,3 @@ services: volumes: lnbits-data: - volumes_from: - - bitcoind:ro diff --git a/docker-scripts.sh b/docker-scripts.sh index d560f07..7595ac0 100755 --- a/docker-scripts.sh +++ b/docker-scripts.sh @@ -120,9 +120,9 @@ regtest-start-log(){ regtest-stop(){ docker compose down --volumes # clean up lightning node data - sudo rm -rf ./data/clightning-1 ./data/clightning-2 ./data/lnd-1 ./data/lnd-2 ./data/boltz/boltz.db ./data/elements/liquidregtest ./data/bitcoin/regtest + sudo rm -rf ./data/clightning-1 ./data/clightning-2 ./data/clightning-3 ./data/lnd-1 ./data/lnd-2 ./data/lnd-3 ./data/boltz/boltz.db ./data/elements/liquidregtest ./data/bitcoin/regtest # recreate lightning node data folders preventing permission errors - mkdir ./data/clightning-1 ./data/clightning-2 ./data/lnd-1 ./data/lnd-2 + mkdir ./data/clightning-1 ./data/clightning-2 ./data/clightning-3 ./data/lnd-1 ./data/lnd-2 ./data/lnd-3 } regtest-restart(){ @@ -159,14 +159,18 @@ elements-init(){ } boltz-client-init(){ - boltzcli-sim wallet create lnbits LBTC + echo "boltz-client-init..." + # boltzcli-sim wallet create lnbits LBTC + # boltzcli-sim formatmacaroon } lightning-sync(){ wait-for-clightning-sync 1 wait-for-clightning-sync 2 + wait-for-clightning-sync 3 wait-for-lnd-sync 1 wait-for-lnd-sync 2 + wait-for-lnd-sync 3 } lightning-init(){ @@ -174,8 +178,10 @@ lightning-init(){ for i in 0 1 2; do fund_clightning_node 1 fund_clightning_node 2 + fund_clightning_node 3 fund_lnd_node 1 fund_lnd_node 2 + fund_lnd_node 3 done echo "mining 3 blocks..." @@ -246,24 +252,25 @@ lightning-init(){ bitcoin-cli-sim -generate $channel_confirms > /dev/null wait-for-lnd-channel 3 - # lnd-1 -> eclair-1 - lncli-sim 1 connect $(get-eclair-pubkey)@lnbits-eclair-1 > /dev/null - echo "open channel from lnd-2 to eclair-1" - lncli-sim 1 openchannel $(get-eclair-pubkey) $channel_size $balance_size > /dev/null - bitcoin-cli-sim -generate $channel_confirms > /dev/null - wait-for-lnd-channel 1 + # # lnd-1 -> eclair-1 + # lncli-sim 1 connect $(get-eclair-pubkey)@lnbits-eclair-1 > /dev/null + # echo "open channel from lnd-2 to eclair-1" + # lncli-sim 1 openchannel $(get-eclair-pubkey) $channel_size $balance_size > /dev/null + # bitcoin-cli-sim -generate $channel_confirms > /dev/null + # wait-for-lnd-channel 1 - # lnd-2 -> eclair-1 - lncli-sim 2 connect $(get-eclair-pubkey)@lnbits-eclair-1 > /dev/null - echo "open channel from lnd-2 to eclair-1" - lncli-sim 2 openchannel $(get-eclair-pubkey) $channel_size $balance_size > /dev/null - bitcoin-cli-sim -generate $channel_confirms > /dev/null - wait-for-lnd-channel 2 + # # lnd-2 -> eclair-1 + # lncli-sim 2 connect $(get-eclair-pubkey)@lnbits-eclair-1 > /dev/null + # echo "open channel from lnd-2 to eclair-1" + # lncli-sim 2 openchannel $(get-eclair-pubkey) $channel_size $balance_size > /dev/null + # bitcoin-cli-sim -generate $channel_confirms > /dev/null + # wait-for-lnd-channel 2 wait-for-clightning-channel 1 wait-for-clightning-channel 2 + wait-for-clightning-channel 3 - wait-for-eclair-channel + # wait-for-eclair-channel lightning-sync } diff --git a/regtest b/start-regtest similarity index 69% rename from regtest rename to start-regtest index 85c9aaa..acff56b 100755 --- a/regtest +++ b/start-regtest @@ -20,9 +20,8 @@ run(){ } failed="false" -blockheight=183 -channel_count=3 -utxos=5 +blockheight=201 +utxos=3 channel_size=24000000 # 0.024 btc balance_size=12000000 # 0.012 btc @@ -33,24 +32,35 @@ printf "\033[;1;36mregtest started! starting tests...\033[;0m\n" echo "==================================" echo "" - -for i in 1 2; do +for i in 1 2 3; do run "lnd-$i .synced_to_chain" "true" $(lncli-sim $i getinfo | jq -r ".synced_to_chain") run "lnd-$i utxo count" $utxos $(lncli-sim $i listunspent | jq -r ".utxos | length") run "lnd-$i .block_height" $blockheight $(lncli-sim $i getinfo | jq -r ".block_height") + if [[ "$i" == "1" ]]; then + channel_count=5 + fi + if [[ "$i" == "2" ]]; then + channel_count=2 + fi + if [[ "$i" == "3" ]]; then + channel_count=3 + fi run "lnd-$i openchannels" $channel_count $(lncli-sim $i listchannels | jq -r ".channels | length") run "lnd-$i .channels[0].capacity" $channel_size $(lncli-sim $i listchannels | jq -r ".channels[0].capacity") run "lnd-$i .channels[0].push_amount_sat" $balance_size $(lncli-sim $i listchannels | jq -r ".channels[0].push_amount_sat") done -for i in 1 2; do +for i in 1 2 3; do # run "cln-$i blockheight" $blockheight $(lightning-cli-sim $i getinfo | jq -r ".blockheight") run "cln-$i utxo count" $utxos $(lightning-cli-sim $i listfunds | jq -r ".outputs | length") run "cln-$i openchannels" 2 $(lightning-cli-sim $i getinfo | jq -r ".num_active_channels") run "cln-$i channel[0].state" "CHANNELD_NORMAL" $(lightning-cli-sim $i listfunds | jq -r ".channels[0].state") - run "cln-$i channel[0].amount_msat" $((channel_size * 1000)) $(lightning-cli-sim $i listfunds | jq -r ".channels[0].amount_msat") - run "cln-$i channel[0].our_amount_msat" $((balance_size * 1000)) $(lightning-cli-sim $i listfunds | jq -r ".channels[0].our_amount_msat") + run "cln-$i channel[0].amount_msat" $(($channel_size * 1000)) $(lightning-cli-sim $i listfunds | jq -r ".channels[0].amount_msat" | sed 's/msat//g') + run "cln-$i channel[0].our_amount_msat" $(($balance_size * 1000)) $(lightning-cli-sim $i listfunds | jq -r ".channels[0].our_amount_msat" | sed 's/msat//g') done +# run "eclair-1 openchannels" 2 $(docker exec lnbits-eclair-1 curl -s http://localhost:8080/channels -X POST -u :lnbits| jq '. | length') +# run "eclair-1 blockHeight" $blockheight $(docker exec lnbits-eclair-1 curl -s http://localhost:8080/getinfo -X POST -u :lnbits| jq '.blockHeight') +run "lnbits service status" "200" $(curl -s -o /dev/null -w "%{http_code}" "http://localhost:5001/") run "boltz service status" "200" $(curl -s -o /dev/null --head -w "%{http_code}" "http://localhost:9001/version") # return non-zero exit code if a test fails