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

Function estimatefees_parse_feerate

plugins/bcli.c:497–524  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

495}
496
497static struct command_result *
498estimatefees_parse_feerate(struct bitcoin_cli *bcli, u64 *feerate)
499{
500 const jsmntok_t *tokens;
501
502 tokens = json_parse_simple(bcli->output,
503 bcli->output, bcli->output_bytes);
504 if (!tokens) {
505 return command_err_bcli_badjson(bcli, "cannot parse");
506 }
507
508 if (json_scan(tmpctx, bcli->output, tokens, "{feerate:%}",
509 JSON_SCAN(json_to_bitcoin_amount, feerate)) != NULL) {
510 /* Paranoia: if it had a feerate, but was malformed: */
511 if (json_get_member(bcli->output, tokens, "feerate"))
512 return command_err_bcli_badjson(bcli, "cannot scan");
513 /* Regtest fee estimation is generally awful: Fake it at min. */
514 if (bitcoind->fake_fees) {
515 *feerate = 1000;
516 return NULL;
517 }
518 /* We return null if estimation failed, and bitcoin-cli will
519 * exit with 0 but no feerate field on failure. */
520 return estimatefees_null_response(bcli);
521 }
522
523 return NULL;
524}
525
526static struct command_result *process_sendrawtransaction(struct bitcoin_cli *bcli)
527{

Callers 1

estimatefees_doneFunction · 0.85

Calls 5

command_err_bcli_badjsonFunction · 0.85
json_parse_simpleFunction · 0.50
json_scanFunction · 0.50
json_get_memberFunction · 0.50

Tested by

no test coverage detected