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

Function openchannel_update_ok

plugins/spender/openchannel.c:674–766  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

672}
673
674static struct command_result *
675openchannel_update_ok(struct command *cmd,
676 const char *method,
677 const char *buf,
678 const jsmntok_t *result,
679 struct multifundchannel_destination *dest)
680{
681 struct multifundchannel_command *mfc = dest->mfc;
682 const jsmntok_t *psbt_tok, *done_tok;
683 bool done;
684
685 plugin_log(mfc->cmd->plugin, LOG_DBG,
686 "mfc %"PRIu64", dest %u: openchannel_update %s returned.",
687 mfc->id, dest->index,
688 fmt_node_id(tmpctx, &dest->id));
689
690 assert(!dest->updated_psbt);
691 psbt_tok = json_get_member(buf, result, "psbt");
692 if (!psbt_tok)
693 plugin_err(cmd->plugin,
694 "`openchannel_update` did not return "
695 "'psbt': %.*s",
696 json_tok_full_len(result),
697 json_tok_full(buf, result));
698
699 dest->updated_psbt = json_to_psbt(dest->mfc, buf, psbt_tok);
700 if (!dest->updated_psbt)
701 plugin_err(cmd->plugin,
702 "`openchannel_update` returned invalid "
703 "'psbt': %.*s",
704 json_tok_full_len(result),
705 json_tok_full(buf, result));
706
707 /* FIXME: check that the channel id is correct? */
708 done_tok = json_get_member(buf, result, "commitments_secured");
709 if (!done_tok)
710 plugin_err(cmd->plugin,
711 "`openchannel_update` failed to return "
712 "'commitments_secured': %.*s",
713 json_tok_full_len(result),
714 json_tok_full(buf, result));
715
716 if (!json_to_bool(buf, done_tok, &done))
717 plugin_err(cmd->plugin,
718 "`openchannel_update` returned invalid "
719 "'commitments_secured': %.*s",
720 json_tok_full_len(result),
721 json_tok_full(buf, result));
722
723 /* We loop through here several times. We may
724 * reach an intermediate state however,
725 * MULTIFUNDCHANNEL_SIGNED_NOT_SECURED, so we only update
726 * to UPDATED iff we're at the previous state (STARTED) */
727 if (dest->state == MULTIFUNDCHANNEL_STARTED)
728 dest->state = MULTIFUNDCHANNEL_UPDATED;
729
730 if (done) {
731 const jsmntok_t *outnum_tok, *close_to_tok;

Callers

nothing calls this directly

Calls 11

fmt_node_idFunction · 0.85
json_get_memberFunction · 0.85
json_to_psbtFunction · 0.85
plugin_logFunction · 0.50
plugin_errFunction · 0.50
json_tok_full_lenFunction · 0.50
json_tok_fullFunction · 0.50
json_to_boolFunction · 0.50
json_to_numberFunction · 0.50
json_tok_bin_from_hexFunction · 0.50

Tested by

no test coverage detected