Get the feerate floor from getmempoolinfo. * Returns NULL on success (floor stored in *perkb_floor), or error response. */
| 526 | /* Get the feerate floor from getmempoolinfo. |
| 527 | * Returns NULL on success (floor stored in *perkb_floor), or error response. */ |
| 528 | static 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 | return NULL; |
| 553 | } |
| 554 | |
| 555 | /* Get a single feerate from estimatesmartfee. |
| 556 | * Returns NULL on success (feerate stored in *perkb), or error response. */ |
no test coverage detected