Ton

Форк
0
/
new-restricted-wallet2.fif 
47 строк · 1.7 Кб
1
#!/usr/bin/fift -s
2
"TonUtil.fif" include
3
"Asm.fif" include
4

5
{ ."usage: " @' $0 type ." <public-key> <amount> [<savefile>]" cr
6
  ."Creates a restricted lockup wallet in the masterchain controlled by the private key corresponding to the specified public key" cr
7
  ."and saves its address into <savefile>.addr ('rwallet.addr' by default)" cr 1 halt
8
} : usage
9
$# 2- -2 and ' usage if
10

11
-1 =: wc
12
$1 parse-pubkey =: PubKey
13
$2 $>GR =: amount
14
def? $3 { @' $3 } { "rwallet" } cond constant file-base
15

16
."Creating new restricted lockup wallet in workchain " wc . ."controlled by public key " PubKey .pubkey
17
." with nominal amount " amount .GR cr
18

19
// D x t -- D'
20
{ <b rot Gram, swap rot 16 b>idict! not abort"cannot add value"
21
} : rdict-entry
22
// balance -- dict
23
{ dictnew
24
  over -32768 rdict-entry
25
  over 3/4 */ 92 rdict-entry
26
  over 1/2 */ 183 rdict-entry
27
  swap 1/4 */ 366 rdict-entry
28
  0 548 rdict-entry
29
} : make-rdict
30

31
// Create new restricted wallet; code taken from `auto/restricted-wallet2-code.fif`
32
"auto/restricted-wallet2-code.fif" include  // code
33
<b 0 32 u, PubKey 256 u, 0 32 u, amount make-rdict dict, b> // data
34
null // no libraries
35
<b b{0011} s, 3 roll ref, rot ref, swap dict, b>  // create StateInit
36
dup ."StateInit: " <s csr. cr
37
dup hashu wc swap 2dup 2constant wallet_addr
38
."new wallet address = " 2dup .addr cr
39
2dup file-base +".addr" save-address-verbose
40
."Non-bounceable address (for init): " 2dup 7 .Addr cr
41
."Bounceable address (for later access): " 6 .Addr cr
42
<b b{1000100} s, wallet_addr addr, b{000010} s, swap 
43
  <s s, b{0} s, 0 256 u, 0 256 u, 0 32 u, -1 32 i, b>
44
dup ."External message for initialization is " <s csr. cr
45
2 boc+>B dup Bx. cr
46
file-base +"-query.boc" tuck B>file
47
."(Saved wallet creating query to file " type .")" cr
48

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

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

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

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