| 80 | } |
| 81 | |
| 82 | static const char *last_time_check(const struct rune *rune, |
| 83 | struct cond_info *cinfo, |
| 84 | u64 n_sec) |
| 85 | { |
| 86 | u64 diff; |
| 87 | struct timeabs last_used; |
| 88 | |
| 89 | if (!wallet_get_rune(tmpctx, cinfo->runes->ld->wallet, atol(rune->unique_id), &last_used)) { |
| 90 | /* FIXME: If we do not know the rune, per does not work */ |
| 91 | return NULL; |
| 92 | } |
| 93 | if (time_before(cinfo->now, last_used)) { |
| 94 | last_used = cinfo->now; |
| 95 | } |
| 96 | |
| 97 | diff = time_to_nsec(time_between(cinfo->now, last_used)); |
| 98 | if (diff < n_sec) { |
| 99 | return "too soon"; |
| 100 | } |
| 101 | return NULL; |
| 102 | } |
| 103 | |
| 104 | static const char *per_time_check(const tal_t *ctx, |
| 105 | const struct runes *runes, |
no test coverage detected