mirror of
https://github.com/danog/toncontest.git
synced 2024-11-26 12:04:50 +01:00
Update
This commit is contained in:
parent
0be80c0b45
commit
7b9d2c8120
@ -44,7 +44,9 @@ b>
|
||||
<b now timeout + 32 u, seqno 32 u, send-mode 8 u, swap ref, b>
|
||||
|
||||
dup ."signing message: " <s csr. cr
|
||||
dup hash wallet_pk ed25519_sign_uint
|
||||
dup hashu
|
||||
dup ."Hash: " x. cr cr
|
||||
wallet_pk ed25519_sign_uint
|
||||
|
||||
// signature$_ R:bits256 s:bits256 = Signature;
|
||||
256 B>u@+ swap 256 B>u@ swap
|
||||
|
@ -7,8 +7,9 @@
|
||||
$# 1 < ' usage if
|
||||
|
||||
$1 +".pk" load-generate-keypair drop
|
||||
$1 +".pubkey" B>file
|
||||
dup $1 +".pubkey" B>file
|
||||
|
||||
|
||||
."Wrote private key to " $1 +".pk" type cr
|
||||
."Wrote public key to " $1 +".pubkey" type cr
|
||||
."Wrote public key to " $1 +".pubkey" type cr cr
|
||||
."Public key: " Bx. cr cr
|
115
wallet/inspect-lib.fif
Normal file
115
wallet/inspect-lib.fif
Normal file
@ -0,0 +1,115 @@
|
||||
"TonUtil.fif" include
|
||||
|
||||
// Inspects contents of cell provided on top of the stack
|
||||
|
||||
// Assuming the same external structure created by create.fif (simple external message)
|
||||
//
|
||||
// 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;
|
||||
//
|
||||
// <b b{1000100} s, wallet_addr addr, 0 Gram, b{00} s,
|
||||
// swap <s s, b>
|
||||
// (external message)
|
||||
//
|
||||
{ hole dup 1 ' @ does create 1 ' ! does create } : variable-set
|
||||
{ hole hole 2dup 2 { @ swap @ swap } does create 2 { rot swap ! ! } does create } : 2variable-set
|
||||
2variable-set wallet_addr wallet_addr!
|
||||
variable-set message-hash message-hash!
|
||||
|
||||
<s dup csr. cr
|
||||
// External message
|
||||
7 u@+ swap 68 <> { ."There seems to be an invalid header" cr } if // 1000100 => 68
|
||||
|
||||
8 i@+
|
||||
256 u@+ -rot
|
||||
2dup wallet_addr!
|
||||
."Wallet address: " .addr cr
|
||||
|
||||
Gram@+ nip // Ignore grams
|
||||
|
||||
1 u@+ swap
|
||||
abort"This seems to be an init message"
|
||||
|
||||
// multiSigWrapper$0 signatures:(HashmapE 4 Signature) message:(WrappedMessage X) = MultiSigWrapper X;
|
||||
1 u@+ swap
|
||||
dup ."Message version: " . cr
|
||||
abort"Unsupported message version!"
|
||||
|
||||
dict@+ swap
|
||||
dup null? abort"Empty signature list!"
|
||||
|
||||
."Signed by the following keys: "
|
||||
4 { drop . ."- " -1 } dictforeach cr drop
|
||||
|
||||
."Hash: " dup shash dup Bx. cr
|
||||
message-hash!
|
||||
|
||||
// modeMessage$_ mode:uint8 body:^(Message X) = ModeMessage X;
|
||||
// wrappedMessage$_ expires_at:uint32 seqno:uint32 body:(ModeMessage X) = WrappedMessage X;
|
||||
|
||||
32 u@+ swap
|
||||
dup ."Expires: " .
|
||||
dup now < { ."(already EXPIRED!)" drop } { ."(in " now - . ."seconds)" } cond cr
|
||||
|
||||
32 u@+ swap
|
||||
."Seqno: " . cr
|
||||
|
||||
8 u@+ swap
|
||||
."Mode: " . cr
|
||||
|
||||
// Now on to the actual message we're agreeing to sign
|
||||
//
|
||||
// int_msg_info$0 ihr_disabled:Bool bounce:Bool bounced:Bool
|
||||
// src:MsgAddressInt dest:MsgAddressInt
|
||||
// value:CurrencyCollection ihr_fee:Grams fwd_fee:Grams
|
||||
// created_lt:uint64 created_at:uint32 = CommonMsgInfo;
|
||||
// ext_in_msg_info$10 src:MsgAddressExt dest:MsgAddressInt
|
||||
// import_fee:Grams = CommonMsgInfo;
|
||||
// ext_out_msg_info$11 src:MsgAddressInt dest:MsgAddressExt
|
||||
// created_lt:uint64 created_at:uint32 = CommonMsgInfo;
|
||||
."=>" cr ref@ <s
|
||||
|
||||
1 u@+ swap
|
||||
{ // Extcr ernal message
|
||||
."Inside: external message" cr
|
||||
}
|
||||
{ // Internal message
|
||||
."Inside: internal message" cr
|
||||
1 u@+ swap
|
||||
."Instant hypercube routing disabled? " . cr
|
||||
|
||||
1 u@+ swap
|
||||
."Bounce flag set? " . cr
|
||||
|
||||
1 u@+ swap
|
||||
// ."Bounced flag set? " . cr
|
||||
drop
|
||||
|
||||
2 u@+ nip // Drop src address constructor + flags
|
||||
|
||||
3 u@+ swap
|
||||
4 <> abort"Unsupported address!" // Make things simple for now
|
||||
|
||||
8 i@+
|
||||
256 u@+ -rot
|
||||
."Destination address: " .addr cr
|
||||
|
||||
Gram@+ swap
|
||||
."Grams: " .GR cr
|
||||
} cond
|
||||
drop
|
@ -1,119 +1,11 @@
|
||||
"TonUtil.fif" include
|
||||
|
||||
{ dup ."Inspecting order from file " type ."..." cr
|
||||
file>B B>boc
|
||||
} : inspect-load-boc
|
||||
{
|
||||
."usage: " @' $0 type ." <input>" cr
|
||||
."Inspects contents of multisig <input>.boc file." cr 1 halt
|
||||
} : usage
|
||||
$# 1 < ' usage if
|
||||
$1 +".boc"
|
||||
|
||||
"inspect-this" (def?) not {
|
||||
$# 1 < ' usage if
|
||||
$1 =: inspect-this
|
||||
} if
|
||||
dup ."Inspecting order from file " type ."..." cr
|
||||
file>B B>boc
|
||||
|
||||
|
||||
// Assuming the same external structure created by create.fif (simple external message)
|
||||
//
|
||||
// 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;
|
||||
//
|
||||
// <b b{1000100} s, wallet_addr addr, 0 Gram, b{00} s,
|
||||
// swap <s s, b>
|
||||
// (external message)
|
||||
//
|
||||
inspect-this +".boc" inspect-load-boc
|
||||
<s dup csr. cr
|
||||
// External message
|
||||
7 u@+ swap 68 <> { ."There seems to be an invalid header" cr } if // 1000100 => 68
|
||||
|
||||
8 i@+
|
||||
256 u@+ -rot
|
||||
2dup 2constant wallet_addr
|
||||
."Wallet address: " .addr cr
|
||||
|
||||
Gram@+ nip // Ignore grams
|
||||
|
||||
1 u@+ swap
|
||||
abort"This seems to be an init message"
|
||||
|
||||
// multiSigWrapper$0 signatures:(HashmapE 4 Signature) message:(WrappedMessage X) = MultiSigWrapper X;
|
||||
1 u@+ swap
|
||||
dup ."Message version: " . cr
|
||||
abort"Unsupported message version!"
|
||||
|
||||
dict@+ swap
|
||||
dup null? abort"Empty signature list!"
|
||||
|
||||
."Signed by the following keys: "
|
||||
4 { drop . ."- " -1 } dictforeach cr drop
|
||||
|
||||
// modeMessage$_ mode:uint8 body:^(Message X) = ModeMessage X;
|
||||
// wrappedMessage$_ expires_at:uint32 seqno:uint32 body:(ModeMessage X) = WrappedMessage X;
|
||||
|
||||
32 u@+ swap
|
||||
dup ."Expires: " .
|
||||
dup now < { ."(already EXPIRED!)" drop } { ."(in " now - . ."seconds)" } cond cr
|
||||
|
||||
32 u@+ swap
|
||||
."Seqno: " . cr
|
||||
|
||||
8 u@+ swap
|
||||
."Mode: " . cr
|
||||
|
||||
// Now on to the actual message we're agreeing to sign
|
||||
//
|
||||
// int_msg_info$0 ihr_disabled:Bool bounce:Bool bounced:Bool
|
||||
// src:MsgAddressInt dest:MsgAddressInt
|
||||
// value:CurrencyCollection ihr_fee:Grams fwd_fee:Grams
|
||||
// created_lt:uint64 created_at:uint32 = CommonMsgInfo;
|
||||
// ext_in_msg_info$10 src:MsgAddressExt dest:MsgAddressInt
|
||||
// import_fee:Grams = CommonMsgInfo;
|
||||
// ext_out_msg_info$11 src:MsgAddressInt dest:MsgAddressExt
|
||||
// created_lt:uint64 created_at:uint32 = CommonMsgInfo;
|
||||
cr ref@ <s
|
||||
|
||||
1 u@+ swap
|
||||
{ // External message
|
||||
."Inside: external message" cr
|
||||
}
|
||||
{ // Internal message
|
||||
."Inside: internal message" cr
|
||||
1 u@+ swap
|
||||
."Instant hypercube routing disabled? " . cr
|
||||
|
||||
1 u@+ swap
|
||||
."Bounce flag set? " . cr
|
||||
|
||||
1 u@+ swap
|
||||
."Bounced flag set? " . cr
|
||||
|
||||
2 u@+ nip // Drop src address constructor + flags
|
||||
|
||||
3 u@+ swap
|
||||
4 <> abort"Unsupported address!" // Make things simple for now
|
||||
|
||||
8 i@+
|
||||
256 u@+ -rot
|
||||
."Destination address: " .addr cr
|
||||
|
||||
Gram@+ swap
|
||||
."Grams: " .GR cr
|
||||
} cond
|
||||
drop
|
||||
"inspect-lib.fif" include
|
@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env -S fift -s
|
||||
"TonUtil.fif" include
|
||||
|
||||
' constant : const
|
||||
{ dup ."Loading order from file " type ."..." cr
|
||||
file>B B>boc
|
||||
} : load-boc
|
||||
{
|
||||
."usage: " @' $0 type ." <input1> <input2> [<input3> ...] <output>" cr
|
||||
."Merges multisig <inputx>.boc files and writes result to <output>.boc" cr 1 halt
|
||||
} : usage
|
||||
$# 3 < ' usage if
|
||||
|
||||
$# 1 - const input-len
|
||||
1 { dup $() +".boc" swap 1+ } input-len times drop
|
||||
input-len tuple const input-files
|
||||
|
||||
$# $() +".boc" const output-file
|
||||
|
||||
."Inspecting and merging " input-len . ."files..." cr
|
||||
input-files explode 1- swap
|
||||
|
||||
load-boc
|
||||
dup "inspect-lib.fif" include cr
|
||||
message-hash const previous-hash
|
||||
<s
|
||||
// External message
|
||||
7 u@+ nip
|
||||
8 i@+ nip
|
||||
256 u@+ nip
|
||||
Gram@+ nip
|
||||
2 u@+ nip
|
||||
|
||||
// multiSigWrapper$0 signatures:(HashmapE 4 Signature) message:(WrappedMessage X) = MultiSigWrapper X;
|
||||
dict@+
|
||||
s>c const wrapped-message // Store message in const
|
||||
swap // put length on top, signatures right underneath
|
||||
|
||||
{ swap // Get filename, signatures right underneath
|
||||
load-boc
|
||||
dup "inspect-lib.fif" include cr
|
||||
message-hash previous-hash B= not abort"Hash mismatch!"
|
||||
<s
|
||||
// External message
|
||||
7 u@+ nip
|
||||
8 i@+ nip
|
||||
256 u@+ nip
|
||||
Gram@+ nip
|
||||
2 u@+ nip
|
||||
|
||||
// multiSigWrapper$0 signatures:(HashmapE 4 Signature) message:(WrappedMessage X) = MultiSigWrapper X;
|
||||
dict@
|
||||
4 { drop s, -1 } dictmerge
|
||||
} swap times
|
||||
|
||||
// Signatures are the only element on the stack
|
||||
."Fianl message signed by the following keys: "
|
||||
dup 4 { drop . ."- " -1 } dictforeach cr drop
|
||||
|
||||
<b 68 7 u, wallet_addr addr, 0 Gram, 0 2 u, swap dict, wrapped-message <s s, b>
|
||||
|
||||
2 boc+>B dup Bx. cr
|
||||
output-file tuck B>file
|
||||
."Saved new multisigned message to file " type cr
|
@ -15,12 +15,10 @@ $2 =: output-file
|
||||
$3 =: key
|
||||
$4 parse-int =: key-id
|
||||
|
||||
input-file constant inspect-this
|
||||
"inspect.fif" include cr
|
||||
|
||||
input-file +".boc" load-boc constant order
|
||||
key +".pk" load-keypair nip constant wallet_pk
|
||||
|
||||
order "inspect-lib.fif" include cr
|
||||
|
||||
order <s
|
||||
// External message
|
||||
|
4
wallet/test.fif
Normal file
4
wallet/test.fif
Normal file
@ -0,0 +1,4 @@
|
||||
0 variable x
|
||||
1 variable y
|
||||
|
||||
.s
|
@ -260,4 +260,7 @@ int seqno() method_id {
|
||||
return new_dict();
|
||||
}
|
||||
return getPartialsById(id);
|
||||
}
|
||||
(cell) getPartialsByHash(int hash) method_id {
|
||||
return get_data().begin_parse().skip_bits(36).skip_keys().preload_dict().udict_get_ref(256, hash);
|
||||
}
|
Loading…
Reference in New Issue
Block a user