mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
simple_config.estimate_fee: make sure method never fails
code in lnsweep was already assuming this
This commit is contained in:
parent
7f1b456b93
commit
80c52d4808
1 changed files with 11 additions and 6 deletions
|
@ -44,14 +44,19 @@ def set_config(c):
|
||||||
global config
|
global config
|
||||||
config = c
|
config = c
|
||||||
|
|
||||||
def estimate_fee(tx_size_bytes):
|
def estimate_fee(tx_size_bytes: int) -> int:
|
||||||
global config
|
def use_fallback_feerate():
|
||||||
if config:
|
|
||||||
fee = config.estimate_fee(tx_size_bytes)
|
|
||||||
else:
|
|
||||||
fee_per_kb = FEERATE_FALLBACK_STATIC_FEE
|
fee_per_kb = FEERATE_FALLBACK_STATIC_FEE
|
||||||
fee = SimpleConfig.estimate_fee_for_feerate(fee_per_kb, tx_size_bytes)
|
fee = SimpleConfig.estimate_fee_for_feerate(fee_per_kb, tx_size_bytes)
|
||||||
return fee
|
return fee
|
||||||
|
|
||||||
|
global config
|
||||||
|
if not config:
|
||||||
|
return use_fallback_feerate()
|
||||||
|
try:
|
||||||
|
return config.estimate_fee(tx_size_bytes)
|
||||||
|
except NoDynamicFeeEstimates:
|
||||||
|
return use_fallback_feerate()
|
||||||
|
|
||||||
FINAL_CONFIG_VERSION = 3
|
FINAL_CONFIG_VERSION = 3
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue