fix(chain): filter coinbase tx not in best chain

Coinbase transactions cannot exist in the mempool and be unconfirmed.
`TxGraph::try_get_chain_position` should always return `None` for coinbase
transactions not anchored in best chain.
This commit is contained in:
Wei Chen
2023-11-10 05:34:08 +08:00
parent 0a7b60f0f7
commit 991cb77b6f
2 changed files with 51 additions and 1 deletions

View File

@@ -718,7 +718,14 @@ impl<A: Anchor> TxGraph<A> {
// might be in mempool, or it might have been dropped already.
// Let's check conflicts to find out!
let tx = match tx_node {
TxNodeInternal::Whole(tx) => tx,
TxNodeInternal::Whole(tx) => {
// A coinbase tx that is not anchored in the best chain cannot be unconfirmed and
// should always be filtered out.
if tx.is_coin_base() {
return Ok(None);
}
tx
}
TxNodeInternal::Partial(_) => {
// Partial transactions (outputs only) cannot have conflicts.
return Ok(None);