#!/usr/bin/fift -s "TonUtil.fif" include "GetOpt.fif" include "validator-to-sign.req" =: savefile { ."usage: " @' $0 type ." []" cr ."Creates an unsigned request to vote for complaint (decimal; prefix with '0x' if needed) of past validator set on behalf of validator with zero-based index in current validator set (as stored in configuration parameter 34)." cr ."The result is saved into (" savefile type ." by default) and output in hexadecimal form, to be signed later by the validator public key" cr 1 halt } : usage $# dup 3 < swap 4 > or ' usage if 4 :$1..n $1 parse-int dup =: val-idx 16 ufits not abort"validator index out of range" $2 parse-int dup =: elect-id 32 ufits not abort"invalid election id" $3 parse-int dup =: compl-hash 256 ufits not abort"invalid complaint hash" $4 savefile replace-if-null =: savefile ."Creating a request to vote for complaint 0x" compl-hash 64x. ."of past validator set " elect-id . ."on behalf of current validator with index " val-idx . cr B{56744350} val-idx 16 u>B B+ elect-id 32 u>B B+ compl-hash 256 u>B B+ dup Bx. cr dup B>base64url type cr savefile tuck B>file ."Saved to file " type cr