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
variable extra-currencies
12
{ extra-currencies @ cc+ extra-currencies ! } : extra-cc+!
15
" <filename-base> <dest-addr> <seqno> <amount> [-x <extra-amount>*<extra-currency-id>] [-n|-b] [-B <body-boc>] [-C <comment>] [<savefile>]" +cr +tab
16
+"Creates a request to simple wallet created by new-wallet.fif, with private key loaded from file <filename-base>.pk "
17
+"and address from <filename-base>.addr, and saves it into <savefile>.boc ('wallet-query.boc' by default)"
18
disable-digit-options generic-help-setopt
19
"n" "--no-bounce" { false =: allow-bounce } short-long-option
20
"Clears bounce flag" option-help
21
"b" "--force-bounce" { true =: force-bounce } short-long-option
22
"Forces bounce flag" option-help
23
"x" "--extra" { $>xcc extra-cc+! } short-long-option-arg
24
"Indicates the amount of extra currencies to be transfered" option-help
25
"B" "--body" { =: body-boc-file } short-long-option-arg
26
"Sets the payload of the transfer message" option-help
27
"C" "--comment" { =: comment } short-long-option-arg
28
"Sets the comment to be sent in the transfer message" option-help
29
"I" "--with-init" { =: init-file } short-long-option-arg
30
"Indicates filename with BoC containing StateInit for internal message" option-help
31
"m" "--mode" { parse-int =: send-mode } short-long-option-arg
32
"Sets transfer mode (0..255) for SENDRAWMSG (" send-mode (.) $+ +" by default)"
34
"h" "--help" { usage } short-long-option
35
"Shows a help message" option-help
38
$# dup 4 < swap 5 > or ' usage if
42
$2 bounce parse-load-address allow-bounce and force-bounce or =: bounce 2=: dest_addr
44
$4 $>cc extra-cc+! extra-currencies @ 2=: amount
45
$5 "wallet-query" replace-if-null =: savefile
46
allow-bounce not force-bounce and abort"cannot have bounce flag both set and cleared"
47
// "" 1 { 69091 * 1+ 65535 and tuck 2521 / 65 + hold swap } 1000 times drop =: comment
49
file-base +".addr" load-address
50
2dup 2constant wallet_addr
51
."Source wallet address = " 2dup .addr cr 6 .Addr cr
52
file-base +".pk" load-keypair nip constant wallet_pk
54
def? body-boc-file { @' body-boc-file file>B B>boc } { comment simple-transfer-body } cond
57
def? init-file { @' init-file file>B B>boc <s b{11} swap |_ } { b{0} } cond
60
."Transferring " amount .GR+cc ."to account "
61
dest_addr 2dup bounce 7 + .Addr ." = " .addr
62
."seqno=0x" seqno x. ."bounce=" bounce . cr
63
."Body of transfer message is " body-cell <s csr. cr
64
."StateInit is " state-init csr. cr
67
<b b{01} s, bounce 1 i, b{000} s, dest_addr Addr, amount Gram+cc, 0 8 64 32 + + u, state-init s,
68
body-cell <s 2dup 1 s-fits-with? not rot over 1 i, -rot { drop body-cell ref, } { s, } cond
70
<b 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
."(Saved to file " type .")" cr