MCPcopy Create free account
hub / github.com/ElementsProject/lightning / json_recoverchannel

Function json_recoverchannel

lightningd/opening_control.c:1691–1792  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1689}
1690
1691static 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;

Callers

nothing calls this directly

Calls 15

json_array_startFunction · 0.85
tal_hexdataFunction · 0.85
shachain_initFunction · 0.85
stub_chanFunction · 0.85
wallet_channel_insertFunction · 0.85
channel_watch_fundingFunction · 0.85
json_add_channel_idFunction · 0.85
json_array_endFunction · 0.85
command_param_failedFunction · 0.70
json_stream_successFunction · 0.70
get_channel_basepointsFunction · 0.70
setup_peersFunction · 0.70

Tested by

no test coverage detected