summaryrefslogtreecommitdiff
path: root/regional-currency/list-incoming.sh
blob: aa12b33aa309e7079b3480d562239656cb0765b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env bash

# This file is in the public domain.

# Script for basic diagnostics of a Taler regio deployment.
# @author Florian Dold <dold@taler.net>

if [ "$(id -u)" -ne 0 ]; then
  echo "FATAL: Please run as root." >&2
  exit 1
fi

libeufin_bank_db=$(libeufin-bank config get libeufin-bankdb-postgres config)
libeufin_nexus_db=$(libeufin-nexus config get libeufin-nexusdb-postgres config)
exchange_db=$(taler-config -s exchangedb-postgres -o config)

if [[ $libeufin_nexus_db != $libeufin_bank_db ]]; then
  echo "FATAL: libeufin-bank and libeufin-nexus don't share the same database" >&2
  exit 1
fi

libeufin_db=$libeufin_bank_db

# runsql db RESNAME < query
function runsql() {
  local sql
  read -r -d '' sql
  res=$(cd / && sudo -u postgres psql "$1" -t --csv -c "$sql")
  printf -v "$2" '%s' "$res"
}

runsql "$exchange_db" reserves_in <<EOF
select reserve_pub from exchange.reserves_in;
EOF

mapfile -t lines <<<$reserves_in

for line in "${lines[@]}"; do
  python3 -c "import sys; print(sys.argv[1].encode('utf-8').decode('unicode_escape'))" "$line" | gnunet-base32
  echo
done