| 3146 | } |
| 3147 | |
| 3148 | static struct json_stream *build_commit_response(struct command *cmd, |
| 3149 | struct channel *channel, |
| 3150 | struct channel_inflight *inflight) |
| 3151 | { |
| 3152 | struct json_stream *response; |
| 3153 | |
| 3154 | response = json_stream_success(cmd); |
| 3155 | json_add_string(response, "channel_id", |
| 3156 | fmt_channel_id(tmpctx, &channel->cid)); |
| 3157 | json_add_psbt(response, "psbt", inflight->funding_psbt); |
| 3158 | json_add_channel_type(response, "channel_type", channel->type); |
| 3159 | json_add_bool(response, "commitments_secured", inflight->last_tx != NULL); |
| 3160 | /* For convenience sake, we include the funding outnum */ |
| 3161 | assert(inflight->funding); |
| 3162 | json_add_num(response, "funding_outnum", inflight->funding->outpoint.n); |
| 3163 | /* This is *sort of* dicey, since there's a small chance the channel |
| 3164 | * might disconnect/reconnect and we lose the open-attempt data */ |
| 3165 | if (channel->open_attempt && channel->open_attempt->our_upfront_shutdown_script) { |
| 3166 | /* FIXME: also include the output as address */ |
| 3167 | json_add_hex_talarr(response, "close_to", |
| 3168 | channel->open_attempt->our_upfront_shutdown_script); |
| 3169 | /* Worse case is that we accidentally report what we're 'closing-to' even if you |
| 3170 | * didn't request it? We *could* just announce it every time... */ |
| 3171 | } else if (!channel->open_attempt && channel->shutdown_scriptpubkey[LOCAL]) { |
| 3172 | json_add_hex_talarr(response, "close_to", |
| 3173 | channel->shutdown_scriptpubkey[LOCAL]); |
| 3174 | /* FIXME: also include the output as address */ |
| 3175 | } |
| 3176 | return response; |
| 3177 | } |
| 3178 | |
| 3179 | static struct command_result *json_openchannel_update(struct command *cmd, |
| 3180 | const char *buffer, |
no test coverage detected