Skip to content

Commit

Permalink
feat: add wallet creation for esplora
Browse files Browse the repository at this point in the history
  • Loading branch information
DhananjayPurohit committed Aug 13, 2024
1 parent e4aec0b commit 296e370
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ jobs:
echo "New Wallet Address: $address"
docker exec $container_id bitcoin-cli -regtest -rpcuser=user -rpcpassword=pass generatetoaddress 101 "$address"
docker exec $container_id bitcoin-cli -regtest -rpcuser=user -rpcpassword=pass sendtoaddress bcrt1pcngfxjdkf4r2h26k52dh5nunxg8m68uf4lkfhmfjvjj6agfkm5jqmftw4e 0.0001
- name: Create wallet for esplora
run: |
container_id=$(docker ps -qf "name=esplora-container")
echo "Container ID: $container_id"
docker logs $container_id
wallet_name="esplora_wallet"
docker exec $container_id cli createwallet $wallet_name
- name: Wait for services to be ready
run: |
sleep 60 # Wait for lnd to sync with latest block
Expand Down
6 changes: 3 additions & 3 deletions clients/tests/web/server-regtest.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ app.use(bodyParser.json())
app.use(cors())

async function getnewaddress() {
const generateBlockCommand = `docker exec $(docker ps -qf "name=esplora-container") cli -rpcconnect=bitcoind -rpcuser=user -rpcpassword=pass getnewaddress`;
const generateBlockCommand = `docker exec $(docker ps -qf "name=esplora-container") cli getnewaddress`;
const { stdout, stderr } = await exec(generateBlockCommand);
if (stderr) {
throw new Error(`Error: ${stderr}`);
Expand All @@ -20,13 +20,13 @@ async function getnewaddress() {

async function generateBlocks(numBlocks) {
const address = await getnewaddress();
const generateBlockCommand = `docker exec $(docker ps -qf "name=esplora-container") cli -rpcconnect=bitcoind -rpcuser=user -rpcpassword=pass generatetoaddress ${numBlocks} ${address}`;
const generateBlockCommand = `docker exec $(docker ps -qf "name=esplora-container") cli generatetoaddress ${numBlocks} ${address}`;
await exec(generateBlockCommand);
}

async function depositCoin(amount, address) {
const amountInBtc = amount / 100000000;
const sendBitcoinCommand = `docker exec $(docker ps -qf "name=esplora-container") cli -rpcconnect=bitcoind -rpcuser=user -rpcpassword=pass sendtoaddress ${address} ${amountInBtc}`;
const sendBitcoinCommand = `docker exec $(docker ps -qf "name=esplora-container") cli sendtoaddress ${address} ${amountInBtc}`;
await exec(sendBitcoinCommand);
}

Expand Down

0 comments on commit 296e370

Please sign in to comment.