mirror of
https://github.com/ton-blockchain/ton
synced 2025-02-12 19:22:37 +00:00
- rldp-http-proxy used TONLib to resolve domains via DNS smartcontract - updated tonlib - bugfixes
89 lines
3.2 KiB
Text
Executable file
89 lines
3.2 KiB
Text
Executable file
#!/usr/bin/fift -s
|
|
"TonUtil.fif" include
|
|
"GetOpt.fif" include
|
|
|
|
{ show-options-help 1 halt } : usage
|
|
|
|
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
|
|
|
|
begin-options
|
|
" <filename-base> <subwallet-id> <seqno> <order-file> [-n|-b] [-t<timeout>] [<savefile>]" +cr +tab
|
|
+"Creates a request with up to 254 orders loaded from <order-file> to high-load (sub)wallet created by new-highload-wallet.fif, with private key loaded from file <filename-base>.pk "
|
|
+"and address from <filename-base><subwallet-id>.addr, and saves it into <savefile>.boc ('wallet-query.boc' by default)" +cr
|
|
+"<order-file> is a text file with lines `SEND <dest-addr> <amount>`"
|
|
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
|
|
"t" "--timeout" { parse-int =: timeout } short-long-option-arg
|
|
"Sets expiration timeout in seconds (" timeout (.) $+ +" by default)" 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
|
|
|
|
$1 =: file-base
|
|
$2 parse-int dup 32 fits ' usage ifnot =: subwallet-id // parse subwallet-id
|
|
{ subwallet-id (.) $+ } : +subwallet
|
|
$3 parse-int =: seqno
|
|
$4 =: order-file
|
|
$5 "wallet-query" replace-if-null =: savefile
|
|
|
|
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
|
|
|
|
variable orders dictnew orders !
|
|
variable order# order# 0!
|
|
// c --
|
|
{ <s order# @ dup 254 >= abort"more than 254 orders"
|
|
orders @ 16 udict!+ not abort"cannot add order to dictionary"
|
|
orders ! order# 1+!
|
|
} : add-order
|
|
// b body -- b'
|
|
{ tuck <s 2dup 1 s-fits-with? not rot over 1 i, -rot
|
|
{ drop swap ref, } { s, nip } cond
|
|
} : append-msg-body
|
|
// ng wc addr bounce body -- c
|
|
{ <b b{01} s, rot 1 i, b{000100} s, 2swap addr, rot Gram,
|
|
0 9 64 32 + + 1+ u, swap append-msg-body b>
|
|
} : 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
|
|
<b 0 32 u, b> create-int-msg
|
|
} : create-simple-transfer
|
|
// c m -- c'
|
|
{ <b swap 8 u, swap ref, b> } : create-order
|
|
|
|
// addr$ ng --
|
|
{ create-simple-transfer send-mode create-order add-order } : send
|
|
{ bl word bl word $>GR send } : SEND
|
|
|
|
// parse order file
|
|
order-file include
|
|
|
|
// create external message
|
|
<b subwallet-id 32 i, now timeout + 32 u, seqno 32 u, orders @ dict, b>
|
|
dup ."signing message: " <s csr. cr
|
|
dup hashu wallet_pk ed25519_sign_uint
|
|
<b b{1000100} s, wallet_addr addr, 0 Gram, b{00} s,
|
|
swap B, swap <s s, b>
|
|
dup ."resulting external message: " <s csr. cr
|
|
2 boc+>B dup Bx. cr
|
|
savefile +".boc" tuck B>file
|
|
."(Saved to file " type .")" cr
|