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

Function json_openchannel_signed

lightningd/dual_open_control.c:2680–2803  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2678}
2679
2680static struct command_result *
2681json_openchannel_signed(struct command *cmd,
2682 const char *buffer,
2683 const jsmntok_t *obj UNNEEDED,
2684 const jsmntok_t *params)
2685{
2686 struct wally_psbt *psbt;
2687 struct channel_id *cid;
2688 struct channel *channel;
2689 struct bitcoin_txid txid;
2690 struct channel_inflight *inflight;
2691
2692 if (!param_check(cmd, buffer, params,
2693 p_req("channel_id", param_channel_id, &cid),
2694 p_req("signed_psbt", param_psbt, &psbt),
2695 NULL))
2696 return command_param_failed();
2697
2698 channel = channel_by_cid(cmd->ld, cid);
2699 if (!channel)
2700 return command_fail(cmd, FUNDING_UNKNOWN_CHANNEL,
2701 "Unknown channel");
2702 if (channel->open_attempt)
2703 return command_fail(cmd, FUNDING_STATE_INVALID,
2704 "Commitments for this channel not "
2705 "yet secured, see `openchannel_update`");
2706
2707 if (list_empty(&channel->inflights))
2708 return command_fail(cmd, FUNDING_STATE_INVALID,
2709 "Channel open not initialized yet.");
2710
2711 if (channel->openchannel_signed_cmd)
2712 return command_fail(cmd, FUNDING_STATE_INVALID,
2713 "Already sent sigs, waiting for peer's");
2714
2715 /* Verify that the psbt's txid matches that of the
2716 * funding txid for this channel */
2717 psbt_txid(NULL, psbt, &txid, NULL);
2718 if (!bitcoin_txid_eq(&txid, &channel->funding.txid))
2719 return command_fail(cmd, FUNDING_PSBT_INVALID,
2720 "Txid for passed in PSBT does not match"
2721 " funding txid for channel. Expected %s, "
2722 "received %s",
2723 fmt_bitcoin_txid(tmpctx,
2724 &channel->funding.txid),
2725 fmt_bitcoin_txid(tmpctx,
2726 &txid));
2727
2728 inflight = list_tail(&channel->inflights,
2729 struct channel_inflight,
2730 list);
2731 if (!inflight)
2732 return command_fail(cmd, LIGHTNINGD,
2733 "Open attempt for channel not found");
2734
2735 if (!bitcoin_txid_eq(&txid, &inflight->funding->outpoint.txid))
2736 return command_fail(cmd, LIGHTNINGD,
2737 "Current inflight transaction is %s,"

Callers

nothing calls this directly

Calls 15

param_checkFunction · 0.85
psbt_txidFunction · 0.85
fmt_bitcoin_txidFunction · 0.85
psbt_is_finalizedFunction · 0.85
psbt_finalizeFunction · 0.85
psbt_side_finalizedFunction · 0.85
tal_wally_startFunction · 0.85
tal_wally_endFunction · 0.85
tal_freeFunction · 0.85
wallet_inflight_saveFunction · 0.85
clone_psbtFunction · 0.85
command_param_failedFunction · 0.70

Tested by

no test coverage detected