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

Function get_feerate_floor

plugins/bcli.c:528–560  ·  view source on GitHub ↗

Get the feerate floor from getmempoolinfo. * Returns NULL on success (floor stored in *perkb_floor), or error response. */

Source from the content-addressed store, hash-verified

526/* Get the feerate floor from getmempoolinfo.
527 * Returns NULL on success (floor stored in *perkb_floor), or error response. */
528static struct command_result *get_feerate_floor(struct command *cmd,
529 u64 *perkb_floor)
530{
531 struct bcli_result *res;
532 const jsmntok_t *tokens;
533 const char *err;
534 u64 mempoolfee, relayfee;
535
536 res = run_bitcoin_cli(cmd, cmd->plugin, "getmempoolinfo", NULL);
537 if (res->exitstatus != 0)
538 return estimatefees_null_response(cmd);
539
540 tokens = json_parse_simple(res->output, res->output, res->output_len);
541 if (!tokens)
542 return command_err(cmd, res, "bad JSON: cannot parse");
543
544 err = json_scan(tmpctx, res->output, tokens,
545 "{mempoolminfee:%,minrelaytxfee:%}",
546 JSON_SCAN(json_to_bitcoin_amount, &mempoolfee),
547 JSON_SCAN(json_to_bitcoin_amount, &relayfee));
548 if (err)
549 return command_err(cmd, res, tal_fmt(tmpctx, "bad JSON: %s", err));
550
551 *perkb_floor = max_u64(mempoolfee, relayfee);
552 /* Bound the floor before it can also raise the per-target feerates. */
553 if (*perkb_floor > 0xFFFFFFFF) {
554 plugin_log(cmd->plugin, LOG_UNUSUAL,
555 "Feerate floor %"PRIu64" is ridiculous: trimming to 32 bits",
556 *perkb_floor);
557 *perkb_floor = 0xFFFFFFFF;
558 }
559 return NULL;
560}
561
562/* Get a single feerate from estimatesmartfee.
563 * Returns NULL on success (feerate stored in *perkb), or error response. */

Callers 1

estimatefeesFunction · 0.70

Calls 7

run_bitcoin_cliFunction · 0.85
json_parse_simpleFunction · 0.85
command_errFunction · 0.85
max_u64Function · 0.85
plugin_logFunction · 0.70
json_scanFunction · 0.50

Tested by

no test coverage detected