mirror of
https://github.com/danog/ton.git
synced 2024-11-30 04:29:19 +01:00
52 lines
1.9 KiB
Plaintext
52 lines
1.9 KiB
Plaintext
#!/usr/bin/fift -s
|
|
"TonUtil.fif" include
|
|
|
|
{ ."usage: " @' $0 type ." <filename-base> <dest-addr> <seqno> <amount> [-B <body-boc>] [<savefile>]" cr
|
|
."Creates a request to simple wallet created by new-wallet.fif, with private key loaded from file <filename-base>.pk "
|
|
."and address from <filename-base>.addr, and saves it into <savefile>.boc ('wallet-query.boc' by default)" cr 1 halt
|
|
} : usage
|
|
def? $6 { @' $5 "-B" $= { @' $6 =: body-boc-file [forget] $6 def? $7 { @' $7 =: $5 [forget] $7 } { [forget] $5 } cond
|
|
@' $# 2- =: $# } if } if
|
|
def? $# { @' $# dup 4 < swap 5 > or ' usage if } if
|
|
|
|
"new-wallet" constant file-base
|
|
Basechain 0x13CB612A00A7C092C7DFD2EA45D603A9B54591BA4C88F71E707E009B879F0FB2 2constant dest_addr
|
|
0 constant seqno
|
|
GR$.666 constant amount
|
|
true constant bounce
|
|
|
|
def? $4 {
|
|
@' $1 =: file-base
|
|
@' $2 bounce parse-load-address =: bounce 2=: dest_addr
|
|
@' $3 parse-int =: seqno
|
|
@' $4 $>GR =: amount
|
|
} if
|
|
def? $5 { @' $5 } { "wallet-query" } cond constant savefile
|
|
|
|
file-base +".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 } { <b "TEST" $, b> } cond
|
|
constant body-cell
|
|
|
|
."Transferring " amount .GR ."to account "
|
|
dest_addr 2dup bounce 7 + .Addr ." = " .addr
|
|
."seqno=0x" seqno x. ."bounce=" bounce . cr
|
|
."Body of transfer message is " body-cell <s csr. cr
|
|
|
|
// create a message
|
|
<b b{01} s, bounce 1 i, b{000100} s, dest_addr addr, amount Gram, 0 9 64 32 + + 1+ u,
|
|
body-cell <s 2dup s-fits? not rot over 1 i, -rot { drop body-cell ref, } { s, } cond
|
|
b>
|
|
<b seqno 32 u, 1 8 u, swap ref, b>
|
|
dup ."signing message: " <s csr. cr
|
|
dup hash 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
|