bitpay / bitcore

A full stack for bitcoin and blockchain-based applications
https://bitcore.io/
MIT License
4.8k stars 2.07k forks source link

[BCN] Add replacedByTxid to RBF'd txs #3618

Closed kajoseph closed 11 months ago

kajoseph commented 11 months ago

Currently, there is no good way to identify which transaction replaced an existing one in the mempool. If I have a system that is monitoring a tx and that tx is RBF'd, all our API endpoint returns is a blockHeight of -3 (conflicting) without a pointer to the conflicting tx.

This PR adds the replacedByTxid field to the transaction schema and records it when a tx is RBF'd. This required a refactor of the pruneMempool method to reliably record the replacedByTxid where appropriate. The result is a simpler, more elegant pruneMempool method.