| 2678 | } |
| 2679 | |
| 2680 | static struct command_result * |
| 2681 | json_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," |
nothing calls this directly
no test coverage detected