Users running Bitcoin Core on home networks with routers that don’t support PCP (Port Control Protocol) or NAT-PMP port mapping receive frequent warning-level log messages every few minutes:
“pcp: Mapping failed with result NOT_AUTHORIZED (code 2)”
This is expected behavior for many consumer routers that have PCP disabled by default, not an actionable error. The repeated warnings create unnecessary log noise.
This change:
- Adds explicit constants for NOT_AUTHORIZED result code (value 2) for both NAT-PMP and PCP protocols
- Downgrades NOT_AUTHORIZED failures from LogWarning to LogDebug since this is an expected condition on many networks
- Keeps LogWarning for other failure types that may indicate actual configuration or network issues
The NOT_AUTHORIZED message will still be visible when running with -debug=net for users who need to troubleshoot port mapping issues.
Fixes #34114