Browse Source

Merge JoinMarket-Org/joinmarket-clientserver#1636: Allow absurd fee override when setting tx fee manually

196a097667 Allow absurd fee override when setting tx fee manually (Kristaps Kaupe)

Pull request description:

  When user manually specifies `--txfee` with `sendpayment.py`, he likely knows what he is doing. So allow there fees above `absurd_fee_per_kb` setting. But still ask for user confirmation as he could possible made a mistake, for example, added some extra zeros to the value.

Top commit has no ACKs.

Tree-SHA512: 2155c38a483fd6392153bf42b2ea87cb9395f0da289cc2743602493df9e924a1d621688704a46d179e3e574ce41e82ced26b62331157ac2c3d1481931a334ace
master
Kristaps Kaupe 2 years ago
parent
commit
8319870345
No known key found for this signature in database
GPG Key ID: 33E472FE870C7E5D
  1. 21
      scripts/sendpayment.py
  2. 6
      src/jmclient/blockchaininterface.py

21
scripts/sendpayment.py

@ -157,6 +157,27 @@ def main():
# If tx_fees are set manually by CLI argument, override joinmarket.cfg:
if int(options.txfee) > 0:
if jm_single().bc_interface.fee_per_kb_has_been_manually_set(
options.txfee):
absurd_fee = jm_single().config.getint("POLICY",
"absurd_fee_per_kb")
tx_fees_factor = jm_single().config.getfloat("POLICY",
"tx_fees_factor")
max_potential_txfee = int(max(options.txfee,
options.txfee * float(1 + tx_fees_factor)))
if max_potential_txfee > absurd_fee:
jmprint(
"WARNING: Manually specified Bitcoin transaction fee "
f"{btc.fee_per_kb_to_str(options.txfee)} can be "
"randomized up to "
f"{btc.fee_per_kb_to_str(max_potential_txfee)}, "
"above absurd value "
f"{btc.fee_per_kb_to_str(absurd_fee)}.",
"warning")
if input("Still continue? (y/n):")[0] != "y":
sys.exit("Aborted by user.")
jm_single().config.set("POLICY", "absurd_fee_per_kb",
str(max_potential_txfee))
jm_single().config.set("POLICY", "tx_fees", str(options.txfee))
maxcjfee = (1, float('inf'))

6
src/jmclient/blockchaininterface.py

@ -233,7 +233,7 @@ class BlockchainInterface(ABC):
# and return the indices of the others:
return [i for i, val in enumerate(res) if val]
def _fee_per_kb_has_been_manually_set(self, tx_fees: int) -> bool:
def fee_per_kb_has_been_manually_set(self, tx_fees: int) -> bool:
"""If the block target (tx_fees) is higher than 1000, interpret it
as manually set fee sats/kvB.
"""
@ -242,7 +242,7 @@ class BlockchainInterface(ABC):
def estimate_fee_per_kb(self, tx_fees: int) -> int:
""" The argument tx_fees may be either a number of blocks target,
for estimation of feerate by Core, or a number of satoshis
per kilo-vbyte (see `_fee_per_kb_has_been_manually_set` for
per kilo-vbyte (see `fee_per_kb_has_been_manually_set` for
how this is distinguished).
In both cases it is prevented from falling below the current
minimum feerate for tx to be accepted into node's mempool.
@ -264,7 +264,7 @@ class BlockchainInterface(ABC):
mempoolminfee_in_sat_randomized = random.uniform(
mempoolminfee_in_sat, mempoolminfee_in_sat * float(1 + tx_fees_factor))
if self._fee_per_kb_has_been_manually_set(tx_fees):
if self.fee_per_kb_has_been_manually_set(tx_fees):
N_res = random.uniform(tx_fees, tx_fees * float(1 + tx_fees_factor))
if N_res < mempoolminfee_in_sat:
msg = "Using this mempool min fee as tx feerate"

Loading…
Cancel
Save