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

Function fundchannel_start_ok

plugins/spender/multifundchannel.c:1004–1059  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1002}
1003
1004static struct command_result *
1005fundchannel_start_ok(struct command *cmd,
1006 const char *buf,
1007 const jsmntok_t *result,
1008 struct multifundchannel_destination *dest)
1009{
1010 struct multifundchannel_command *mfc = dest->mfc;
1011 const jsmntok_t *address_tok;
1012 const jsmntok_t *script_tok;
1013 const jsmntok_t *close_to_tok;
1014
1015 plugin_log(mfc->cmd->plugin, LOG_DBG,
1016 "mfc %"PRIu64", dest %u: fundchannel_start %s done.",
1017 mfc->id, dest->index,
1018 node_id_to_hexstr(tmpctx, &dest->id));
1019
1020 /* Extract funding_address. */
1021 address_tok = json_get_member(buf, result, "funding_address");
1022 if (!address_tok)
1023 plugin_err(cmd->plugin,
1024 "fundchannel_start did not "
1025 "return 'funding_address': %.*s",
1026 json_tok_full_len(result),
1027 json_tok_full(buf, result));
1028 dest->funding_addr = json_strdup(dest->mfc, buf, address_tok);
1029 /* Extract scriptpubkey. */
1030 script_tok = json_get_member(buf, result, "scriptpubkey");
1031 if (!script_tok)
1032 plugin_err(cmd->plugin,
1033 "fundchannel_start did not "
1034 "return 'scriptpubkey': %.*s",
1035 json_tok_full_len(result),
1036 json_tok_full(buf, result));
1037 dest->funding_script = json_tok_bin_from_hex(dest->mfc,
1038 buf, script_tok);
1039 if (!dest->funding_script)
1040 plugin_err(cmd->plugin,
1041 "fundchannel_start did not "
1042 "return parseable 'scriptpubkey': %.*s",
1043 json_tok_full_len(script_tok),
1044 json_tok_full(buf, script_tok));
1045
1046 close_to_tok = json_get_member(buf, result, "close_to");
1047 /* Only returned if a) we requested and b) peer supports
1048 * opt_upfront_shutdownscript */
1049 if (close_to_tok) {
1050 dest->close_to_script =
1051 json_tok_bin_from_hex(dest->mfc, buf, close_to_tok);
1052 } else
1053 dest->close_to_script = NULL;
1054
1055
1056 dest->state = MULTIFUNDCHANNEL_STARTED;
1057
1058 return fundchannel_start_done(dest);
1059}
1060
1061static struct command_result *

Callers

nothing calls this directly

Calls 9

fundchannel_start_doneFunction · 0.85
plugin_logFunction · 0.50
node_id_to_hexstrFunction · 0.50
json_get_memberFunction · 0.50
plugin_errFunction · 0.50
json_tok_full_lenFunction · 0.50
json_tok_fullFunction · 0.50
json_strdupFunction · 0.50
json_tok_bin_from_hexFunction · 0.50

Tested by

no test coverage detected