net, refactor: Refactor CBaseChainParams::RPCPort function
net, refactor: Refactor CBaseChainParams::RPCPort function

Summary:
This is a backport of [[https://github.com/bitcoin/bitcoin/pull/19991 | core#19991]] [3/8]
https://github.com/bitcoin/bitcoin/pull/19991/commits/fdd3ae4d264f26f87009879838dec035db5a7aed

Depends on D10445

Test Plan: `ninja all check-all`

Reviewers: #bitcoin_abc, majcosta

Reviewed By: #bitcoin_abc, majcosta

Differential Revision: https://reviews.bitcoinabc.org/D10446

Bitcoin-ABC/bitcoin-abc,Bitcoin-ABC/bitcoin-abc,Bitcoin-ABC/bitcoin-abc,Bitcoin-ABC/bitcoin-abc,Bitcoin-ABC/bitcoin-abc,Bitcoin-ABC/bitcoin-abc,Bitcoin-ABC/bitcoin-abc,Bitcoin-ABC/bitcoin-abc,Bitcoin-ABC/bitcoin-abc,Bitcoin-ABC/bitcoin-abc,Bitcoin-ABC/bitcoin-abc,Bitcoin-ABC/bitcoin-abc,Bitcoin-ABC/bitcoin-abc