5
{ ."usage: " @' $0 type ." <workchain-id> <subwallet-id> [<filename-base>]" cr
6
."Creates a new high-load wallet in the specified workchain, with the controlling private key saved to or loaded from <filename-base>.pk "
7
."('new-wallet.pk' by default)" cr
8
."<subwallet-id> is the 32-bit identifier of this subwallet among all controlled by the same private key" cr 1 halt
10
$# 2- -2 and ' usage if
12
$1 parse-workchain-id =: wc // set workchain id from command line argument
13
$2 parse-int dup =: subwallet-id // parse subwallet-id
15
{ subwallet-id (.) $+ } : +subwallet
16
def? $3 { @' $3 } { "new-wallet" } cond constant file-base
18
."Creating new high-load wallet in workchain " wc .
19
."with subwallet id " subwallet-id . cr
21
// Create new high-load wallet; source code included from `auto/highload-wallet-code.fif`
22
"auto/highload-wallet-code.fif" include
24
<b 0 32 u, subwallet-id 32 i,
25
file-base +".pk" load-generate-keypair
30
<b b{0011} s, 3 roll ref, rot ref, swap dict, b> // create StateInit
31
dup ."StateInit: " <s csr. cr
32
dup hashu wc swap 2dup 2constant wallet_addr
33
."new wallet address = " 2dup .addr cr
34
2dup file-base +subwallet +".addr" save-address-verbose
35
."Non-bounceable address (for init): " 2dup 7 .Addr cr
36
."Bounceable address (for later access): " 6 .Addr cr
37
<b subwallet-id 32 i, -1 32 i, 0 32 u, false 1 i, b>
38
dup ."signing message: " <s csr. cr
39
dup hashu wallet_pk ed25519_sign_uint rot
40
<b b{1000100} s, wallet_addr addr, b{000010} s, swap <s s, b{0} s, swap B, swap <s s, b>
41
dup ."External message for initialization is " <s csr. cr
43
file-base +subwallet +"-query.boc" tuck B>file
44
."(Saved wallet creating query to file " type .")" cr