This is a backport of [[https://github.com/bitcoin/bitcoin/pull/19773 | core#19773]] [2/2]
https://github.com/bitcoin/bitcoin/pull/19773/commits/772ea4844c34ad70d02fd0bd6c0945baa8fff85c
Backport note: `checkFinalTx` was replaced by `ContextualCheckTransactionForCurrentBlock` in D5804