summaryrefslogtreecommitdiff
path: root/regional-currency/list-incoming.sh
blob: bb3a67d39104a499c0f79e353f2dc8b0c9da8ae3 (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
#!/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

exchange_db=$(taler-config -s exchangedb-postgres -o config)

# 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 binascii; import sys; sys.stdout.buffer.write(binascii.a2b_hex(sys.argv[1][2:]))" "$line" | gnunet-base32
  echo
done