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

Function feerate_from_style

bitcoin/feerate.c:5–26  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3#include <bitcoin/feerate.h>
4
5u32 feerate_from_style(u32 feerate, enum feerate_style style)
6{
7 /* Make sure it's called somewhere! */
8 assert(feerate_floor_check() == FEERATE_FLOOR);
9
10 switch (style) {
11 case FEERATE_PER_KSIPA:
12 return feerate;
13 case FEERATE_PER_KBYTE:
14 /* Everyone uses satoshi per kbyte, but we use satoshi per ksipa
15 * (don't round down to zero though)!
16 *
17 * Widen before rounding up: on a u32 the +3 wraps for the top
18 * three values, turning an absurd feerate into 0 or 1 perkw.
19 * That is the dangerous direction (it underpays our unilateral
20 * close), and it slips under every bound we check afterwards,
21 * since those are applied to the converted value. The result
22 * always fits a u32: (UINT_MAX + 3) / 4 < UINT_MAX. */
23 return ((u64)feerate + 3) / 4;
24 }
25 abort();
26}
27
28u32 feerate_to_style(u32 feerate_perkw, enum feerate_style style)
29{

Callers 2

param_feerate_valFunction · 0.85
estimatefees_callbackFunction · 0.85

Calls 2

feerate_floor_checkFunction · 0.85
abortFunction · 0.85

Tested by

no test coverage detected