-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathpool-elect-req.fif
31 lines (27 loc) · 1.56 KB
/
pool-elect-req.fif
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/fift -s
"TonUtil.fif" include
{ "usage: " @' $0 type ." <pool-addr> <elect-utime> <max-factor> <adnl-addr> [<savefile>]" +cr +tab
+"Creates a request to participate in validator elections starting at <elect-utime> on behalf" +cr +tab
+"of smart-contract with address <pool-addr> and hexadecimal adnl address <adnl-addr>" +cr +tab
"The result is saved into <savefile> and output in hexadecimal form, to be signed later by the validator public key" type cr 1 halt
} : usage
$# dup 3 < swap 5 > or ' usage if
$1 true parse-load-address drop swap 1+ abort"only masterchain smartcontracts may participate in validator elections"
constant src_addr
$2 (number) 1 <> { 0 } if dup 0<= abort"<elect-utime> must be a positive integer"
constant elect_time
$3 (number) dup 0= abort"<max-factor> must be a real number 1..100"
1 = { 16 << } { 16 <</r } cond
dup 65536 < over 6553600 > or abort"<max-factor> must be a real number 1..100"
constant max_factor
def? $4 { @' $4 dup $len 1 > { parse-adnl-address } { drop 0 } cond } ' 0 cond
constant adnl_addr
def? $5 { @' $5 } { "validator-to-sign.bin" } cond constant output_fname
."Creating a request to participate in validator elections at time " elect_time .
."from smart contract " -1 src_addr 2dup 1 .Addr ." = " .addr
." with maximal stake factor with respect to the minimal stake " max_factor ._
."/65536 and validator ADNL address " adnl_addr 64x. cr
B{654c5074} elect_time 32 u>B B+ max_factor 32 u>B B+ src_addr 256 u>B B+ adnl_addr 256 u>B B+
dup Bx. cr
dup B>base64url type cr
output_fname tuck B>file ."Saved to file " type cr