Also pass in appropriate object to:
- TxToJSON
This is a partial backport of [[https://github.com/bitcoin/bitcoin/pull/21391 | core#21391]]
https://github.com/bitcoin/bitcoin/pull/21391/commits/7be0671b950842fc3a17641a4a21501de0a800b5
Depends on D11511