This diffs fixes the assertions introduced in D3232 and adds a linter to
avoid reproducing the issue.
The fix is a backport of core PR14088
https://github.com/bitcoin/bitcoin/pull/14088/files
The linter is based on the second commit, but integrated into arcanist.