#!/usr/bin/gawk -f

#this takes a signed coin, and runs xchequer to create a corresponding
#new blinded protocoin in cashfile.new, and unblinder in cashfile.nub.
#
#This is so you can do something like:
#
#    cat cashfile.sgn | newexch.awk | mail xchequer
#
#Then have procmail look for "-----BEGIN SIGNED BLINDED COIN-----"
#in the body of incoming mail, and pass it through a similar script
#cating the cashfile.nub to the mail message and running it through
#xchequer to unblind and save off the coin.
#
#xchequer below needs the pgp keyrings in the default locations

{
  if( $0 ~ /^-----BEGIN SIGNED COIN-----/ ){
    print;
    getline;
    command = "xchequer -i " $1 ">>cashfile.new 2>>cashfile.nub";
    system(command);
  }
  print;
}

END {
  system("cat cashfile.new");
}

