From 604c0acf26a8319b3d908c7b3a1a0c5fd8dca7d3 Mon Sep 17 00:00:00 2001
From: DhananjayPurohit <dhananjaypurohit7@gmail.com>
Date: Wed, 31 Jul 2024 13:44:16 +0530
Subject: [PATCH] feat: add script to open channel

---
 .github/workflows/tests.yml | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 0754f546..0609892e 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -58,11 +58,17 @@ jobs:
           echo "Container ID: $container_id_bob"
           docker logs $container_id_alice
           docker logs $container_id_bob
-          identity_pubkey=$(docker exec $container_id_bob lncli -n regtest getinfo | jq -r '.identity_pubkey')
-          echo "Pubkey: $identity_pubkey"
-          docker exec $container_id_alice lncli -n regtest connect $identity_pubkey@bob:9736
+          identity_pubkey_bob=$(docker exec $container_id_bob lncli -n regtest getinfo | jq -r '.identity_pubkey')
+          echo "Pubkey: $identity_pubkey_bob"
+          docker exec $container_id_alice lncli -n regtest connect $identity_pubkey_bob@bob:9735
           docker exec $container_id_alice lncli -n regtest listpeers
-          docker exec $container_id_bob lncli -n regtest getinfo
+          address=$(docker exec $container_id_bob lncli -n regtest newaddress p2wkh | jq -r '.address')
+          container_id_bitcoind=$(docker ps -qf "name=mercurylayer_bitcoind_1")
+          docker exec $container_id_bitcoind bitcoin-cli -regtest -rpcuser=user -rpcpassword=pass sendtoaddress $address 0.5
+          docker exec $(docker ps -qf "name=mercurylayer_bitcoind_1") bitcoin-cli -regtest -rpcuser=user -rpcpassword=pass -generate 6
+          identity_pubkey_alice=$(docker exec $container_id_alice lncli -n regtest getinfo | jq -r '.identity_pubkey')
+          docker exec $container_id_bob lncli -n regtest openchannel $identity_pubkey_alice 100000
+          docker exec $(docker ps -qf "name=mercurylayer_bitcoind_1") bitcoin-cli -regtest -rpcuser=user -rpcpassword=pass -generate 5
           docker logs $container_id_alice
           docker logs $container_id_bob
       - name: Verify ElectrumX Service with Curl