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

Function openchannel_init_ok

plugins/spender/openchannel.c:896–964  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

894}
895
896static struct command_result *
897openchannel_init_ok(struct command *cmd,
898 const char *buf,
899 const jsmntok_t *result,
900 struct multifundchannel_destination *dest)
901{
902 struct multifundchannel_command *mfc = dest->mfc;
903 const jsmntok_t *psbt_tok;
904 const jsmntok_t *channel_id_tok;
905 const jsmntok_t *funding_serial_tok;
906
907 plugin_log(mfc->cmd->plugin, LOG_DBG,
908 "mfc %"PRIu64", dest %u: openchannel_init %s done.",
909 mfc->id, dest->index,
910 node_id_to_hexstr(tmpctx, &dest->id));
911
912 /* We've got the PSBT and channel_id here */
913 psbt_tok = json_get_member(buf, result, "psbt");
914 if (!psbt_tok)
915 plugin_err(cmd->plugin,
916 "openchannel_init did not return "
917 "'psbt': %.*s",
918 json_tok_full_len(result),
919 json_tok_full(buf, result));
920 dest->updated_psbt = json_to_psbt(dest->mfc, buf, psbt_tok);
921 if (!dest->updated_psbt)
922 plugin_err(cmd->plugin,
923 "openchannel_init returned invalid "
924 "'psbt': %.*s",
925 json_tok_full_len(result),
926 json_tok_full(buf, result));
927
928 channel_id_tok = json_get_member(buf, result, "channel_id");
929 if (!channel_id_tok)
930 plugin_err(cmd->plugin,
931 "openchannel_init did not return "
932 "'channel_id': %.*s",
933 json_tok_full_len(result),
934 json_tok_full(buf, result));
935 json_to_channel_id(buf, channel_id_tok, &dest->channel_id);
936
937 funding_serial_tok = json_get_member(buf, result,
938 "funding_serial");
939 if (!funding_serial_tok)
940 plugin_err(cmd->plugin,
941 "openchannel_init did not return "
942 "'funding_serial': %.*s",
943 json_tok_full_len(result),
944 json_tok_full(buf, result));
945 json_to_u64(buf, funding_serial_tok, &dest->funding_serial);
946
947 dest->state = MULTIFUNDCHANNEL_STARTED;
948
949 /* Port any updates onto 'parent' PSBT */
950 if (!update_parent_psbt(dest->mfc, dest, dest->psbt,
951 dest->updated_psbt, &mfc->psbt)) {
952 fail_destination_msg(dest, FUNDING_PSBT_INVALID,
953 "Unable to update parent"

Callers

nothing calls this directly

Calls 13

json_to_psbtFunction · 0.85
update_parent_psbtFunction · 0.85
fail_destination_msgFunction · 0.85
tal_wally_startFunction · 0.85
openchannel_init_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_to_channel_idFunction · 0.50

Tested by

no test coverage detected