@@ -74,7 +74,7 @@ void print_banner(const char* argv0)
7474 << " " << argv0 << " --with-peer-verify [--testnet] [--peer HOST:PORT] [--max-seconds N]\n "
7575 << " " << argv0 << " --leg-c-capture [--rpc-conf PATH]\n "
7676 << " " << argv0 << " --leg-c-capture-p2p [--rpc-conf PATH] [--p2p-port N]\n "
77- << " " << argv0 << " --pool [--testnet|--regtest] [--stratum [HOST:]PORT] [--peer HOST:PORT] [--anchor N]\n\n "
77+ << " " << argv0 << " --pool [--testnet|--regtest] [--stratum [HOST:]PORT] [--peer HOST:PORT] [--anchor N] [--rpc-conf PATH] \n\n "
7878 << " Status: M5 pool/sharechain + embedded-daemon assembly live.\n "
7979 << " The embedded daemon (coin/embedded_daemon.hpp) is the primary\n "
8080 << " work source; external BCHN-RPC stays as the fallback.\n "
@@ -605,7 +605,8 @@ int run_leg_c_capture_p2p(const std::string& conf_path, uint16_t p2p_port)
605605// share/PPLNS/coinbase/PoW bytes. PER-COIN ISOLATION: src/impl/bch only.
606606int run_pool (const std::string& peer_host, uint16_t peer_port, bool testnet,
607607 bool regtest, uint32_t anchor_height,
608- const std::string& stratum_addr, uint16_t stratum_port)
608+ const std::string& stratum_addr, uint16_t stratum_port,
609+ const std::string& rpc_conf)
609610{
610611 boost::asio::io_context ioc;
611612
@@ -629,6 +630,25 @@ int run_pool(const std::string& peer_host, uint16_t peer_port, bool testnet,
629630 // framing. standup_pool_run's Node reads pool()->m_prefix.
630631 config.pool ()->m_prefix = ParseHexBytes (bch::PoolConfig::prefix_hex ());
631632
633+ // External BCHN-RPC fallback endpoint (v36 external_fallback invariant): the
634+ // embedded daemon is the PRIMARY work source, but coin::Node::init_rpc still
635+ // binds the external RPC as the fallback sink + eager getwork prime. run_pool
636+ // builds config by hand (no YAML load), so m_rpc stays unset -- and an unset
637+ // endpoint yields "Connection refused", leaving only the embedded leg. Load
638+ // host:port + creds from --rpc-conf (operator node, e.g. testnet4 :28332).
639+ if (!rpc_conf.empty ()) {
640+ RegtestRpcConf rc;
641+ if (load_rpc_conf (rpc_conf, rc)) {
642+ config.coin ()->m_rpc .address = NetService (std::string (" 127.0.0.1" ), rc.port );
643+ config.coin ()->m_rpc .userpass = rc.user + " :" + rc.pass ;
644+ std::cout << " [pool] external BCHN-RPC fallback -> 127.0.0.1:" << rc.port
645+ << " (from " << rpc_conf << " )\n " ;
646+ } else {
647+ std::cout << " [pool] WARN: --rpc-conf " << rpc_conf
648+ << " has no rpcuser/rpcpassword; RPC fallback endpoint unset\n " ;
649+ }
650+ }
651+
632652 std::cout
633653 << " [pool] c2pool-bch pool run-loop"
634654 << (regtest ? " (regtest)" : (testnet ? " (testnet)" : " (mainnet)" ))
@@ -738,7 +758,7 @@ int main(int argc, char** argv)
738758 }
739759
740760 if (want_pool)
741- return run_pool (host, port, testnet, regtest, anchor_height, stratum_addr, stratum_port);
761+ return run_pool (host, port, testnet, regtest, anchor_height, stratum_addr, stratum_port, rpc_conf );
742762
743763 if (want_with_peer_verify)
744764 return run_with_peer_verify (host, port, testnet, max_seconds);
0 commit comments