| 1689 | } |
| 1690 | |
| 1691 | static struct command_result *json_recoverchannel(struct command *cmd, |
| 1692 | const char *buffer, |
| 1693 | const jsmntok_t *obj UNNEEDED, |
| 1694 | const jsmntok_t *params) |
| 1695 | { |
| 1696 | const jsmntok_t *scb, *t; |
| 1697 | size_t i; |
| 1698 | struct json_stream *response; |
| 1699 | struct modern_scb_chan *scb_chan = tal(cmd, struct modern_scb_chan); |
| 1700 | |
| 1701 | if (!param(cmd, buffer, params, |
| 1702 | p_req("scb", param_array, &scb), |
| 1703 | NULL)) |
| 1704 | return command_param_failed(); |
| 1705 | |
| 1706 | response = json_stream_success(cmd); |
| 1707 | |
| 1708 | json_array_start(response, "stubs"); |
| 1709 | json_for_each_arr(i,t,scb){ |
| 1710 | |
| 1711 | char *token = json_strdup(tmpctx, buffer, t); |
| 1712 | const u8 *scb_arr = tal_hexdata(cmd, token, strlen(token)); |
| 1713 | size_t scblen = tal_count(scb_arr); |
| 1714 | struct shachain chain; |
| 1715 | struct basepoints basepoints; |
| 1716 | struct pubkey _localfundingpubkey; |
| 1717 | enum side opener = LOCAL; |
| 1718 | u16 remote_to_self_delay = 0; |
| 1719 | |
| 1720 | scb_chan = fromwire_modern_scb_chan(cmd, &scb_arr, &scblen); |
| 1721 | |
| 1722 | if (scb_chan == NULL) { |
| 1723 | log_broken(cmd->ld->log, "SCB is invalid!"); |
| 1724 | continue; |
| 1725 | } |
| 1726 | |
| 1727 | if (scb_chan->tlvs != NULL) { |
| 1728 | if (scb_chan->tlvs->shachain == NULL) { |
| 1729 | shachain_init(&chain); |
| 1730 | } else { |
| 1731 | chain = *scb_chan->tlvs->shachain; |
| 1732 | } |
| 1733 | |
| 1734 | if (scb_chan->tlvs->basepoints == NULL) { |
| 1735 | get_channel_basepoints(cmd->ld, |
| 1736 | &scb_chan->node_id, |
| 1737 | scb_chan->id, |
| 1738 | &basepoints, |
| 1739 | &_localfundingpubkey); |
| 1740 | } else { |
| 1741 | basepoints = *scb_chan->tlvs->basepoints; |
| 1742 | } |
| 1743 | |
| 1744 | if (scb_chan->tlvs->opener != NULL) |
| 1745 | opener = *scb_chan->tlvs->opener; |
| 1746 | |
| 1747 | if (scb_chan->tlvs->remote_to_self_delay != NULL) |
| 1748 | remote_to_self_delay = *scb_chan->tlvs->remote_to_self_delay; |
nothing calls this directly
no test coverage detected