| 1653 | } |
| 1654 | |
| 1655 | static bool |
| 1656 | peer_connected_hook_deserialize(struct peer_connected_hook_payload *payload, |
| 1657 | const char *buffer, |
| 1658 | const jsmntok_t *toks) |
| 1659 | { |
| 1660 | struct lightningd *ld = payload->ld; |
| 1661 | |
| 1662 | /* already rejected by prior plugin hook in the chain */ |
| 1663 | if (payload->error != NULL) |
| 1664 | return true; |
| 1665 | |
| 1666 | if (!toks || !buffer) |
| 1667 | return true; |
| 1668 | |
| 1669 | /* If we had a hook, interpret result. */ |
| 1670 | const jsmntok_t *t_res = json_get_member(buffer, toks, "result"); |
| 1671 | const jsmntok_t *t_err = json_get_member(buffer, toks, "error_message"); |
| 1672 | |
| 1673 | /* fail */ |
| 1674 | if (!t_res) |
| 1675 | fatal("Plugin returned an invalid response to the " |
| 1676 | "peer_connected hook: %s", buffer); |
| 1677 | |
| 1678 | /* reject */ |
| 1679 | if (json_tok_streq(buffer, t_res, "disconnect")) { |
| 1680 | payload->error = (u8*)""; |
| 1681 | if (t_err) { |
| 1682 | payload->error = towire_warningfmt(tmpctx, NULL, "%.*s", |
| 1683 | t_err->end - t_err->start, |
| 1684 | buffer + t_err->start); |
| 1685 | } |
| 1686 | log_debug(ld->log, "peer_connected hook rejects and says '%s'", |
| 1687 | payload->error); |
| 1688 | /* At this point we suppress other plugins in the chain and |
| 1689 | * directly move to final */ |
| 1690 | peer_connected_hook_final(payload); |
| 1691 | return false; |
| 1692 | } else if (!json_tok_streq(buffer, t_res, "continue")) |
| 1693 | fatal("Plugin returned an invalid response to the " |
| 1694 | "peer_connected hook: %s", buffer); |
| 1695 | |
| 1696 | /* call next hook */ |
| 1697 | return true; |
| 1698 | } |
| 1699 | |
| 1700 | /* Have they/we committed funds to the channel? */ |
| 1701 | static bool channel_state_relationship(enum channel_state state) |
nothing calls this directly
no test coverage detected