| 1633 | } |
| 1634 | |
| 1635 | static bool |
| 1636 | peer_connected_hook_deserialize(struct peer_connected_hook_payload *payload, |
| 1637 | const char *buffer, |
| 1638 | const jsmntok_t *toks) |
| 1639 | { |
| 1640 | struct lightningd *ld = payload->ld; |
| 1641 | |
| 1642 | /* already rejected by prior plugin hook in the chain */ |
| 1643 | if (payload->error != NULL) |
| 1644 | return true; |
| 1645 | |
| 1646 | if (!toks || !buffer) |
| 1647 | return true; |
| 1648 | |
| 1649 | /* If we had a hook, interpret result. */ |
| 1650 | const jsmntok_t *t_res = json_get_member(buffer, toks, "result"); |
| 1651 | const jsmntok_t *t_err = json_get_member(buffer, toks, "error_message"); |
| 1652 | |
| 1653 | /* fail */ |
| 1654 | if (!t_res) |
| 1655 | fatal("Plugin returned an invalid response to the " |
| 1656 | "peer_connected hook: %s", buffer); |
| 1657 | |
| 1658 | /* reject */ |
| 1659 | if (json_tok_streq(buffer, t_res, "disconnect")) { |
| 1660 | payload->error = (u8*)""; |
| 1661 | if (t_err) { |
| 1662 | payload->error = towire_warningfmt(tmpctx, NULL, "%.*s", |
| 1663 | t_err->end - t_err->start, |
| 1664 | buffer + t_err->start); |
| 1665 | } |
| 1666 | log_debug(ld->log, "peer_connected hook rejects and says '%s'", |
| 1667 | payload->error); |
| 1668 | /* At this point we suppress other plugins in the chain and |
| 1669 | * directly move to final */ |
| 1670 | peer_connected_hook_final(payload); |
| 1671 | return false; |
| 1672 | } else if (!json_tok_streq(buffer, t_res, "continue")) |
| 1673 | fatal("Plugin returned an invalid response to the " |
| 1674 | "peer_connected hook: %s", buffer); |
| 1675 | |
| 1676 | /* call next hook */ |
| 1677 | return true; |
| 1678 | } |
| 1679 | |
| 1680 | /* Have they/we committed funds to the channel? */ |
| 1681 | static bool channel_state_relationship(enum channel_state state) |
nothing calls this directly
no test coverage detected