pub fn replacement_checks(
new_tx: &Transaction,
existing_tx: &Transaction,
utxo_set: &HashMap<OutPoint, Arc<UTXO>, FxBuildHasher>,
mempool: &HashSet<[u8; 32]>,
) -> Result<bool, ConsensusError>Expand description
ReplacementChecks: 𝒯𝒳 × 𝒯𝒳 × 𝒰𝒮 × Mempool → {true, false}
Check if new transaction can replace existing one (BIP125 RBF rules).
According to BIP125 and Orange Paper Section 9.3, replacement is allowed if:
- Existing transaction signals RBF (nSequence < SEQUENCE_FINAL)
- New transaction has higher fee rate: FeeRate(tx_2) > FeeRate(tx_1)
- New transaction pays absolute fee bump: Fee(tx_2) > Fee(tx_1) + MIN_RELAY_FEE
- New transaction conflicts with existing: tx_2 spends at least one input from tx_1
- No new unconfirmed dependencies: All inputs of tx_2 are confirmed or from tx_1