Partial backport of Core PR13669
https://github.com/bitcoin/bitcoin/pull/13669/commits/736f9414246f2a855e7b6fc57c8f903e60530540
Changes to feature_csv_activation.py omitted because they caused the
test to fail the assert in create_transaction() due to divergences in our codebases.
https://github.com/bitcoin/bitcoin/pull/13669/commits/736f9414246f2a855e7b6fc57c8f903e60530540#diff-72d4bdc0bac8c2153666b0a94544af94L50
Depends on D4820