| 422 | } |
| 423 | |
| 424 | static struct command_result * |
| 425 | psbt_funded(struct command *cmd, |
| 426 | const char *method, |
| 427 | const char *buf, |
| 428 | const jsmntok_t *result, |
| 429 | struct open_info *info) |
| 430 | { |
| 431 | struct wally_psbt *psbt; |
| 432 | struct json_stream *response; |
| 433 | struct amount_msat our_funding_msat; |
| 434 | |
| 435 | const char *err; |
| 436 | |
| 437 | err = json_scan(tmpctx, buf, result, |
| 438 | "{psbt:%}", |
| 439 | JSON_SCAN_TAL(tmpctx, json_to_psbt, &psbt)); |
| 440 | if (err) |
| 441 | plugin_err(cmd->plugin, |
| 442 | "`fundpsbt` response did not scan %s: %.*s", |
| 443 | err, json_tok_full_len(result), |
| 444 | json_tok_full(buf, result)); |
| 445 | |
| 446 | /* We also mark all of our inputs as *ours*, so we |
| 447 | * can easily identify them for `signpsbt` later */ |
| 448 | for (size_t i = 0; i < psbt->num_inputs; i++) |
| 449 | psbt_input_mark_ours(psbt, &psbt->inputs[i]); |
| 450 | |
| 451 | new_channel_open(cmd->plugin, cmd->plugin, |
| 452 | info->id, info->cid, psbt); |
| 453 | |
| 454 | if (!amount_sat_to_msat(&our_funding_msat, info->our_funding)) |
| 455 | abort(); |
| 456 | |
| 457 | response = jsonrpc_stream_success(cmd); |
| 458 | json_add_string(response, "result", "continue"); |
| 459 | json_add_psbt(response, "psbt", psbt); |
| 460 | json_add_amount_msat(response, "our_funding_msat", our_funding_msat); |
| 461 | |
| 462 | /* If we're accepting an lease request, *and* they've |
| 463 | * requested one, fill in our most recent infos */ |
| 464 | if (current_policy->rates && !amount_sat_is_zero(info->requested_lease)) |
| 465 | json_add_lease_rates(response, current_policy->rates); |
| 466 | |
| 467 | return command_finished(cmd, response); |
| 468 | } |
| 469 | |
| 470 | static struct command_result * |
| 471 | psbt_fund_failed(struct command *cmd, |
nothing calls this directly
no test coverage detected