```
This is needed when we want to encode an arbitrary number as CompactSize
like node service flags, which is a bitmask and could be bigger than the
usual size of an object.
```
Partial backport (1/4) of core PR19954:
https://github.com/bitcoin/bitcoin/pull/19954/commits/1d3ec2a1fda7446323786a52da1fd109c01aa6fb