Skip to content

Commit

Permalink
Merge #1604: Allow fee bump tx not signalling BIP125 if `mempoolfullr…
Browse files Browse the repository at this point in the history
…bf` is enabled

c990a4d Allow fee bump tx not signalling BIP125 if mempoolfullrbf is enabled (Kristaps Kaupe)

Pull request description:

  We should allow this if full-RBF is enabled in Bitcoin node.

ACKs for top commit:
  AdamISZ:
    utACK c990a4d

Tree-SHA512: a2bb2374e790891d437ee71647c15ad91eb855ae5bd99afa8e116b91d15bdd4a9f3694469a867f24a37612c38e4215bfb1d45beda8fc921b3dc4363d5d015fd0
  • Loading branch information
kristapsk committed Nov 24, 2023
2 parents 8e27120 + c990a4d commit 3e09421
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 3e09421

Please sign in to comment.