This will be convenient in the I2P SAM implementation.
This is a backport of [[https://github.com/bitcoin/bitcoin/pull/20685 | core#20685]] [13/20]
https://github.com/bitcoin/bitcoin/pull/20685/commits/5bac7e45e1d3a07115b5ff002d988438fcc92a53
Depends on D11023