Note: the #include <util/memory.h> is unnecessary because we use
std::make_unique rather than MakeUnique.
This is a backport of core#19102 [1/3]
https://github.com/bitcoin/bitcoin/pull/19102/commits/0103d6434ea9d155259b40575008239a3762d6f7
Depends on D10038