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
12
$1 parse-pubkey =: PubKey
14
def? $3 { @' $3 } { "rwallet" } cond constant file-base
16
."Creating new restricted lockup wallet in workchain " wc . ."controlled by public key " PubKey .pubkey
17
." with nominal amount " amount .GR cr
20
{ <b rot Gram, swap rot 16 b>idict! not abort"cannot add value"
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
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
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
46
file-base +"-query.boc" tuck B>file
47
."(Saved wallet creating query to file " type .")" cr