Skip to main content

replacement_checks

Function replacement_checks 

Source
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:

  1. Existing transaction signals RBF (nSequence < SEQUENCE_FINAL)
  2. New transaction has higher fee rate: FeeRate(tx_2) > FeeRate(tx_1)
  3. New transaction pays absolute fee bump: Fee(tx_2) > Fee(tx_1) + MIN_RELAY_FEE
  4. New transaction conflicts with existing: tx_2 spends at least one input from tx_1
  5. No new unconfirmed dependencies: All inputs of tx_2 are confirmed or from tx_1