diff options
Diffstat (limited to 'sandcastle/utils/fund-rewards.sh')
-rwxr-xr-x | sandcastle/utils/fund-rewards.sh | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/sandcastle/utils/fund-rewards.sh b/sandcastle/utils/fund-rewards.sh deleted file mode 100755 index 6f76a39..0000000 --- a/sandcastle/utils/fund-rewards.sh +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/bash - -# This file is in the public domain. - -set -eu - -# Maybe add these to base Dockerfile as ENV? - -export LD_LIBRARY_PATH=/usr/local/lib -export GNUNET_FORCE_LOG=";;;;WARNING" - -# Configuration variables - Please change to your needs - -DOMAIN="demo.taler.net" - -# Program variables - No need to be changed by the user. - -MERCHANT_URL="https://backend.${DOMAIN}/" -MERCHANT_APIKEY=$(taler-config -c /config/deployment.conf -s taler-deployment -o merchant-apikey) -BANK_ACCESS_URL="https://bank.${DOMAIN}/demobanks/default/access-api/" -WIRE_METHOD="iban" -AMOUNT="100" # Amount to add, on each new reserve (tiptopup option) -BANK_ACCOUNT="survey-at-sandbox" -BANK_PASSWORD="secret-at-sandbox" -#BANK_PASSWORD=$(taler-config -c /config/deployment.conf -s taler-deployment -o db-password) -EXCHANGE_URL=$(taler-config -c /config/deployment.conf -s taler-deployment -o default-exchange) -EXCHANGE_URL="https://exchange.${DOMAIN}/" -# shellcheck disable=SC2034 -CURRENCY=$(taler-config -c /config/deployment.conf -s taler-deployment -o currency) - -# Obtain current reserves in json format -# Just one single call to the taler-harness program to avoid inconsistencies - -JSON=$(taler-harness deployment tip-status \ - --merchant-url "$MERCHANT_URL" \ - --merchant-apikey "$MERCHANT_APIKEY") - -# Calculate remaining funds - -ACTIVE_FUNDS=$(echo "$JSON" | jq '[.reserves[] | select(.active)]') - -# If there is ANY active reserve, then do the substraction -if [[ $ACTIVE_FUNDS != "[]" ]]; then -TOTAL_EXCHANGE_INITIAL_AMOUNT=$(echo "$ACTIVE_FUNDS" | jq --arg cur "$CURRENCY" '[.[].exchange_initial_amount | sub($cur + ":"; "") | tonumber] | add') -TOTAL_PICKUP_AMOUNT=$(echo "$ACTIVE_FUNDS" | jq --arg cur "$CURRENCY" '[.[].pickup_amount | sub($cur + ":"; "") | tonumber] | add') -TOTAL_RESERVE_AMOUNT=$((TOTAL_EXCHANGE_INITIAL_AMOUNT - TOTAL_PICKUP_AMOUNT)) -else -# Otherwise set variable to zero -TOTAL_RESERVE_AMOUNT=0 -fi - -# Decide whether add a new reserve, or leave it as is. - -if [ "$TOTAL_RESERVE_AMOUNT" -lt 100 ]; then - # Add new reserve amount of 100 units - taler-harness deployment tip-topup \ - --merchant-url "$MERCHANT_URL" \ - --merchant-apikey="$MERCHANT_APIKEY" \ - --bank-access-url "$BANK_ACCESS_URL" \ - --wire-method="$WIRE_METHOD" \ - --amount=KUDOS:"$AMOUNT" \ - --bank-account="$BANK_ACCOUNT" \ - --bank-password="$BANK_PASSWORD" \ - --exchange-url "$EXCHANGE_URL" -fi - -# If the json variable contains more than 100 records, wipe its content - -TOTAL_JSON_RECORDS=$(echo "$JSON" | jq '.[] | length') - -if [ "$TOTAL_JSON_RECORDS" -gt 100 ]; then - taler-harness deployment tip-cleanup --merchant-url "$BACKEND_URL" -fi - |