diff --git a/scripts/sendpayment.py b/scripts/sendpayment.py index 802bd4b..00c47be 100755 --- a/scripts/sendpayment.py +++ b/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')) diff --git a/src/jmclient/blockchaininterface.py b/src/jmclient/blockchaininterface.py index 663dce8..d9ae28b 100644 --- a/src/jmclient/blockchaininterface.py +++ b/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"