mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 21:35:11 +01:00
chaintopology: use satoshi-per-kw everywhere.
This means we convert it when retrieving from bitcoind; internally it's always satoshi-per-1000-weight aka millisatoshi-per-weight. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
b954662f06
commit
ef4d54df94
@ -262,18 +262,18 @@ static bool extract_feerate(struct bitcoin_cli *bcli,
|
||||
static void process_estimatefee(struct bitcoin_cli *bcli)
|
||||
{
|
||||
double feerate;
|
||||
u64 satoshi_per_kb;
|
||||
u64 satoshi_per_kw;
|
||||
void (*cb)(struct bitcoind *, u64, void *) = bcli->cb;
|
||||
|
||||
/* FIXME: We could trawl recent blocks for median fee... */
|
||||
if (!extract_feerate(bcli, bcli->output, bcli->output_bytes, &feerate)) {
|
||||
log_unusual(bcli->bitcoind->log, "Unable to estimate fee");
|
||||
satoshi_per_kb = 0;
|
||||
satoshi_per_kw = 0;
|
||||
} else
|
||||
/* Rate in satoshi per kb. */
|
||||
satoshi_per_kb = feerate * 100000000;
|
||||
/* Rate in satoshi per kw. */
|
||||
satoshi_per_kw = feerate * 100000000 / 4;
|
||||
|
||||
cb(bcli->bitcoind, satoshi_per_kb, bcli->cb_arg);
|
||||
cb(bcli->bitcoind, satoshi_per_kw, bcli->cb_arg);
|
||||
}
|
||||
|
||||
void bitcoind_estimate_fee_(struct bitcoind *bitcoind,
|
||||
|
@ -57,7 +57,7 @@ void wait_for_bitcoind(struct bitcoind *bitcoind);
|
||||
|
||||
void bitcoind_estimate_fee_(struct bitcoind *bitcoind,
|
||||
void (*cb)(struct bitcoind *bitcoind,
|
||||
u64, void *),
|
||||
u64 satoshi_per_kw, void *),
|
||||
void *arg);
|
||||
|
||||
#define bitcoind_estimate_fee(bitcoind_, cb, arg) \
|
||||
|
@ -291,12 +291,12 @@ static void free_blocks(struct chain_topology *topo, struct block *b)
|
||||
}
|
||||
}
|
||||
|
||||
static void update_fee(struct bitcoind *bitcoind, u64 rate,
|
||||
static void update_fee(struct bitcoind *bitcoind, u64 satoshi_per_kw,
|
||||
struct chain_topology *topo)
|
||||
{
|
||||
log_debug(topo->log, "Feerate %"PRIu64" (was %"PRIu64")",
|
||||
rate, topo->feerate);
|
||||
topo->feerate = rate;
|
||||
satoshi_per_kw, topo->feerate);
|
||||
topo->feerate = satoshi_per_kw;
|
||||
}
|
||||
|
||||
/* B is the new chain (linked by ->next); update topology */
|
||||
|
@ -138,7 +138,7 @@ size_t get_tx_depth(const struct chain_topology *topo,
|
||||
/* Get highest block number. */
|
||||
u32 get_block_height(const struct chain_topology *topo);
|
||||
|
||||
/* Get fee rate. */
|
||||
/* Get fee rate in satoshi per kiloweight. */
|
||||
u64 get_feerate(const struct chain_topology *topo);
|
||||
|
||||
/* Broadcast a single tx, and rebroadcast as reqd (copies tx).
|
||||
|
Loading…
Reference in New Issue
Block a user