5
{ show-options-help 1 halt } : usage
7
"" =: comment // comment for simple transfers
10
3 =: send-mode // mode for SENDRAWMSG: +1 - sender pays fees, +2 - ignore errors
11
60 =: timeout // external message expires in 60 seconds
12
variable extra-currencies
13
{ extra-currencies @ cc+ extra-currencies ! } : extra-cc+!
16
" <filename-base> <dest-addr> <subwallet-id> <seqno> <amount> [-x <extra-amount>*<extra-currency-id>] [-n|-b] [-t<timeout>] [-B <body-boc>] [-C <comment>] [<savefile>]" +cr +tab
17
+"Creates a request to advanced wallet created by new-wallet-v3.fif, with private key loaded from file <filename-base>.pk "
18
+"and address from <filename-base>.addr, and saves it into <savefile>.boc ('wallet-query.boc' by default)"
19
disable-digit-options generic-help-setopt
20
"n" "--no-bounce" { false =: allow-bounce } short-long-option
21
"Clears bounce flag" option-help
22
"b" "--force-bounce" { true =: force-bounce } short-long-option
23
"Forces bounce flag" option-help
24
"x" "--extra" { $>xcc extra-cc+! } short-long-option-arg
25
"Indicates the amount of extra currencies to be transfered" option-help
26
"t" "--timeout" { parse-int =: timeout } short-long-option-arg
27
"Sets expiration timeout in seconds (" timeout (.) $+ +" by default)" option-help
28
"B" "--body" { =: body-boc-file } short-long-option-arg
29
"Sets the payload of the transfer message" option-help
30
"C" "--comment" { =: comment } short-long-option-arg
31
"Sets the comment to be sent in the transfer message" option-help
32
"m" "--mode" { parse-int =: send-mode } short-long-option-arg
33
"Sets transfer mode (0..255) for SENDRAWMSG (" send-mode (.) $+ +" by default)"
35
"h" "--help" { usage } short-long-option
36
"Shows a help message" option-help
39
$# dup 5 < swap 6 > or ' usage if
44
$2 bounce parse-load-address force-bounce or allow-bounce and =: bounce 2=: dest_addr
45
$3 parse-int =: subwallet_id
47
$5 $>cc extra-cc+! extra-currencies @ 2=: amount
48
$6 "wallet-query" replace-if-null =: savefile
49
subwallet_id (.) 1 ' $+ does : +subwallet
51
file-base +subwallet +".addr" dup file-exists? { drop file-base +".addr" } ifnot
53
2dup 2constant wallet_addr
54
."Source wallet address = " 2dup .addr cr 6 .Addr cr
55
file-base +".pk" load-keypair nip constant wallet_pk
57
def? body-boc-file { @' body-boc-file file>B B>boc } { comment simple-transfer-body } cond
60
."Transferring " amount .GR+cc ."to account "
61
dest_addr 2dup bounce 7 + .Addr ." = " .addr
62
."subwallet_id=0x" subwallet_id x.
63
."seqno=0x" seqno x. ."bounce=" bounce . cr
64
."Body of transfer message is " body-cell <s csr. cr
67
<b b{01} s, bounce 1 i, b{000} s, dest_addr Addr, amount Gram+cc, 0 9 64 32 + + u,
68
body-cell <s 2dup 1 s-fits-with? not rot over 1 i, -rot { drop body-cell ref, } { s, } cond
70
<b subwallet_id 32 u, now timeout + 32 u, seqno 32 u, send-mode 8 u, swap ref, b>
71
dup ."signing message: " <s csr. cr
72
dup hashu wallet_pk ed25519_sign_uint
73
<b b{1000100} s, wallet_addr addr, 0 Gram, b{00} s,
75
dup ."resulting external message: " <s csr. cr
77
savefile +".boc" tuck B>file
78
."Query expires in " timeout . ."seconds" cr
79
."(Saved to file " type .")" cr