electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 80c52d4808014fa58773021ac66f6686bebae08c
parent 7f1b456b93fa2f09a7eca3ada31082331ea7ecb7
Author: SomberNight <somber.night@protonmail.com>
Date:   Mon,  5 Aug 2019 18:51:54 +0200

simple_config.estimate_fee: make sure method never fails

code in lnsweep was already assuming this

Diffstat:
Melectrum/simple_config.py | 17+++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/electrum/simple_config.py b/electrum/simple_config.py @@ -44,14 +44,19 @@ def set_config(c): global config config = c -def estimate_fee(tx_size_bytes): - global config - if config: - fee = config.estimate_fee(tx_size_bytes) - else: +def estimate_fee(tx_size_bytes: int) -> int: + def use_fallback_feerate(): fee_per_kb = FEERATE_FALLBACK_STATIC_FEE 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