* json_fundchannel_cancel - Entrypoint for cancelling a channel which funding isn't broadcast */
| 1057 | * json_fundchannel_cancel - Entrypoint for cancelling a channel which funding isn't broadcast |
| 1058 | */ |
| 1059 | static struct command_result *json_fundchannel_cancel(struct command *cmd, |
| 1060 | const char *buffer, |
| 1061 | const jsmntok_t *obj UNNEEDED, |
| 1062 | const jsmntok_t *params) |
| 1063 | { |
| 1064 | |
| 1065 | struct node_id *id; |
| 1066 | struct peer *peer; |
| 1067 | u8 *msg; |
| 1068 | |
| 1069 | if (!param(cmd, buffer, params, |
| 1070 | p_req("id", param_node_id, &id), |
| 1071 | NULL)) |
| 1072 | return command_param_failed(); |
| 1073 | |
| 1074 | peer = peer_by_id(cmd->ld, id); |
| 1075 | if (!peer) { |
| 1076 | return command_fail(cmd, FUNDING_UNKNOWN_PEER, "Unknown peer"); |
| 1077 | } |
| 1078 | |
| 1079 | if (peer->uncommitted_channel) { |
| 1080 | if (!peer->uncommitted_channel->fc || !peer->uncommitted_channel->fc->inflight) |
| 1081 | return command_fail(cmd, FUNDING_NOTHING_TO_CANCEL, |
| 1082 | "No channel funding in progress."); |
| 1083 | |
| 1084 | /* Make sure this gets notified if we succeed or cancel */ |
| 1085 | tal_arr_expand(&peer->uncommitted_channel->fc->cancels, cmd); |
| 1086 | msg = towire_openingd_funder_cancel(NULL); |
| 1087 | subd_send_msg(peer->uncommitted_channel->open_daemon, take(msg)); |
| 1088 | return command_still_pending(cmd); |
| 1089 | } |
| 1090 | |
| 1091 | log_debug(cmd->ld->log, "fundchannel_cancel no uncommitted_channel!"); |
| 1092 | |
| 1093 | /* Handle `fundchannel_cancel` after `fundchannel_complete`. */ |
| 1094 | return cancel_channel_before_broadcast(cmd, peer); |
| 1095 | } |
| 1096 | |
| 1097 | /** |
| 1098 | * json_fundchannel_start - Entrypoint for funding a channel |
nothing calls this directly
no test coverage detected