Skip to content

Commit

Permalink
Allow fee bump tx not signalling BIP125 if mempoolfullrbf is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
kristapsk committed Nov 24, 2023
1 parent 8e27120 commit c990a4d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
6 changes: 4 additions & 2 deletions scripts/bumpfee.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ def check_valid_candidate(orig_tx, wallet, output_index=-1):
if own_inputs_n != tx_inputs_n:
raise ValueError('Transaction inputs should belong to the wallet.')

# at least one input should signal opt-in rbf
if not any([vin.nSequence <= 0xffffffff - 2 for vin in orig_tx.vin]):
# either mempoolfullrbf must be enabled or at least one input must signal
# opt-in rbf
if not jm_single().bc_interface.mempoolfullrbf() and \
not any([vin.nSequence <= 0xffffffff - 2 for vin in orig_tx.vin]):
raise ValueError('Transaction not replaceable.')

# 1. If output_index is specified, check that the output exist
Expand Down
14 changes: 13 additions & 1 deletion src/jmclient/blockchaininterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ def testmempoolaccept(self, rawtx: str) -> bool:
"""Checks that raw transaction would be accepted by mempool.
"""

@abstractmethod
def mempoolfullrbf(self) -> bool:
"""Whether mempool full-RBF is enabled.
"""

@abstractmethod
def _get_mempool_min_fee(self) -> Optional[int]:
"""Returns minimum mempool fee as a floor to avoid relay problems
Expand Down Expand Up @@ -558,13 +563,20 @@ def query_utxo_set(self,
result.append(result_dict)
return result

def _getmempoolinfo(self) -> Optional[dict]:
return self._rpc('getmempoolinfo')

def _get_mempool_min_fee(self) -> Optional[int]:
rpc_result = self._rpc('getmempoolinfo')
rpc_result = self._getmempoolinfo()
if not rpc_result:
# in case of connection error:
return None
return btc.btc_to_sat(rpc_result['mempoolminfee'])

def mempoolfullrbf(self) -> bool:
rpc_result = self._getmempoolinfo()
return 'fullrbf' in rpc_result and rpc_result['fullrbf']

def _estimate_fee_basic(self, conf_target: int) -> Optional[int]:
# Special bitcoin core case: sometimes the highest priority
# cannot be estimated in that case the 2nd highest priority
Expand Down
2 changes: 2 additions & 0 deletions test/jmclient/commontest.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ def get_wallet_rescan_status(self) -> Tuple[bool, Optional[Decimal]]:
pass
def rescanblockchain(self, start_height: int, end_height: Optional[int] = None) -> None:
pass
def mempoolfullrbf(self) -> bool:
pass

def get_current_block_height(self) -> int:
return 10**6
Expand Down

0 comments on commit c990a4d

Please sign in to comment.