Ton

Форк
0
/
config-proposal-vote-req.fif 
46 строк · 1.8 Кб
1
#!/usr/bin/fift -s
2
"TonUtil.fif" include
3
"GetOpt.fif" include
4

5
"validator-to-sign.req" =: savefile
6
false =: internal?
7
-1 =: seqno
8
-1 =: expire-at
9

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
14
} : usage
15

16
$# dup 3 < swap 5 > or ' usage if
17
5 :$1..n
18
{ $* @ dup null? ' dup ' uncons cond $* ! } : $next
19

20
$1 "-i" $= { $next drop true =: internal? } if
21

22
internal? {
23
  $next parse-int =: seqno
24
  $next parse-int dup 30 1<< < { now + 1000 + 2000 /c 2000 * } if
25
    dup =: expire-at
26
    dup now <= abort"expiration time must be in the future"
27
    32 ufits not abort"invalid expiration time"
28
} ifnot
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
35

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
39

40
internal? { B{566f7445} } {
41
  B{566f7465} seqno 32 u>B B+ expire-at 32 u>B B+
42
} cond
43
val-idx 16 u>B B+ prop-hash 256 u>B B+ 
44
dup Bx. cr
45
dup B>base64url type cr
46
savefile tuck B>file ."Saved to file " type cr
47

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.