5
{ ."usage: " @' $0 type ." <workchain-id> <subwallet-id> [<filename-base>]" cr
6
."Creates a new v2 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
17
65536 constant timeout // init query times out in 65536 seconds
19
."Creating new v2 high-load wallet in workchain " wc .
20
."with subwallet id " subwallet-id . cr
22
// Create new high-load wallet; source code included from `auto/highload-wallet-v2-code.fif`
23
"auto/highload-wallet-v2-code.fif" include
25
<b subwallet-id 32 i, 0 64 u,
26
file-base +".pk" load-generate-keypair
31
<b b{0011} s, 3 roll ref, rot ref, swap dict, b> // create StateInit
32
dup ."StateInit: " <s csr. cr
33
dup hashu wc swap 2dup 2constant wallet_addr
34
."new wallet address = " 2dup .addr cr
35
2dup file-base +subwallet +".addr" save-address-verbose
36
."Non-bounceable address (for init): " 2dup 7 .Addr cr
37
."Bounceable address (for later access): " 6 .Addr cr
38
now timeout + 32 << 1- dup =: query_id
39
."Init query_id is " dup . ."(0x" X._ .")" cr
40
<b subwallet-id 32 i, query_id 64 u, false 1 i, b>
41
dup ."signing message: " <s csr. cr
42
dup hashu wallet_pk ed25519_sign_uint rot
43
<b b{1000100} s, wallet_addr addr, b{000010} s, swap <s s, b{0} s, swap B, swap <s s, b>
44
dup ."External message for initialization is " <s csr. cr
46
file-base +subwallet +"-query.boc" tuck B>file
47
."(Saved wallet creating query to file " type .")" cr