2019-09-07 12:03:22 +02:00
|
|
|
;; 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;
|
2019-09-08 18:29:51 +02:00
|
|
|
var (msg_seqno, valid_until) = (cs~load_uint(32), cs~load_uint(32));
|
2019-09-28 09:44:38 +02:00
|
|
|
throw_if(35, valid_until <= now());
|
2019-09-08 18:29:51 +02:00
|
|
|
var ds = get_data().begin_parse();
|
|
|
|
var (stored_seqno, public_key) = (ds~load_uint(32), ds~load_uint(256));
|
|
|
|
ds.end_parse();
|
2019-09-07 12:03:22 +02:00
|
|
|
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());
|
|
|
|
}
|
2019-09-08 18:29:51 +02:00
|
|
|
|
|
|
|
;; Get methods
|
|
|
|
|
|
|
|
int seqno() method_id {
|
|
|
|
return get_data().begin_parse().preload_uint(32);
|
|
|
|
}
|