MCPcopy Create free account
hub / github.com/ElementsProject/lightning / perform_fundpsbt

Function perform_fundpsbt

plugins/spender/multifundchannel.c:1374–1486  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1372}
1373
1374static struct command_result *
1375perform_fundpsbt(struct multifundchannel_command *mfc, u32 feerate)
1376{
1377 struct out_req *req;
1378
1379 /* If the user specified utxos we should use utxopsbt instead
1380 * of fundpsbt. */
1381 if (mfc->utxos_str) {
1382 plugin_log(mfc->cmd->plugin, LOG_DBG,
1383 "mfc %"PRIu64": utxopsbt.",
1384 mfc->id);
1385
1386 req = jsonrpc_request_start(mfc->cmd->plugin,
1387 mfc->cmd,
1388 "utxopsbt",
1389 &after_fundpsbt,
1390 &mfc_forward_error,
1391 mfc);
1392 json_add_jsonstr(req->js, "utxos",
1393 mfc->utxos_str, strlen(mfc->utxos_str));
1394 json_add_bool(req->js, "reservedok", false);
1395 } else {
1396 plugin_log(mfc->cmd->plugin, LOG_DBG,
1397 "mfc %"PRIu64": fundpsbt.",
1398 mfc->id);
1399
1400 req = jsonrpc_request_start(mfc->cmd->plugin,
1401 mfc->cmd,
1402 "fundpsbt",
1403 &after_fundpsbt,
1404 &mfc_forward_error,
1405 mfc);
1406 json_add_u32(req->js, "minconf", mfc->minconf);
1407 }
1408
1409 /* The entire point is to reserve the inputs. */
1410 /* BOLT #2:
1411 * The sender:
1412 *...
1413 * - SHOULD ensure the funding transaction confirms in the next 2016
1414 * blocks.
1415 */
1416 json_add_u32(req->js, "reserve", 2016);
1417 /* How much do we need to reserve? */
1418 if (has_all(mfc))
1419 json_add_string(req->js, "satoshi", "all");
1420 else {
1421 struct amount_sat sum = AMOUNT_SAT(0);
1422 for (size_t i = 0; i < tal_count(mfc->destinations); ++i) {
1423 struct amount_sat requested
1424 = mfc->destinations[i].request_amt;
1425
1426 if (!amount_sat_add(&sum,
1427 sum, mfc->destinations[i].amount))
1428 return mfc_fail(mfc, JSONRPC2_INVALID_PARAMS,
1429 "Overflow while summing "
1430 "destination values.");
1431 /* Also add in any fees for requested amt! */

Callers 1

after_getfeerateFunction · 0.85

Calls 15

json_add_jsonstrFunction · 0.85
has_allFunction · 0.85
mfc_failFunction · 0.85
amount_sat_zeroFunction · 0.85
lease_rates_calc_feeFunction · 0.85
bitcoin_tx_core_weightFunction · 0.85
bitcoin_tx_output_weightFunction · 0.85
dest_countFunction · 0.85
plugin_logFunction · 0.50
json_add_boolFunction · 0.50
json_add_u32Function · 0.50
json_add_stringFunction · 0.50

Tested by

no test coverage detected