| 461 | } |
| 462 | |
| 463 | static struct command_result * |
| 464 | psbt_funded(struct command *cmd, |
| 465 | const char *method, |
| 466 | const char *buf, |
| 467 | const jsmntok_t *result, |
| 468 | struct open_info *info) |
| 469 | { |
| 470 | struct wally_psbt *psbt; |
| 471 | struct json_stream *response; |
| 472 | struct amount_msat our_funding_msat; |
| 473 | |
| 474 | const char *err; |
| 475 | |
| 476 | err = json_scan(tmpctx, buf, result, |
| 477 | "{psbt:%}", |
| 478 | JSON_SCAN_TAL(tmpctx, json_to_psbt, &psbt)); |
| 479 | if (err) |
| 480 | plugin_err(cmd->plugin, |
| 481 | "`fundpsbt` response did not scan %s: %.*s", |
| 482 | err, json_tok_full_len(result), |
| 483 | json_tok_full(buf, result)); |
| 484 | |
| 485 | /* We also mark all of our inputs as *ours*, so we |
| 486 | * can easily identify them for `signpsbt` later */ |
| 487 | for (size_t i = 0; i < psbt->num_inputs; i++) |
| 488 | psbt_input_mark_ours(psbt, &psbt->inputs[i]); |
| 489 | |
| 490 | new_channel_open(cmd->plugin, cmd->plugin, |
| 491 | info->id, info->cid, psbt); |
| 492 | |
| 493 | if (!amount_sat_to_msat(&our_funding_msat, info->our_funding)) |
| 494 | abort(); |
| 495 | |
| 496 | response = jsonrpc_stream_success(cmd); |
| 497 | json_add_string(response, "result", "continue"); |
| 498 | json_add_psbt(response, "psbt", psbt); |
| 499 | json_add_amount_msat(response, "our_funding_msat", our_funding_msat); |
| 500 | |
| 501 | /* If we're accepting an lease request, *and* they've |
| 502 | * requested one, fill in our most recent infos */ |
| 503 | if (current_policy->rates && !amount_sat_is_zero(info->requested_lease)) |
| 504 | json_add_lease_rates(response, current_policy->rates); |
| 505 | |
| 506 | funding_queue_done(info); |
| 507 | return command_finished(cmd, response); |
| 508 | } |
| 509 | |
| 510 | static struct command_result * |
| 511 | psbt_fund_failed(struct command *cmd, |
nothing calls this directly
no test coverage detected