| 25 | #endif |
| 26 | |
| 27 | static bool state_update_ok(struct channel *channel, |
| 28 | enum htlc_state oldstate, enum htlc_state newstate, |
| 29 | u64 htlc_id, const char *dir) |
| 30 | { |
| 31 | enum htlc_state expected = oldstate + 1; |
| 32 | |
| 33 | /* We never get told about RCVD_REMOVE_HTLC, so skip over that |
| 34 | * (we initialize in SENT_ADD_HTLC / RCVD_ADD_COMMIT, so those |
| 35 | * work). */ |
| 36 | if (expected == RCVD_REMOVE_HTLC) |
| 37 | expected = RCVD_REMOVE_COMMIT; |
| 38 | |
| 39 | if (newstate != expected) { |
| 40 | channel_internal_error(channel, |
| 41 | "HTLC %s %"PRIu64" invalid update %s->%s", |
| 42 | dir, htlc_id, |
| 43 | htlc_state_name(oldstate), |
| 44 | htlc_state_name(newstate)); |
| 45 | return false; |
| 46 | } |
| 47 | |
| 48 | log_debug(channel->log, "HTLC %s %"PRIu64" %s->%s", |
| 49 | dir, htlc_id, |
| 50 | htlc_state_name(oldstate), htlc_state_name(newstate)); |
| 51 | return true; |
| 52 | } |
| 53 | |
| 54 | static bool htlc_in_update_state(struct channel *channel, |
| 55 | struct htlc_in *hin, |
no test coverage detected