This is a backport of [[https://github.com/bitcoin/bitcoin/pull/19717 | core#19717]] [2/4]
https://github.com/bitcoin/bitcoin/pull/19717/commits/faaa46dc204d6d714f71dbc6f0bf02215dba0f0f
Note: the double `\n` in `rpc_generate.py` is required because of D7184
Depends on D10145