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

Function json_peer_sigs

plugins/spender/openchannel.c:541–608  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

539}
540
541static struct command_result *json_peer_sigs(struct command *cmd,
542 const char *buf,
543 const jsmntok_t *params)
544{
545 struct channel_id cid;
546 const struct wally_psbt *psbt;
547 struct multifundchannel_destination *dest;
548 const char *err;
549
550 err = json_scan(tmpctx, buf, params,
551 "{openchannel_peer_sigs:"
552 "{channel_id:%,signed_psbt:%}}",
553 JSON_SCAN(json_to_channel_id, &cid),
554 JSON_SCAN_TAL(cmd, json_to_psbt, &psbt));
555 if (err)
556 plugin_err(cmd->plugin,
557 "`openchannel_peer_sigs` did not scan: %s. %.*s",
558 err, json_tok_full_len(params),
559 json_tok_full(buf, params));
560
561 /* Find the destination that's got this channel_id on it! */
562 dest = find_dest_by_channel_id(&cid);
563 if (!dest) {
564 /* if there's no pending destination... whatever */
565 plugin_log(cmd->plugin, LOG_DBG,
566 "mfc ??: `openchannel_peer_sigs` no "
567 "pending dest found for channel_id %s",
568 fmt_channel_id(tmpctx, &cid));
569 return notification_handled(cmd);
570 }
571
572 plugin_log(cmd->plugin, LOG_DBG,
573 "mfc %"PRIu64":`openchannel_peer_sigs` notice received for"
574 " channel %s",
575 dest->mfc->id,
576 tal_hexstr(tmpctx, &cid, sizeof(cid)));
577
578 /* Combine with the parent. Unknown map dupes are ignored,
579 * so the updated serial_id should persist on the parent */
580 tal_wally_start();
581 if (wally_psbt_combine(dest->mfc->psbt, psbt) != WALLY_OK)
582 plugin_err(cmd->plugin,
583 "mfc %"PRIu64": Unable to combine signed "
584 "PSBT with roll-up. "
585 "Signed %s, prev %s", dest->mfc->id,
586 fmt_wally_psbt(tmpctx, psbt),
587 fmt_wally_psbt(tmpctx, dest->mfc->psbt));
588
589 tal_wally_end(dest->mfc->psbt);
590
591 /* Bit of a race is possible here. If we're still waiting for
592 * their commitment sigs to come back, we'll be in
593 * "UPDATED" still. We check that SIGNED is hit before
594 * we mark ourselves as ready to send the sigs, so it's ok
595 * to relax this check */
596 if (dest->state != MULTIFUNDCHANNEL_SECURED)
597 dest->state = MULTIFUNDCHANNEL_SIGNED_NOT_SECURED;
598 else {

Callers

nothing calls this directly

Calls 13

find_dest_by_channel_idFunction · 0.85
tal_hexstrFunction · 0.85
tal_wally_startFunction · 0.85
fmt_wally_psbtFunction · 0.85
tal_wally_endFunction · 0.85
check_sigs_readyFunction · 0.85
json_scanFunction · 0.50
plugin_errFunction · 0.50
json_tok_full_lenFunction · 0.50
json_tok_fullFunction · 0.50
plugin_logFunction · 0.50
fmt_channel_idFunction · 0.50

Tested by

no test coverage detected