mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-17 19:03:42 +01:00
elements: Fix up feerate upper bound when updating the feerate
This was still using the non-elements estimation only and did not consider the elements overhead.
This commit is contained in:
parent
14247283b2
commit
181764b12d
@ -879,7 +879,28 @@ u32 approx_max_feerate(const struct channel *channel)
|
||||
/* Assume none are trimmed; this gives lower bound on feerate. */
|
||||
num = tal_count(committed) + tal_count(adding) - tal_count(removing);
|
||||
|
||||
/* BOLT #3:
|
||||
*
|
||||
* commitment_transaction: 125 + 43 * num-htlc-outputs bytes
|
||||
* - version: 4 bytes
|
||||
* - witness_header <---- part of the witness data
|
||||
* - count_tx_in: 1 byte
|
||||
* - tx_in: 41 bytes
|
||||
* funding_input
|
||||
* - count_tx_out: 1 byte
|
||||
* - tx_out: 74 + 43 * num-htlc-outputs bytes
|
||||
* output_paying_to_remote,
|
||||
* output_paying_to_local,
|
||||
* ....htlc_output's...
|
||||
* - lock_time: 4 bytes
|
||||
*/
|
||||
/* Those 74 bytes static output are effectively 2 outputs, one
|
||||
* `output_paying_to_local` and one `output_paying_to_remote`. So when
|
||||
* adding the elements overhead we need to add 2 + num htlcs
|
||||
* outputs. */
|
||||
|
||||
weight = 724 + 172 * num;
|
||||
weight = elements_add_overhead(weight, 1, num + 2);
|
||||
|
||||
/* We should never go below reserve. */
|
||||
if (!amount_sat_sub(&avail,
|
||||
|
Loading…
Reference in New Issue
Block a user