#!/usr/bin/env fift -s "TonUtil.fif" include "Asm.fif" include { ."usage: " @' $0 type ." []" cr ."Creates a new v2 high-load wallet in the specified workchain, with the controlling private key saved to or loaded from .pk " ."('new-wallet.pk' by default)" cr ." is the 32-bit identifier of this subwallet among all controlled by the same private key" cr 1 halt } : usage $# 2- -2 and ' usage if $1 parse-workchain-id =: wc // set workchain id from command line argument $2 parse-int dup =: subwallet-id // parse subwallet-id 32 fits ' usage ifnot { subwallet-id (.) $+ } : +subwallet def? $3 { @' $3 } { "new-wallet" } cond constant file-base 65536 constant timeout // init query times out in 65536 seconds ."Creating new v2 high-load wallet in workchain " wc . ."with subwallet id " subwallet-id . cr // Create new high-load wallet; source code included from `highload-wallet-v2-code.fif` "highload-wallet-v2-code.fif" include // code // data null // no libraries // create StateInit dup ."StateInit: " dup ."signing message: " dup ."External message for initialization is " B dup Bx. cr file-base +subwallet +"-query.boc" tuck B>file ."(Saved wallet creating query to file " type .")" cr