Repository: bitcoin/bitcoin
File: src/init.cpp (C++)

Code before:
                suffix_allowed ? param_value.substr(0, param_value.rfind('=')) : param_value};
            std::string host_out;
            uint16_t port_out{0};
            if (!SplitHostPort(param_value_hostport, port_out, host_out)) {
#ifdef HAVE_SOCKADDR_UN
                // Allow unix domain sockets for some options e.g. unix:/some/file/path
                if (!unix || !param_value.starts_with(ADDR_PREFIX_UNIX)) {
                    return InitError(InvalidPortErrMsg(param_name, param_value));
                }
#else
                return InitError(InvalidPortErrMsg(param_name, param_value));
#endif
            }
        }
    }

    return true;
}

/**
 * @brief Checks for duplicate bindings across all binding configuration.
 *
 * @param connOptions Connection options containing the binding vectors to check
 * @return std::optional<CService> containing the first duplicate found, or std::nullopt if no duplicates
 */
std::optional<CService> CheckBindingConflicts(const CConnman::Options& connOptions)
{
    std::set<CService> seen;

    // Check all whitelisted bindings
    for (const auto& wb : connOptions.vWhiteBinds) {
        if (!seen.insert(wb.m_service).second) {
            return wb.m_service;
        }
    }

    // Check regular bindings
    for (const auto& bind : connOptions.vBinds) {
        if (!seen.insert(bind).second) {
            return bind;
        }
    }

    // Check onion bindings
    for (const auto& onion_bind : connOptions.onion_binds) {
        if (!seen.insert(onion_bind).second) {
            return onion_bind;
        }
    }

    return std::nullopt;

Review comment (suggestion):
Since the new function is used only in this file:

```suggestion
static std::optional<CService> CheckBindingConflicts(const CConnman::Options& connOptions)
```

Code after:
                suffix_allowed ? param_value.substr(0, param_value.rfind('=')) : param_value};
            std::string host_out;
            uint16_t port_out{0};
            if (!SplitHostPort(param_value_hostport, port_out, host_out)) {
#ifdef HAVE_SOCKADDR_UN
                // Allow unix domain sockets for some options e.g. unix:/some/file/path
                if (!unix || !param_value.starts_with(ADDR_PREFIX_UNIX)) {
                    return InitError(InvalidPortErrMsg(param_name, param_value));
                }
#else
                return InitError(InvalidPortErrMsg(param_name, param_value));
#endif
            }
        }
    }

    return true;
}

/**
 * @brief Checks for duplicate bindings across all binding configurations.
 *
 * @param[in] conn_options Connection options containing the binding vectors to check
 * @return std::optional<CService> containing the first duplicate found, or std::nullopt if no duplicates
 */
static std::optional<CService> CheckBindingConflicts(const CConnman::Options& conn_options)
{
    std::set<CService> seen;

    // Check all whitelisted bindings
    for (const auto& wb : conn_options.vWhiteBinds) {
        if (!seen.insert(wb.m_service).second) {
            return wb.m_service;
        }
    }

    // Check regular bindings
    for (const auto& bind : conn_options.vBinds) {
        if (!seen.insert(bind).second) {
            return bind;
        }
    }

    // Check onion bindings
    for (const auto& onion_bind : conn_options.onion_binds) {
        if (!seen.insert(onion_bind).second) {
            return onion_bind;
        }
    }

    return std::nullopt;