Browse Source

Randomize transaction fees only upwards

master
Kristaps Kaupe 3 years ago
parent
commit
67ff868614
No known key found for this signature in database
GPG Key ID: 33E472FE870C7E5D
  1. 8
      jmclient/jmclient/blockchaininterface.py
  2. 8
      jmclient/jmclient/configure.py

8
jmclient/jmclient/blockchaininterface.py

@ -421,8 +421,7 @@ class BitcoinCoreInterface(BlockchainInterface):
mempoolminfee_in_sat, mempoolminfee_in_sat * float(1 + tx_fees_factor))
if super().fee_per_kb_has_been_manually_set(N):
N_res = random.uniform(N * float(1 - tx_fees_factor),
N * float(1 + tx_fees_factor))
N_res = random.uniform(N, N * float(1 + tx_fees_factor))
if N_res < mempoolminfee_in_sat:
log.info("Using this mempool min fee as tx feerate: " +
btc.fee_per_kb_to_str(mempoolminfee_in_sat) + ".")
@ -451,13 +450,12 @@ class BitcoinCoreInterface(BlockchainInterface):
# the 'feerate' key is found and contains a positive value:
if estimate and estimate > 0:
estimate_in_sat = btc.btc_to_sat(estimate)
retval = random.uniform(
estimate_in_sat * float(1 - tx_fees_factor),
retval = random.uniform(estimate_in_sat,
estimate_in_sat * float(1 + tx_fees_factor))
break
else: # cannot get a valid estimate after `tries` tries:
fallback_fee = 10000
retval = random.uniform(fallback_fee * float(1 - tx_fees_factor),
retval = random.uniform(fallback_fee,
fallback_fee * float(1 + tx_fees_factor))
log.warn("Could not source a fee estimate from Core, " +
"falling back to default: " +

8
jmclient/jmclient/configure.py

@ -279,10 +279,10 @@ merge_algorithm = default
# while N=5 will use the 5 block estimate from your selected blockchain source.
tx_fees = 3
# Transaction fee rate variance factor, 0.2 means 20% variation around
# any manually chosen values, so if you set tx_fees=10000 and
# tx_fees_factor=0.2, it might use any value between 8 thousand and 12 thousand
# for your transactions.
# Transaction fee rate variance factor, 0.2 means fee will be random
# between any manually chosen value and 20% above that value, so if you set
# tx_fees=10000 and tx_fees_factor=0.2, it might use any value between
# 10 thousand and 12 thousand for your transactions.
tx_fees_factor = 0.2
# For users getting transaction fee estimates over an API,

Loading…
Cancel
Save