5
{ ."usage: " @' $0 type ." <public-key> [<savefile>]" cr
6
."Creates a restricted 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
13
def? $2 { @' $2 } { "rwallet" } cond constant file-base
15
."Creating new restricted wallet in workchain " wc . ."controlled by public key " PubKey .pubkey cr
17
// Create new restricted wallet; code taken from `auto/restricted-wallet-code.fif`
18
"auto/restricted-wallet-code.fif" include // code
19
<b 0 32 u, PubKey 256 u, b> // data
21
<b b{0011} s, 3 roll ref, rot ref, swap dict, b> // create StateInit
22
dup ."StateInit: " <s csr. cr
23
dup hashu wc swap 2dup 2constant wallet_addr
24
."new wallet address = " 2dup .addr cr
25
2dup file-base +".addr" save-address-verbose
26
."Non-bounceable address (for init): " 2dup 7 .Addr cr
27
."Bounceable address (for later access): " 6 .Addr cr
28
<b b{1000100} s, wallet_addr addr, b{000010} s, swap
29
<s s, b{0} s, 0 256 u, 0 256 u, 0 32 u, -1 32 i, b>
30
dup ."External message for initialization is " <s csr. cr
32
file-base +"-query.boc" tuck B>file
33
."(Saved wallet creating query to file " type .")" cr