-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: update quickstart yml and bump quickstart (#227)
- Loading branch information
1 parent
cb5499a
commit a361425
Showing
85 changed files
with
2,296 additions
and
558 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
tmp* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
DIR="$(dirname "$(readlink -f "$BASH_SOURCE")")" | ||
|
||
TMPDIR="" | ||
TMPDIR=$(mktemp -d -t repipe.XXXXXX) | ||
trap "rm -rf ${TMPDIR}" INT TERM QUIT EXIT | ||
|
||
sed "s/^galoy_git_ref:.*/galoy_git_ref: ${1}/" ${DIR}/../vendir/values.yml > ${TMPDIR}/new_values.yml | ||
|
||
mv ${TMPDIR}/new_values.yml ${DIR}/../vendir/values.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
DIR="$(dirname "$(readlink -f "$BASH_SOURCE")")" | ||
|
||
TMPDIR="" | ||
TMPDIR=$(mktemp -d -t repipe.XXXXXX) | ||
trap "rm -rf ${TMPDIR}" INT TERM QUIT EXIT | ||
|
||
sed "s/^#@ galoy_${1}_image_digest = \".*\"/#@ galoy_${1}_image_digest = \"${2}\"/" ${DIR}/../docker-compose.tmpl.yml > ${TMPDIR}/docker-compose.tmpl.yml | ||
|
||
mv ${TMPDIR}/docker-compose.tmpl.yml ${DIR}/../docker-compose.tmpl.yml |
11 changes: 11 additions & 0 deletions
11
vendor/galoy-quickstart/bin/bump-mongodb-migrate-image-digest.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
DIR="$(dirname "$(readlink -f "$BASH_SOURCE")")" | ||
|
||
TMPDIR="" | ||
TMPDIR=$(mktemp -d -t repipe.XXXXXX) | ||
trap "rm -rf ${TMPDIR}" INT TERM QUIT EXIT | ||
|
||
sed "s/^#@ mongodb_migrate_image_digest = \".*\"/#@ mongodb_migrate_image_digest = \"${1}\"/" ${DIR}/../docker-compose.tmpl.yml > ${TMPDIR}/docker-compose.tmpl.yml | ||
|
||
mv ${TMPDIR}/docker-compose.tmpl.yml ${DIR}/../docker-compose.tmpl.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,239 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
COMPOSE_PROJECT_NAME="${COMPOSE_PROJECT_NAME:-quickstart}" | ||
# default is oathkeeper endpoint | ||
GALOY_ENDPOINT=${GALOY_ENDPOINT:-localhost:4455} | ||
|
||
if [ -n "$HOST_PROJECT_PATH" ]; then | ||
GALOY_DIR="./vendor/galoy-quickstart" | ||
else | ||
GALOY_DIR="." | ||
fi | ||
export GALOY_DIR | ||
|
||
CACHE_DIR=$GALOY_DIR/tmp/quickstart-cache | ||
mkdir -p $CACHE_DIR | ||
|
||
cache_value() { | ||
echo $2 >${CACHE_DIR}/$1 | ||
} | ||
|
||
read_value() { | ||
cat ${CACHE_DIR}/$1 | ||
} | ||
|
||
bitcoin_cli() { | ||
docker exec "${COMPOSE_PROJECT_NAME}-bitcoind-1" bitcoin-cli $@ | ||
} | ||
|
||
lnd_cli() { | ||
docker exec "${COMPOSE_PROJECT_NAME}-lnd1-1" \ | ||
lncli \ | ||
--macaroonpath /root/.lnd/data/chain/bitcoin/regtest/admin.macaroon \ | ||
--tlscertpath /root/.lnd/tls.cert \ | ||
$@ | ||
} | ||
|
||
lnd_outside_cli() { | ||
docker exec "${COMPOSE_PROJECT_NAME}-lnd-outside-1-1" \ | ||
lncli \ | ||
--macaroonpath /root/.lnd/data/chain/bitcoin/regtest/admin.macaroon \ | ||
--tlscertpath /root/.lnd/tls.cert \ | ||
$@ | ||
} | ||
|
||
init_lnd_channel() { | ||
lnd_cli closeallchannels || true | ||
|
||
local amount="1" | ||
local address="$(lnd_outside_cli newaddress p2wkh | jq -r '.address')" | ||
local local_amount="10000000" | ||
bitcoin_cli sendtoaddress "$address" "$amount" | ||
bitcoin_cli -generate 3 | ||
|
||
# Open balanced channel from lnd1 to lndoutside1 | ||
lnd_local_pubkey="$(lnd_cli getinfo | jq -r '.identity_pubkey')" | ||
lnd_outside_cli connect "${lnd_local_pubkey}@${COMPOSE_PROJECT_NAME}-lnd1-1:9735" || true | ||
for i in {1..10}; do | ||
lnd_outside_cli openchannel \ | ||
--node_key "$lnd_local_pubkey" \ | ||
--local_amt "$local_amount" && break | ||
done | ||
|
||
for i in {1..10}; do | ||
local txid="$(bitcoin_cli getrawmempool | jq -r '.[0]')" | ||
[[ "$txid" != "null" ]] && break | ||
sleep 1 | ||
done | ||
|
||
bitcoin_cli -generate 3 | ||
|
||
} | ||
|
||
bria_cli() { | ||
docker exec "${COMPOSE_PROJECT_NAME}-bria-1" bria $@ | ||
} | ||
|
||
bitcoin_signer_cli() { | ||
docker exec "${COMPOSE_PROJECT_NAME}-bitcoind-signer-1" bitcoin-cli $@ | ||
} | ||
|
||
gql_file() { | ||
echo "$GALOY_DIR/galoy/test/bats/gql/$1.gql" | ||
} | ||
|
||
gql_query() { | ||
cat "$(gql_file $1)" | tr '\n' ' ' | sed 's/"/\\"/g' | ||
} | ||
|
||
graphql_output() { | ||
echo $output | jq -r "$@" | ||
} | ||
|
||
exec_graphql() { | ||
local token_name=$1 | ||
local query_name=$2 | ||
local variables=${3:-"{}"} | ||
|
||
if [[ ${token_name} == "anon" ]]; then | ||
AUTH_HEADER="" | ||
else | ||
AUTH_HEADER="Authorization: Bearer $(read_value ${token_name})" | ||
fi | ||
|
||
gql_route="graphql" | ||
|
||
output=$(curl -s \ | ||
-X POST \ | ||
${AUTH_HEADER:+ -H "$AUTH_HEADER"} \ | ||
-H "Content-Type: application/json" \ | ||
-d "{\"query\": \"$(gql_query $query_name)\", \"variables\": $variables}" \ | ||
"${GALOY_ENDPOINT}/${gql_route}") | ||
} | ||
|
||
login_user() { | ||
local token_name=$1 | ||
local phone=$2 | ||
local code=$3 | ||
|
||
local variables=$( | ||
jq -n \ | ||
--arg phone "$phone" \ | ||
--arg code "$code" \ | ||
'{input: {phone: $phone, code: $code}}' | ||
) | ||
exec_graphql 'anon' 'user-login' "$variables" | ||
auth_token="$(graphql_output '.data.userLogin.authToken')" | ||
[[ -n "${auth_token}" && "${auth_token}" != "null" ]] | ||
cache_value "$token_name" "$auth_token" | ||
|
||
exec_graphql "$token_name" 'wallets-for-account' | ||
|
||
account_id="$(graphql_output '.data.me.defaultAccount.id')" | ||
[[ "${account_id}" != "null" ]] | ||
cache_value "$token_name.account_id" "$account_id" | ||
|
||
btc_wallet_id="$(graphql_output '.data.me.defaultAccount.wallets[] | select(.walletCurrency == "BTC") .id')" | ||
[[ "${btc_wallet_id}" != "null" ]] | ||
cache_value "$token_name.btc_wallet_id" "$btc_wallet_id" | ||
|
||
usd_wallet_id="$(graphql_output '.data.me.defaultAccount.wallets[] | select(.walletCurrency == "USD") .id')" | ||
[[ "${usd_wallet_id}" != "null" ]] | ||
cache_value "$token_name.usd_wallet_id" "$usd_wallet_id" | ||
} | ||
|
||
receive_onchain() { | ||
token_name="alice" | ||
btc_wallet_name="$token_name.btc_wallet_id" | ||
amount="0.01" | ||
|
||
variables=$( | ||
jq -n \ | ||
--arg wallet_id "$(read_value $btc_wallet_name)" \ | ||
'{input: {walletId: $wallet_id}}' | ||
) | ||
|
||
exec_graphql "$token_name" 'on-chain-address-create' "$variables" | ||
address="$(graphql_output '.data.onChainAddressCreate.address')" | ||
|
||
bitcoin_cli sendtoaddress "$address" "$amount" | ||
bitcoin_cli -generate 4 | ||
|
||
variables=$( | ||
jq -n \ | ||
--argjson first "1" \ | ||
'{"first": $first}' | ||
) | ||
for i in {1..60}; do | ||
exec_graphql "$token_name" 'transactions' "$variables" | ||
|
||
jq_query='.data.me.defaultAccount.transactions.edges[] | select(.node.initiationVia.address == $address) .node' | ||
settled_status=$(echo $output \ | ||
| jq -r --arg address "$address" "$jq_query" \ | ||
| jq -r ".status") | ||
[[ "${settled_status}" = "SUCCESS" ]] && break | ||
sleep 1 | ||
done | ||
} | ||
|
||
receive_lightning() { | ||
token_name="alice" | ||
btc_wallet_name="$token_name.btc_wallet_id" | ||
btc_amount=1000 | ||
|
||
variables=$( | ||
jq -n \ | ||
--arg wallet_id "$(read_value $btc_wallet_name)" \ | ||
--arg amount "$btc_amount" \ | ||
'{input: {walletId: $wallet_id, amount: $amount}}' | ||
) | ||
exec_graphql "$token_name" 'ln-invoice-create' "$variables" | ||
payment_request="$(echo $invoice | jq -r '.paymentRequest')" | ||
lnd_outside_cli payinvoice -f \ | ||
--pay_req "$payment_request" | ||
|
||
for i in {1..20}; do | ||
jq_query='.data.me.defaultAccount.transactions.edges[] | select(.node.initiationVia.paymentHash == $payment_hash) .node' | ||
echo $output \ | ||
| jq -r --arg payment_hash "$1" "$jq_query" \ | ||
| jq -r ".status" | ||
[[ "${settled_status}" = "SUCCESS" ]] && break | ||
sleep 1 | ||
done | ||
} | ||
|
||
fund_wallet_from_onchain() { | ||
local token_name=$1 | ||
local wallet_id_name="$2" | ||
local amount=$3 | ||
|
||
variables=$( | ||
jq -n \ | ||
--arg wallet_id "$(read_value $wallet_id_name)" \ | ||
'{input: {walletId: $wallet_id}}' | ||
) | ||
exec_graphql "$token_name" 'on-chain-address-create' "$variables" | ||
address="$(graphql_output '.data.onChainAddressCreate.address')" | ||
[[ "${address}" != "null" ]] | ||
|
||
bitcoin_cli sendtoaddress "$address" "$amount" | ||
bitcoin_cli -generate 5 | ||
} | ||
|
||
initialize_user_from_onchain() { | ||
local token_name="$1" | ||
local phone="$2" | ||
local code="$3" | ||
|
||
local btc_amount_in_btc="1" | ||
|
||
login_user "$token_name" "$phone" "$code" | ||
|
||
fund_wallet_from_onchain \ | ||
"$token_name" \ | ||
"$token_name.btc_wallet_id" \ | ||
"$btc_amount_in_btc" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
COMPOSE_PROJECT_NAME="${COMPOSE_PROJECT_NAME:-quickstart}" | ||
|
||
DIR="$(dirname "$(readlink -f "$BASH_SOURCE")")" | ||
source ${DIR}/helpers.sh | ||
|
||
echo "Running getinfo on lnd..." | ||
lnd_cli getinfo | ||
echo "DONE" | ||
echo "Opening lnd-outside -> lnd channel" | ||
init_lnd_channel | ||
echo "DONE" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
COMPOSE_PROJECT_NAME="${COMPOSE_PROJECT_NAME:-quickstart}" | ||
|
||
DIR="$(dirname "$(readlink -f "$BASH_SOURCE")")" | ||
source ${DIR}/helpers.sh | ||
|
||
echo "Seeding some regtest blocks..." | ||
|
||
bitcoin_cli createwallet "outside" || true | ||
bitcoin_cli -generate 200 > /dev/null 2>&1 | ||
|
||
bitcoin_signer_cli createwallet "dev" || true | ||
bitcoin_signer_cli -rpcwallet=dev importdescriptors "$(cat $GALOY_DIR/galoy/test/bats/bitcoind_signer_descriptors.json)" | ||
|
||
echo "Checking that bria is running..." | ||
|
||
for i in {1..20}; do | ||
bria_cli wallet-balance -w dev-wallet && break | ||
sleep 1 | ||
done | ||
bria_cli wallet-balance -w dev-wallet || exit 1 | ||
|
||
echo "DONE" |
Oops, something went wrong.