| 1372 | } |
| 1373 | |
| 1374 | static struct command_result * |
| 1375 | perform_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! */ |
no test coverage detected