mirror of
https://github.com/danog/ton.git
synced 2024-11-26 20:14:55 +01:00
fd7a8de970
- upated tonlib - fixed bug in message routing
32 lines
933 B
Plaintext
32 lines
933 B
Plaintext
;; Simple wallet smart contract
|
|
|
|
() recv_internal(slice in_msg) impure {
|
|
;; do nothing for internal messages
|
|
}
|
|
|
|
() recv_external(slice in_msg) impure {
|
|
var signature = in_msg~load_bits(512);
|
|
var cs = in_msg;
|
|
var (msg_seqno, valid_until) = (cs~load_uint(32), cs~load_uint(32));
|
|
throw_if(35, valid_until <= now());
|
|
var ds = get_data().begin_parse();
|
|
var (stored_seqno, public_key) = (ds~load_uint(32), ds~load_uint(256));
|
|
ds.end_parse();
|
|
throw_unless(33, msg_seqno == stored_seqno);
|
|
throw_unless(34, check_signature(slice_hash(in_msg), signature, public_key));
|
|
accept_message();
|
|
cs~touch();
|
|
while (cs.slice_refs()) {
|
|
var mode = cs~load_uint(8);
|
|
send_raw_message(cs~load_ref(), mode);
|
|
}
|
|
cs.end_parse();
|
|
set_data(begin_cell().store_uint(stored_seqno + 1, 32).store_uint(public_key, 256).end_cell());
|
|
}
|
|
|
|
;; Get methods
|
|
|
|
int seqno() method_id {
|
|
return get_data().begin_parse().preload_uint(32);
|
|
}
|