From 7e158a9bcf799a4ffc3ddda41126b11bae61bff6 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sat, 29 Jan 2022 11:23:38 +0000 Subject: [PATCH] globalvars.py: make 'tx_fee_adj' a float --- mmgen/globalvars.py | 3 +-- mmgen/tx.py | 10 ++++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/mmgen/globalvars.py b/mmgen/globalvars.py index c2fb3afa..c45aaa01 100755 --- a/mmgen/globalvars.py +++ b/mmgen/globalvars.py @@ -21,7 +21,6 @@ globalvars.py: Constants and configuration options for the MMGen suite """ import sys,os -from decimal import Decimal from collections import namedtuple from .devtools import * @@ -69,7 +68,7 @@ class GlobalContext(Lockable): dfl_hash_preset = '3' usr_randchars = 30 - tx_fee_adj = Decimal('1.0') + tx_fee_adj = 1.0 tx_confs = 3 # Constant vars - some of these might be overridden in opts.py, but they don't change thereafter diff --git a/mmgen/tx.py b/mmgen/tx.py index f9774505..5ca53044 100755 --- a/mmgen/tx.py +++ b/mmgen/tx.py @@ -631,14 +631,16 @@ class MMGenTX: # given network fee estimate in BTC/kB, return absolute fee using estimated tx size def fee_est2abs(self,fee_per_kb,fe_type=None): + from decimal import Decimal tx_size = self.estimate_size() - f = fee_per_kb * opt.tx_fee_adj * tx_size / 1024 - ret = self.proto.coin_amt(f,from_decimal=True) + ret = self.proto.coin_amt( + Decimal(fee_per_kb * opt.tx_fee_adj * tx_size / 1024), + from_decimal = True ) if opt.verbose: msg(fmt(f""" {fe_type.upper()} fee for {opt.tx_confs} confirmations: {fee_per_kb} {self.coin}/kB TX size (estimated): {tx_size} bytes - Fee adjustment factor: {opt.tx_fee_adj} + Fee adjustment factor: {opt.tx_fee_adj:.2f} Absolute fee (fee_per_kb * adj_factor * tx_size / 1024): {ret} {self.coin} """).strip()) return ret @@ -684,7 +686,7 @@ class MMGenTX: if abs_fee: prompt = '{} TX fee{}: {}{} {} ({} {})\n'.format( desc, - (f' (after {opt.tx_fee_adj}X adjustment)' + (f' (after {opt.tx_fee_adj:.2f}X adjustment)' if opt.tx_fee_adj != 1 and desc.startswith('Network-estimated') else ''), ('','≈')[self.fee_is_approximate],