| 292 | } |
| 293 | |
| 294 | static struct command_result * |
| 295 | psbt_funded(struct command *cmd, |
| 296 | const char *buf, |
| 297 | const jsmntok_t *result, |
| 298 | struct open_info *info) |
| 299 | { |
| 300 | struct wally_psbt *psbt; |
| 301 | struct json_stream *response; |
| 302 | struct amount_msat our_funding_msat; |
| 303 | |
| 304 | const char *err; |
| 305 | |
| 306 | err = json_scan(tmpctx, buf, result, |
| 307 | "{psbt:%}", |
| 308 | JSON_SCAN_TAL(tmpctx, json_to_psbt, &psbt)); |
| 309 | if (err) |
| 310 | plugin_err(cmd->plugin, |
| 311 | "`fundpsbt` response did not scan %s: %.*s", |
| 312 | err, json_tok_full_len(result), |
| 313 | json_tok_full(buf, result)); |
| 314 | |
| 315 | /* We also mark all of our inputs as *ours*, so we |
| 316 | * can easily identify them for `signpsbt` later */ |
| 317 | for (size_t i = 0; i < psbt->num_inputs; i++) |
| 318 | psbt_input_mark_ours(psbt, &psbt->inputs[i]); |
| 319 | |
| 320 | new_channel_open(cmd->plugin, cmd->plugin, |
| 321 | info->id, info->cid, psbt); |
| 322 | |
| 323 | if (!amount_sat_to_msat(&our_funding_msat, info->our_funding)) |
| 324 | abort(); |
| 325 | |
| 326 | response = jsonrpc_stream_success(cmd); |
| 327 | json_add_string(response, "result", "continue"); |
| 328 | json_add_psbt(response, "psbt", psbt); |
| 329 | json_add_amount_msat_only(response, "our_funding_msat", |
| 330 | our_funding_msat); |
| 331 | |
| 332 | /* If we're accepting an lease request, *and* they've |
| 333 | * requested one, fill in our most recent infos */ |
| 334 | if (current_policy->rates && !amount_sat_zero(info->requested_lease)) |
| 335 | json_add_lease_rates(response, current_policy->rates); |
| 336 | |
| 337 | return command_finished(cmd, response); |
| 338 | } |
| 339 | |
| 340 | static struct command_result * |
| 341 | psbt_fund_failed(struct command *cmd, |
nothing calls this directly
no test coverage detected