2
0
mirror of https://github.com/lnbook/lnbook synced 2024-11-18 21:28:03 +00:00

Merge pull request #626 from keblek/patch-2

Added -r option to jq to strip quotes
This commit is contained in:
Andreas M. Antonopoulos 2021-02-07 11:28:08 -06:00 committed by GitHub
commit 6b7cef987f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,24 +1,10 @@
#!/bin/bash #!/bin/bash
echo Getting node IDs echo Getting node IDs
alice_address=$(docker-compose exec -T Alice bash -c "lncli -n regtest getinfo | jq .identity_pubkey") alice_address=$(docker-compose exec -T Alice bash -c "lncli -n regtest getinfo | jq -r .identity_pubkey")
bob_address=$(docker-compose exec -T Bob bash -c "lightning-cli getinfo | jq .id") bob_address=$(docker-compose exec -T Bob bash -c "lightning-cli getinfo | jq -r .id")
wei_address=$(docker-compose exec -T Wei bash -c "eclair-cli -s -j -p eclair getinfo| jq .nodeId") wei_address=$(docker-compose exec -T Wei bash -c "eclair-cli -s -j -p eclair getinfo| jq -r .nodeId")
gloria_address=$(docker-compose exec -T Gloria bash -c "lncli -n regtest getinfo | jq .identity_pubkey") gloria_address=$(docker-compose exec -T Gloria bash -c "lncli -n regtest getinfo | jq -r .identity_pubkey")
# The jq command returns JSON strings enclosed in double-quote characters
# These will confuse the shell later, because double-quotes have special
# meaning in a bash script.
# We remove the double-quote character by using the shell string manipulation
# expression: // removes the " character. Even here, we have to escape the "
# character with a backslash because otherwise bash will interpret it as a
# string closure.
# A bit messy, but it works!
alice_address=${alice_address//\"}
bob_address=${bob_address//\"}
wei_address=${wei_address//\"}
gloria_address=${gloria_address//\"}
# Let's tell everyone what we found! # Let's tell everyone what we found!
echo Alice: ${alice_address} echo Alice: ${alice_address}
@ -40,10 +26,8 @@ docker-compose exec -T Wei eclair-cli -p eclair connect --uri=${gloria_address}@
docker-compose exec -T Wei eclair-cli -p eclair open --nodeId=${gloria_address} --fundingSatoshis=1000000 docker-compose exec -T Wei eclair-cli -p eclair open --nodeId=${gloria_address} --fundingSatoshis=1000000
echo Get 10k sats invoice from Gloria echo Get 10k sats invoice from Gloria
gloria_invoice=$(docker-compose exec -T Gloria bash -c "lncli -n regtest addinvoice 10000 | jq .payment_request") gloria_invoice=$(docker-compose exec -T Gloria bash -c "lncli -n regtest addinvoice 10000 | jq -r .payment_request")
# Remove quotes
gloria_invoice=${gloria_invoice//\"}
echo Gloria invoice ${gloria_invoice} echo Gloria invoice ${gloria_invoice}
echo Wait for channel establishment - 60 seconds for 6 blocks echo Wait for channel establishment - 60 seconds for 6 blocks