rpc: Avoid useless mempool query in gettxoutproof
Summary:
GetTransaction implicitly and unconditionally asks the mempool global for a transaction. This is problematic for several reasons:
- gettxoutproof is for on-chain txs only and asking the mempool for on-chain txs is confusing and minimally wasteful
- Globals are confusing and make code harder to test with unit tests
Fix both issues by passing in an optional mempool. This also helps with core#19556
This is a backport of core#19589
Test Plan: ninja all check-all
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Subscribers: Fabien
Differential Revision: https://reviews.bitcoinabc.org/D9783