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

Function estimatefees

plugins/bcli.c:603–639  ·  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

601 * a slow feerate for min, and a normal one for all others.
602 */
603static struct command_result *estimatefees(struct command *cmd,
604 const char *buf UNUSED,
605 const jsmntok_t *toks UNUSED)
606{
607 struct command_result *err;
608 u64 perkb_floor = 0;
609 u64 perkb[ARRAY_SIZE(estimatefee_params)];
610 struct json_stream *response;
611
612 if (!param(cmd, buf, toks, NULL))
613 return command_param_failed();
614
615 err = get_feerate_floor(cmd, &perkb_floor);
616 if (err)
617 return err;
618
619 for (size_t i = 0; i < ARRAY_SIZE(estimatefee_params); i++) {
620 err = get_feerate(cmd, estimatefee_params[i].blocks,
621 estimatefee_params[i].style, &perkb[i]);
622 if (err)
623 return err;
624 }
625
626 response = jsonrpc_stream_success(cmd);
627 json_array_start(response, "feerates");
628 for (size_t i = 0; i < ARRAY_SIZE(perkb); i++) {
629 if (!perkb[i])
630 continue;
631 json_object_start(response, NULL);
632 json_add_u32(response, "blocks", estimatefee_params[i].blocks);
633 json_add_feerate(response, "feerate", cmd, perkb_floor, perkb[i]);
634 json_object_end(response);
635 }
636 json_array_end(response);
637 json_add_u64(response, "feerate_floor", perkb_floor);
638 return command_finished(cmd, response);
639}
640
641/* Send a transaction to the Bitcoin network.
642 * 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