5
"validator-to-sign.req" =: savefile
10
{ ."usage: " @' $0 type ." (-i | <cfg-seqno> <expire-at>) <validator-idx> <proposal-hash> [<savefile>]" cr
11
."Creates an unsigned request expiring at unixtime <expire-at> to vote for configuration proposal <proposal-hash> (decimal; prefix with '0x' if needed) on behalf of validator with zero-based index <validator-idx> in current validator set (as stored in configuration parameter 34)." cr
12
."If -i is selected, prepares unsigned request to be incorporated into an internal message instead." cr
13
."The result is saved into <savefile> (" savefile type ." by default) and output in hexadecimal form, to be signed later by the validator public key" cr 1 halt
16
$# dup 3 < swap 5 > or ' usage if
18
{ $* @ dup null? ' dup ' uncons cond $* ! } : $next
20
$1 "-i" $= { $next drop true =: internal? } if
23
$next parse-int =: seqno
24
$next parse-int dup 30 1<< < { now + 1000 + 2000 /c 2000 * } if
26
dup now <= abort"expiration time must be in the future"
27
32 ufits not abort"invalid expiration time"
29
$# dup 2 < swap 3 > or ' usage if
30
$1 parse-int dup =: val-idx
31
16 ufits not abort"validator index out of range"
32
$2 parse-int dup =: prop-hash
33
256 ufits not abort"invalid proposal hash"
34
$3 savefile replace-if-null =: savefile
36
."Creating a request " internal? { ."with seqno " seqno . ."expiring at " expire-at . } ifnot
37
."to vote for configuration proposal 0x" prop-hash 64x.
38
."on behalf of validator with index " val-idx . cr
40
internal? { B{566f7445} } {
41
B{566f7465} seqno 32 u>B B+ expire-at 32 u>B B+
43
val-idx 16 u>B B+ prop-hash 256 u>B B+
45
dup B>base64url type cr
46
savefile tuck B>file ."Saved to file " type cr