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

Function openchannel_init_ok

plugins/spender/openchannel.c:907–955  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

905}
906
907static struct command_result *
908openchannel_init_ok(struct command *cmd,
909 const char *method,
910 const char *buf,
911 const jsmntok_t *result,
912 struct multifundchannel_destination *dest)
913{
914 struct multifundchannel_command *mfc = dest->mfc;
915 const char *err;
916
917 plugin_log(mfc->cmd->plugin, LOG_DBG,
918 "mfc %"PRIu64", dest %u: openchannel_init %s done.",
919 mfc->id, dest->index,
920 fmt_node_id(tmpctx, &dest->id));
921
922 err = json_scan(mfc, buf, result,
923 "{psbt:%,"
924 "channel_id:%,"
925 "funding_serial:%,"
926 "channel_type:{bits:%}}",
927 JSON_SCAN_TAL(mfc, json_to_psbt, &dest->updated_psbt),
928 JSON_SCAN(json_to_channel_id, &dest->channel_id),
929 JSON_SCAN(json_to_u64, &dest->funding_serial),
930 JSON_SCAN_TAL(mfc, json_bits_to_channel_type, &dest->channel_type));
931 if (err) {
932 plugin_err(cmd->plugin,
933 "openchannel_init bad return %.*s: %s",
934 json_tok_full_len(result),
935 json_tok_full(buf, result), err);
936 }
937
938 dest->state = MULTIFUNDCHANNEL_STARTED;
939
940 /* Port any updates onto 'parent' PSBT */
941 if (!update_parent_psbt(dest->mfc, dest, dest->psbt,
942 dest->updated_psbt, &mfc->psbt)) {
943 fail_destination_msg(dest, FUNDING_PSBT_INVALID,
944 "Unable to update parent"
945 " with node's PSBT");
946 }
947
948 /* Clone updated-psbt to psbt, so original changeset
949 * will be empty, but tallocate it so we can leave tal_free
950 * logic in `perform_openchannel_update` the same. */
951 tal_wally_start();
952 wally_psbt_clone_alloc(dest->updated_psbt, 0, &dest->psbt);
953 tal_wally_end_onto(mfc, dest->updated_psbt, struct wally_psbt);
954 return openchannel_init_done(dest);
955}
956
957static struct command_result *
958openchannel_init_err(struct command *cmd,

Callers

nothing calls this directly

Calls 10

fmt_node_idFunction · 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
json_scanFunction · 0.50
plugin_errFunction · 0.50
json_tok_full_lenFunction · 0.50
json_tok_fullFunction · 0.50

Tested by

no test coverage detected