#!/usr/bin/gawk -f
#extract coins from stream (often an inbox)
{
  if( $0 ~ /^-----BEGIN SIGNED COIN-----/ ||
      $0 ~ /^-----BEGIN SIGNED BLINDED COIN-----/ ||
      $0 ~ /^-----BEGIN UNBLINDER/ ||
      $0 ~ /^-----BEGIN SIGNED TITLE-----/ ||
      $0 ~ /^-----BEGIN BLINDED COIN-----/ ){
    print;
    count = 0;
    test = $0;
    sub("-----BEGIN ","-----END ", test);
    while( count++ < 12 && !( $0 ~ "^" test ) ){
      getline;
      print;
    }
    if( count == 13 )
      print test "\nABOVE IS AN ERROR!!!";
  }
}
