From 550a6e520a3a1c74761a76d91a34c56009eef698 Mon Sep 17 00:00:00 2001 From: DhananjayPurohit Date: Mon, 29 Jul 2024 15:09:37 +0530 Subject: [PATCH] fix: wallet creation on start of lnd --- .github/workflows/tests.yml | 16 ---------------- docker-compose-test.yml | 38 ++++++++++++++++++++++++++++++++----- 2 files changed, 33 insertions(+), 21 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 431eaa7c..957947f0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -51,24 +51,8 @@ jobs: run: | container_id_alice=$(docker ps -qf "name=mercurylayer_alice_1") echo "Container ID: $container_id_alice" - docker exec $container_id_alice \ - curl -X POST http://0.0.0.0:8080/v1/initwallet \ - -H "Content-Type: application/json" \ - -d '{"wallet_password": "password", "stateless_init": "true"}' container_id_bob=$(docker ps -qf "name=mercurylayer_bob_1") echo "Container ID: $container_id_bob" - docker exec $container_id_bob \ - curl -X POST http://0.0.0.0:8080/v1/initwallet \ - -H "Content-Type: application/json" \ - -d '{"wallet_password": "password", "stateless_init": "true"}' - docker exec $container_id_alice \ - curl -X POST http://0.0.0.0:8080/v1/unlockwallet \ - -H "Content-Type: application/json" \ - -d '{"wallet_password": "password"}' - docker exec $container_id_bob \ - curl -X POST http://0.0.0.0:8080/v1/unlockwallet \ - -H "Content-Type: application/json" \ - -d '{"wallet_password": "password"}' docker exec $container_id_alice lncli -n regtest getinfo docker exec $container_id_bob lncli -n regtest getinfo docker logs $container_id_alice diff --git a/docker-compose-test.yml b/docker-compose-test.yml index 0099ccf8..674e32e0 100644 --- a/docker-compose-test.yml +++ b/docker-compose-test.yml @@ -11,9 +11,11 @@ services: bitcoind: image: lncm/bitcoind:v22.0@sha256:37a1adb29b3abc9f972f0d981f45e41e5fca2e22816a023faa9fdc0084aa4507 user: root - command: -regtest -rpcbind=0.0.0.0 -rpcallowip=0.0.0.0/0 -rpcauth=user:63cf03615adebaa9356591f95b07ec7b$$920588e53f94798bda636acac1b6a77e10e3ee7fe57e414d62f3ee9e580cd27a -fallbackfee=0.0001 + command: -regtest -rpcbind=0.0.0.0 -rpcallowip=0.0.0.0/0 -rpcauth=user:63cf03615adebaa9356591f95b07ec7b$$920588e53f94798bda636acac1b6a77e10e3ee7fe57e414d62f3ee9e580cd27a -fallbackfee=0.0001 -zmqpubhashblock=tcp://0.0.0.0:28332 -zmqpubhashtx=tcp://0.0.0.0:28333 ports: - "18443:18443" + - "28332:28332" + - "28333:28333" volumes: - bitcoin_data:/root/.bitcoin @@ -65,18 +67,30 @@ services: - postgres alice: - image: lightninglabs/lnd:v0.18.0-beta + image: lightninglabs/lndinit:v0.1.3-beta-lnd-v0.14.2-beta user: root hostname: lnd entrypoint: - sh - -c - | + if [[ ! -f /data/seed.txt ]]; then + lndinit gen-seed > /data/seed.txt + fi + if [[ ! -f /data/walletpassword.txt ]]; then + lndinit gen-password > /data/walletpassword.txt + fi + lndinit -v init-wallet \ + --secret-source=file \ + --file.seed=/data/seed.txt \ + --file.wallet-password=/data/walletpassword.txt \ + --init-file.output-wallet-dir=/root/.lnd/data/chain/bitcoin/regtest \ + --init-file.validate-password mkdir -p /data/.lnd if [ ! -f "/data/.lnd/umbrel-lnd.conf" ]; then touch "/data/.lnd/umbrel-lnd.conf" fi - lnd --listen=0.0.0.0:9735 --rpclisten=0.0.0.0:10009 --restlisten=0.0.0.0:8080 --bitcoin.active --bitcoin.regtest --bitcoin.node=bitcoind --bitcoind.rpchost=bitcoind --bitcoind.rpcuser=user --bitcoind.rpcpass=pass --bitcoind.zmqpubrawblock=tcp://bitcoind:28332 --bitcoind.zmqpubrawtx=tcp://bitcoind:28333 --configfile=/data/.lnd/umbrel-lnd.conf + lnd --listen=0.0.0.0:9735 --rpclisten=0.0.0.0:10009 --restlisten=0.0.0.0:8080 --bitcoin.active --bitcoin.regtest --bitcoin.node=bitcoind --bitcoind.rpchost=bitcoind --bitcoind.rpcuser=user --bitcoind.rpcpass=pass --bitcoind.zmqpubrawblock=tcp://bitcoind:28332 --bitcoind.zmqpubrawtx=tcp://bitcoind:28333 --configfile=/data/.lnd/umbrel-lnd.conf --wallet-unlock-password-file=/data/walletpassword.txt --wallet-unlock-allow-create=true ports: - "9735:9735" - "10009:10009" @@ -86,22 +100,35 @@ services: restart: unless-stopped environment: HOME: /data + command: [ '/init-wallet-k8s.sh' ] depends_on: - bitcoind bob: - image: lightninglabs/lnd:v0.18.0-beta + image: lightninglabs/lndinit:v0.1.3-beta-lnd-v0.14.2-beta user: root hostname: lnd entrypoint: - sh - -c - | + if [[ ! -f /data/seed.txt ]]; then + lndinit gen-seed > /data/seed.txt + fi + if [[ ! -f /data/walletpassword.txt ]]; then + lndinit gen-password > /data/walletpassword.txt + fi + lndinit -v init-wallet \ + --secret-source=file \ + --file.seed=/data/seed.txt \ + --file.wallet-password=/data/walletpassword.txt \ + --init-file.output-wallet-dir=/root/.lnd/data/chain/bitcoin/regtest \ + --init-file.validate-password mkdir -p /data/.lnd if [ ! -f "/data/.lnd/umbrel-lnd.conf" ]; then touch "/data/.lnd/umbrel-lnd.conf" fi - lnd --listen=0.0.0.0:9735 --rpclisten=0.0.0.0:10009 --restlisten=0.0.0.0:8080 --bitcoin.active --bitcoin.regtest --bitcoin.node=bitcoind --bitcoind.rpchost=bitcoind --bitcoind.rpcuser=user --bitcoind.rpcpass=pass --bitcoind.zmqpubrawblock=tcp://bitcoind:28332 --bitcoind.zmqpubrawtx=tcp://bitcoind:28333 --configfile=/data/.lnd/umbrel-lnd.conf + lnd --listen=0.0.0.0:9735 --rpclisten=0.0.0.0:10009 --restlisten=0.0.0.0:8080 --bitcoin.active --bitcoin.regtest --bitcoin.node=bitcoind --bitcoind.rpchost=bitcoind --bitcoind.rpcuser=user --bitcoind.rpcpass=pass --bitcoind.zmqpubrawblock=tcp://bitcoind:28332 --bitcoind.zmqpubrawtx=tcp://bitcoind:28333 --configfile=/data/.lnd/umbrel-lnd.conf --wallet-unlock-password-file=/data/walletpassword.txt --wallet-unlock-allow-create=true ports: - "9736:9735" - "10010:10009" @@ -111,6 +138,7 @@ services: restart: unless-stopped environment: HOME: /data + command: [ '/init-wallet-k8s.sh' ] depends_on: - bitcoind