#!/bin/bash

curl -s --url "http://127.0.0.1:7778" --data "{\"agent\":\"bitcoinrpc\",\"method\":\"getaddressesbyaccount\",\"account\":\"IGUANA\"}" > /tmp/getaddressbyaccount
printf "\n"

# call json_extract script to get the RPC status value
addr_gaba=$(~/tests/./json_extracta /tmp/getaddressbyaccount result)
err_gaba=$(~/tests/./json_extracta /tmp/getaddressbyaccount error)

addrs=$(echo $addr_gaba | tr "[,]" "\n")


for iguana_addrs in $addrs
do

addrs1=($(echo $iguana_addrs | tr -d '""'))

printf "new address:%s\n" "$addrs1"

curl -s --url "http://127.0.0.1:7778" --data "{\"agent\":\"bitcoinrpc\",\"method\":\"getaccount\",\"address\":\"$addrs1\"}"> /tmp/getaccount
printf "\n"

# call json_extract script to get the RPC status value
acc_ga=$(~/tests/./json_extract /tmp/getaccount account)
printf "ACCOUNT:%s\n" "$acc_ga"

  if [ "$acc_ga" == "IGUANA" ]
  then
      printf "PASSED:"
  else
     printf "FAILED:"

  fi
done