2019-10-03 21:54:25 +02:00
|
|
|
#!/usr/bin/env -S fift -s
|
|
|
|
"TonUtil.fif" include
|
|
|
|
|
|
|
|
{
|
2019-10-07 17:08:09 +02:00
|
|
|
."usage: " @' $0 type ." <filename-base> <key> <key-id> <dest-addr> <seqno> <amount> [-B <body-boc>] [<savefile>]" cr
|
2019-10-07 21:18:31 +02:00
|
|
|
."Creates a request to shared wallet created by wallet-create.fif, with private key <key-id> loaded from file <key>.pk "
|
2019-10-03 21:54:25 +02:00
|
|
|
."and address from <filename-base>.addr, and saves it into <savefile>.boc ('wallet-query.boc' by default)" cr 1 halt
|
|
|
|
} : usage
|
2019-10-07 17:08:09 +02:00
|
|
|
def? $8 { @' $7 "-B" $= { @' $8 =: body-boc-file [forget] $8 def? $9 { @' $9 =: $7 [forget] $9 } { [forget] $7 } cond
|
2019-10-03 21:54:25 +02:00
|
|
|
@' $# 2- =: $# } if } if
|
2019-10-07 21:18:31 +02:00
|
|
|
$# 6 < $# 9 > or ' usage if
|
2019-10-03 21:54:25 +02:00
|
|
|
true constant bounce
|
|
|
|
|
|
|
|
$1 =: file-base
|
2019-10-07 17:08:09 +02:00
|
|
|
$2 =: key
|
2019-10-07 21:18:31 +02:00
|
|
|
$3 parse-int =: key-id
|
2019-10-07 17:08:09 +02:00
|
|
|
$4 bounce parse-load-address =: bounce 2=: dest_addr
|
|
|
|
$5 parse-int =: seqno
|
|
|
|
$6 $>GR =: amount
|
|
|
|
def? $7 { @' $7 } { "wallet-query" } cond constant savefile
|
2019-10-03 21:54:25 +02:00
|
|
|
3 constant send-mode // mode for SENDRAWMSG: +1 - sender pays fees, +2 - ignore errors
|
2019-10-07 21:18:31 +02:00
|
|
|
3 86400 * constant timeout // external message expires in 3 days
|
2019-10-03 21:54:25 +02:00
|
|
|
|
|
|
|
file-base +".addr" load-address
|
2019-10-10 17:37:47 +02:00
|
|
|
2dup 2constant wallet-addr
|
2019-10-03 21:54:25 +02:00
|
|
|
."Source wallet address = " 2dup .addr cr 6 .Addr cr
|
2019-10-07 21:18:31 +02:00
|
|
|
key +".pk" load-keypair nip constant wallet_pk
|
2019-10-03 21:54:25 +02:00
|
|
|
|
|
|
|
def? body-boc-file { @' body-boc-file file>B B>boc } { <b 0 32 u, "TESTv2" $, 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>
|
2019-10-07 17:08:09 +02:00
|
|
|
// create wrapper message
|
2019-10-07 21:18:31 +02:00
|
|
|
// modeMessage$_ mode:uint8 body:^(Message X) = ModeMessage X;
|
|
|
|
// wrappedMessage$_ expires_at:uint32 seqno:uint32 body:(ModeMessage X) = WrappedMessage X;
|
2019-10-07 17:08:09 +02:00
|
|
|
<b now timeout + 32 u, seqno 32 u, send-mode 8 u, swap ref, b>
|
|
|
|
|
2019-10-03 21:54:25 +02:00
|
|
|
dup ."signing message: " <s csr. cr
|
2019-10-08 19:45:25 +02:00
|
|
|
dup hashu
|
|
|
|
dup ."Hash: " x. cr cr
|
|
|
|
wallet_pk ed25519_sign_uint
|
2019-10-07 17:08:09 +02:00
|
|
|
|
|
|
|
// signature$_ R:bits256 s:bits256 = Signature;
|
2019-10-07 21:18:31 +02:00
|
|
|
256 B>u@+ swap 256 B>u@ swap
|
|
|
|
<b swap 256 u, swap 256 u, b>
|
2019-10-07 17:08:09 +02:00
|
|
|
|
|
|
|
// key ID => signature
|
2019-10-07 21:18:31 +02:00
|
|
|
// multiSigWrapper$0 signatures:(HashmapE 4 Signature) message:(WrappedMessage X) = MultiSigWrapper X;
|
|
|
|
<b swap <s key-id dictnew 4 udict! not abort"Failure inserting signature!" dict, swap <s s, b>
|
2019-10-07 17:08:09 +02:00
|
|
|
|
2019-10-07 21:18:31 +02:00
|
|
|
//
|
|
|
|
// addr_none$00 = MsgAddressExt;
|
|
|
|
// addr_extern$01 len:(## 9) external_address:(bits len)
|
|
|
|
// = MsgAddressExt;
|
|
|
|
// anycast_info$_ depth:(#<= 30) { depth >= 1 }
|
|
|
|
// rewrite_pfx:(bits depth) = Anycast;
|
|
|
|
// addr_std$10 anycast:(Maybe Anycast)
|
|
|
|
// workchain_id:int8 address:bits256 = MsgAddressInt;
|
|
|
|
// addr_var$11 anycast:(Maybe Anycast) addr_len:(## 9)
|
|
|
|
// workchain_id:int32 address:(bits addr_len) = MsgAddressInt;
|
|
|
|
//
|
|
|
|
// ext_in_msg_info$10 src:MsgAddressExt dest:MsgAddressInt
|
|
|
|
// import_fee:Grams = CommonMsgInfo;
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// message$_ {X:Type} info:CommonMsgInfo
|
|
|
|
// init:(Maybe (Either StateInit ^StateInit))
|
|
|
|
// body:(Either X ^X) = Message X;
|
|
|
|
//
|
2019-10-10 17:37:47 +02:00
|
|
|
<b b{1000100} s, wallet-addr addr, 0 Gram, b{00} s,
|
2019-10-07 21:18:31 +02:00
|
|
|
swap <s s, b>
|
2019-10-07 17:08:09 +02:00
|
|
|
|
2019-10-03 21:54:25 +02:00
|
|
|
dup ."resulting external message: " <s csr. cr
|
|
|
|
2 boc+>B dup Bx. cr
|
|
|
|
savefile +".boc" tuck B>file
|
|
|
|
."Query expires in " timeout . ."seconds" cr
|
|
|
|
."(Saved to file " type .")" cr
|