#!/usr/bin/fift -s "TonUtil.fif" include "GetOpt.fif" include { show-options-help 1 halt } : usage "" =: comment // comment for simple transfers true =: allow-bounce false =: force-bounce 3 =: send-mode // mode for SENDRAWMSG: +1 - sender pays fees, +2 - ignore errors 60 =: timeout // external message expires in 60 seconds variable extra-currencies { extra-currencies @ cc+ extra-currencies ! } : extra-cc+! begin-options " [-x *] [-n|-b] [-t] [-B ] [-C ] []" +cr +tab +"Creates one request to highload wallet created by new-highload-wallet-v2.fif, with private key loaded from file .pk " +"and address from .addr, and saves it into .boc ('wallet-query.boc' by default)" disable-digit-options generic-help-setopt "n" "--no-bounce" { false =: allow-bounce } short-long-option "Clears bounce flag" option-help "b" "--force-bounce" { true =: force-bounce } short-long-option "Forces bounce flag" option-help "x" "--extra" { $>xcc extra-cc+! } short-long-option-arg "Indicates the amount of extra currencies to be transfered" option-help "t" "--timeout" { parse-int =: timeout } short-long-option-arg "Sets expiration timeout in seconds (" timeout (.) $+ +" by default)" option-help "B" "--body" { =: body-boc-file } short-long-option-arg "Sets the payload of the transfer message" option-help "C" "--comment" { =: comment } short-long-option-arg "Sets the comment to be sent in the transfer message" option-help "m" "--mode" { parse-int =: send-mode } short-long-option-arg "Sets transfer mode (0..255) for SENDRAWMSG (" send-mode (.) $+ +" by default)" option-help "h" "--help" { usage } short-long-option "Shows a help message" option-help parse-options $# dup 4 < swap 5 > or ' usage if 5 :$1..n true constant bounce $1 =: file-base $2 bounce parse-load-address force-bounce or allow-bounce and =: bounce 2=: dest_addr $3 parse-int =: subwallet-id $4 $>cc extra-cc+! extra-currencies @ 2=: amount $5 "wallet-query" replace-if-null =: savefile { subwallet-id (.) $+ } : +subwallet file-base +subwallet +".addr" load-address 2dup 2constant wallet_addr ."Source wallet address = " 2dup .addr cr 6 .Addr cr file-base +".pk" load-keypair nip constant wallet_pk def? body-boc-file { @' body-boc-file file>B B>boc } { comment simple-transfer-body } cond constant body-cell ."Transferring " amount .GR+cc ."to account " dest_addr 2dup bounce 7 + .Addr ." = " .addr ."subwallet-id=0x" subwallet-id x. ."timeout=" timeout . ."bounce=" bounce . cr ."Body of transfer message is " body-cell = abort"more than 254 orders" orders @ 16 udict!+ not abort"cannot add order to dictionary" orders ! order# 1+! } : add-order // b body -- b' { tuck } : create-int-msg // ng wc addr bnc -- { ."Transferring " 3 roll .GR ."to account " -rot 2dup 4 pick 7 + .Addr ." = " .addr ." bounce=" . cr } : .transfer // addr$ ng -- c { swap parse-smc-addr force-bounce or allow-bounce and // ng wc addr bnc 2over 2over .transfer create-int-msg } : create-simple-transfer // c m -- c' { } : create-order // addr$ ng -- { create-simple-transfer send-mode create-order add-order } : send { bl word bl word $>GR send } : SEND // create internal message send-mode create-order add-order // create external message now timeout + 32 << hashu 32 1<<1- and + =: query_id dup ."signing message: " dup ."resulting external message: " B dup Bx. cr ."Query_id is " query_id dup . ."= 0x" X. cr savefile +".boc" tuck B>file ."(Saved to file " type .")" cr