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

Function estimatefees

plugins/bcli.c:596–632  ·  view source on GitHub ↗

Get the current feerates. We use an urgent feerate for unilateral_close and max, * a slightly less urgent feerate for htlc_resolution and penalty transactions, * a slow feerate for min, and a normal one for all others. */

Source from the content-addressed store, hash-verified

594 * a slow feerate for min, and a normal one for all others.
595 */
596static struct command_result *estimatefees(struct command *cmd,
597 const char *buf UNUSED,
598 const jsmntok_t *toks UNUSED)
599{
600 struct command_result *err;
601 u64 perkb_floor = 0;
602 u64 perkb[ARRAY_SIZE(estimatefee_params)];
603 struct json_stream *response;
604
605 if (!param(cmd, buf, toks, NULL))
606 return command_param_failed();
607
608 err = get_feerate_floor(cmd, &perkb_floor);
609 if (err)
610 return err;
611
612 for (size_t i = 0; i < ARRAY_SIZE(estimatefee_params); i++) {
613 err = get_feerate(cmd, estimatefee_params[i].blocks,
614 estimatefee_params[i].style, &perkb[i]);
615 if (err)
616 return err;
617 }
618
619 response = jsonrpc_stream_success(cmd);
620 json_array_start(response, "feerates");
621 for (size_t i = 0; i < ARRAY_SIZE(perkb); i++) {
622 if (!perkb[i])
623 continue;
624 json_object_start(response, NULL);
625 json_add_u32(response, "blocks", estimatefee_params[i].blocks);
626 json_add_feerate(response, "feerate", cmd, perkb_floor, perkb[i]);
627 json_object_end(response);
628 }
629 json_array_end(response);
630 json_add_u64(response, "feerate_floor", perkb_floor);
631 return command_finished(cmd, response);
632}
633
634/* Send a transaction to the Bitcoin network.
635 * Calls `sendrawtransaction` using the first parameter as the raw tx.

Callers

nothing calls this directly

Calls 13

json_array_startFunction · 0.85
json_object_startFunction · 0.85
json_add_u32Function · 0.85
json_add_feerateFunction · 0.85
json_object_endFunction · 0.85
json_array_endFunction · 0.85
json_add_u64Function · 0.85
command_param_failedFunction · 0.70
get_feerate_floorFunction · 0.70
get_feerateFunction · 0.70
jsonrpc_stream_successFunction · 0.70
command_finishedFunction · 0.70

Tested by

no test coverage detected