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

Function estimatefees_next

plugins/bcli.c:678–717  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

676};
677
678static struct command_result *estimatefees_next(struct command *cmd,
679 struct estimatefees_stash *stash)
680{
681 struct json_stream *response;
682
683 if (stash->cursor < ARRAY_SIZE(stash->perkb)) {
684 start_bitcoin_cli(NULL, cmd, estimatefees_done, true,
685 BITCOIND_LOW_PRIO, stash,
686 "estimatesmartfee",
687 take(tal_fmt(NULL, "%u",
688 estimatefee_params[stash->cursor].blocks)),
689 estimatefee_params[stash->cursor].style,
690 NULL);
691
692 return command_still_pending(cmd);
693 }
694
695 response = jsonrpc_stream_success(cmd);
696 json_add_u64(response, "opening", stash->perkb[FEERATE_NORMAL]);
697 json_add_u64(response, "mutual_close", stash->perkb[FEERATE_SLOW]);
698 json_add_u64(response, "unilateral_close",
699 stash->perkb[FEERATE_URGENT] * bitcoind->commit_fee_percent / 100);
700 json_add_u64(response, "delayed_to_us", stash->perkb[FEERATE_NORMAL]);
701 json_add_u64(response, "htlc_resolution", stash->perkb[FEERATE_URGENT]);
702 json_add_u64(response, "penalty", stash->perkb[FEERATE_NORMAL]);
703 /* We divide the slow feerate for the minimum acceptable, lightningd
704 * will use floor if it's hit, though. */
705 json_add_u64(response, "min_acceptable",
706 stash->perkb[FEERATE_SLOW] / 2);
707 /* BOLT #2:
708 *
709 * Given the variance in fees, and the fact that the transaction may be
710 * spent in the future, it's a good idea for the fee payer to keep a good
711 * margin (say 5x the expected fee requirement)
712 */
713 json_add_u64(response, "max_acceptable",
714 stash->perkb[FEERATE_HIGHEST]
715 * bitcoind->max_fee_multiplier);
716 return command_finished(cmd, response);
717}
718
719/* Get the current feerates. We use an urgent feerate for unilateral_close and max,
720 * a slightly less urgent feerate for htlc_resolution and penalty transactions,

Callers 2

estimatefeesFunction · 0.85
estimatefees_doneFunction · 0.85

Calls 5

start_bitcoin_cliFunction · 0.85
command_still_pendingFunction · 0.70
jsonrpc_stream_successFunction · 0.70
command_finishedFunction · 0.70
json_add_u64Function · 0.50

Tested by

no test coverage detected