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

Function json_feerates

lightningd/chaintopology.c:689–796  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

687}
688
689static struct command_result *json_feerates(struct command *cmd,
690 const char *buffer,
691 const jsmntok_t *obj UNNEEDED,
692 const jsmntok_t *params)
693{
694 struct chain_topology *topo = cmd->ld->topology;
695 struct json_stream *response;
696 enum feerate_style *style;
697 u32 rate;
698
699 if (!param(cmd, buffer, params,
700 p_req("style", param_feerate_style, &style),
701 NULL))
702 return command_param_failed();
703
704 const size_t num_feerates = tal_count(topo->feerates[0]);
705
706 response = json_stream_success(cmd);
707 if (!num_feerates)
708 json_add_string(response, "warning_missing_feerates",
709 "Some fee estimates unavailable: bitcoind startup?");
710
711 json_object_start(response, feerate_style_name(*style));
712 rate = opening_feerate(topo);
713 if (rate)
714 json_add_num(response, "opening", feerate_to_style(rate, *style));
715 rate = mutual_close_feerate(topo);
716 if (rate)
717 json_add_num(response, "mutual_close",
718 feerate_to_style(rate, *style));
719 rate = unilateral_feerate(topo, false);
720 if (rate)
721 json_add_num(response, "unilateral_close",
722 feerate_to_style(rate, *style));
723 rate = unilateral_feerate(topo, true);
724 if (rate)
725 json_add_num(response, "unilateral_anchor_close",
726 feerate_to_style(rate, *style));
727 rate = penalty_feerate(topo);
728 if (rate)
729 json_add_num(response, "penalty",
730 feerate_to_style(rate, *style));
731 rate = splice_feerate(topo, cmd->ld);
732 if (rate)
733 json_add_num(response, "splice", feerate_to_style(rate, *style));
734
735 json_add_u64(response, "min_acceptable",
736 feerate_to_style(feerate_min(cmd->ld, NULL), *style));
737 json_add_u64(response, "max_acceptable",
738 feerate_to_style(feerate_max(cmd->ld, NULL), *style));
739 json_add_u64(response, "floor",
740 feerate_to_style(get_feerate_floor(cmd->ld->topology),
741 *style));
742
743 json_array_start(response, "estimates");
744 assert(tal_count(topo->smoothed_feerates) == num_feerates);
745 for (size_t i = 0; i < num_feerates; i++) {
746 json_object_start(response, NULL);

Callers

nothing calls this directly

Calls 15

json_object_startFunction · 0.85
feerate_style_nameFunction · 0.85
json_add_numFunction · 0.85
feerate_to_styleFunction · 0.85
splice_feerateFunction · 0.85
json_add_u64Function · 0.85
feerate_minFunction · 0.85
feerate_maxFunction · 0.85
json_array_startFunction · 0.85
json_object_endFunction · 0.85
json_array_endFunction · 0.85
feature_offeredFunction · 0.85

Tested by

no test coverage detected