| 1593 | } |
| 1594 | |
| 1595 | static bool |
| 1596 | peer_connected_hook_deserialize(struct peer_connected_hook_payload *payload, |
| 1597 | const char *buffer, |
| 1598 | const jsmntok_t *toks) |
| 1599 | { |
| 1600 | struct lightningd *ld = payload->ld; |
| 1601 | |
| 1602 | /* already rejected by prior plugin hook in the chain */ |
| 1603 | if (payload->error != NULL) |
| 1604 | return true; |
| 1605 | |
| 1606 | if (!toks || !buffer) |
| 1607 | return true; |
| 1608 | |
| 1609 | /* If we had a hook, interpret result. */ |
| 1610 | const jsmntok_t *t_res = json_get_member(buffer, toks, "result"); |
| 1611 | const jsmntok_t *t_err = json_get_member(buffer, toks, "error_message"); |
| 1612 | |
| 1613 | /* fail */ |
| 1614 | if (!t_res) |
| 1615 | fatal("Plugin returned an invalid response to the " |
| 1616 | "peer_connected hook: %s", buffer); |
| 1617 | |
| 1618 | /* reject */ |
| 1619 | if (json_tok_streq(buffer, t_res, "disconnect")) { |
| 1620 | payload->error = (u8*)""; |
| 1621 | if (t_err) { |
| 1622 | payload->error = towire_warningfmt(tmpctx, NULL, "%.*s", |
| 1623 | t_err->end - t_err->start, |
| 1624 | buffer + t_err->start); |
| 1625 | } |
| 1626 | log_debug(ld->log, "peer_connected hook rejects and says '%s'", |
| 1627 | payload->error); |
| 1628 | /* At this point we suppress other plugins in the chain and |
| 1629 | * directly move to final */ |
| 1630 | peer_connected_hook_final(payload); |
| 1631 | return false; |
| 1632 | } else if (!json_tok_streq(buffer, t_res, "continue")) |
| 1633 | fatal("Plugin returned an invalid response to the " |
| 1634 | "peer_connected hook: %s", buffer); |
| 1635 | |
| 1636 | /* call next hook */ |
| 1637 | return true; |
| 1638 | } |
| 1639 | |
| 1640 | /* Have they/we committed funds to the channel? */ |
| 1641 | static bool channel_state_relationship(enum channel_state state) |
nothing calls this directly
no test coverage detected