#!/bin/bash
cat /etc/os-release
sha256sum ./bx-linux-x64-qrcode || { echo bx absent; exit 1; }
[[ $1 && $2 && $3 ]] || { echo usage: $0 ppp_id initial_tx_hash part_of_name [option]; exit 1; }
[[ $1 =~ ^ppp_[a-z][a-z]_[0-9]{4}_[0-9]{2}_([0-9a-f]{3})_([0-9a-f]{3})$ ]] || { echo wrong ppp_id; exit 1; }
[[ $2 =~ ^${BASH_REMATCH[1]}[0-9a-f]{58}${BASH_REMATCH[2]}$ ]] || { echo wrong initial_tx_hash; exit 1; }
wget --no-verbose -T 15 -O- https://bico.media/$2 >tmp.txt || { echo wget failed; exit 1; }
grep -q "#pp${1:2:5}new" tmp.txt || { echo _new tag not found; exit 1; }
grep -q "$3" tmp.txt || { echo part of name not found; exit 1; }
ppp=$1
function pba {
  echo ---
  abbrev=$(echo $* | python3 -c 'import sys, re; print("".join(re.findall("\\b\\w", sys.stdin.readline())))')
  (( ${#abbrev} > 1 )) && echo '#'expl_${ppp}_${abbrev} - $* || abbrev=$1
  for m in 10 100 1000
  do
    tag='#'${ppp}_${abbrev}_hmwyda_$m
    echo $tag - $(./bx-linux-x64-qrcode base16-encode $tag | ./bx-linux-x64-qrcode ripemd160 | ./bx-linux-x64-qrcode address-encode)
  done
}
echo "---
#hmwyda_${ppp:4:2}_options
#${ppp}
#${ppp}_initial_tx: $2
#${ppp}_options:"
[[ $4 ]] && { shift 3; pba $*; exit; }
pba prior warning/question
pba serious warning/demand
pba personal information general
pba personal information private
pba personal information body identification
pba personal information dna
pba information/money minor damage
pba information/money serious damage
pba material things/objects minor damage
pba material things/objects serious damage
pba home minor damage
pba home serious damage
pba home unusable
pba body minor damage
pba body serious damage
pba body disability/chronic disease
pba death
