mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-18 13:17:55 +02:00
Merge 4148e60909 into merged_master (Bitcoin PR bitcoin/bitcoin#30679)
This commit is contained in:
commit
0a977e2783
3 changed files with 74 additions and 45 deletions
94
src/init.cpp
94
src/init.cpp
|
|
@ -1284,6 +1284,53 @@ bool AppInitInterfaces(NodeContext& node)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool CheckHostPortOptions(const ArgsManager& args) {
|
||||
for (const std::string port_option : {
|
||||
"-port",
|
||||
"-rpcport",
|
||||
}) {
|
||||
if (args.IsArgSet(port_option)) {
|
||||
const std::string port = args.GetArg(port_option, "");
|
||||
uint16_t n;
|
||||
if (!ParseUInt16(port, &n) || n == 0) {
|
||||
return InitError(InvalidPortErrMsg(port_option, port));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for ([[maybe_unused]] const auto& [arg, unix] : std::vector<std::pair<std::string, bool>>{
|
||||
// arg name UNIX socket support
|
||||
{"-i2psam", false},
|
||||
{"-onion", true},
|
||||
{"-proxy", true},
|
||||
{"-rpcbind", false},
|
||||
{"-torcontrol", false},
|
||||
{"-whitebind", false},
|
||||
{"-zmqpubhashblock", true},
|
||||
{"-zmqpubhashtx", true},
|
||||
{"-zmqpubrawblock", true},
|
||||
{"-zmqpubrawtx", true},
|
||||
{"-zmqpubsequence", true},
|
||||
}) {
|
||||
for (const std::string& socket_addr : args.GetArgs(arg)) {
|
||||
std::string host_out;
|
||||
uint16_t port_out{0};
|
||||
if (!SplitHostPort(socket_addr, port_out, host_out)) {
|
||||
#ifdef HAVE_SOCKADDR_UN
|
||||
// Allow unix domain sockets for some options e.g. unix:/some/file/path
|
||||
if (!unix || !socket_addr.starts_with(ADDR_PREFIX_UNIX)) {
|
||||
return InitError(InvalidPortErrMsg(arg, socket_addr));
|
||||
}
|
||||
#else
|
||||
return InitError(InvalidPortErrMsg(arg, socket_addr));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
||||
{
|
||||
const ArgsManager& args = *Assert(node.args);
|
||||
|
|
@ -1384,6 +1431,9 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||
|
||||
// ELEMENTS:
|
||||
policyAsset = CAsset(uint256S(gArgs.GetArg("-feeasset", chainparams.GetConsensus().pegged_asset.GetHex())));
|
||||
|
||||
// Check port numbers
|
||||
if (!CheckHostPortOptions(args)) return false;
|
||||
|
||||
/* Start the RPC server already. It will be started in "warmup" mode
|
||||
* and not really process calls already (but it will signify connections
|
||||
|
|
@ -1475,50 +1525,6 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||
validation_signals.RegisterValidationInterface(fee_estimator);
|
||||
}
|
||||
|
||||
// Check port numbers
|
||||
for (const std::string port_option : {
|
||||
"-port",
|
||||
"-rpcport",
|
||||
}) {
|
||||
if (args.IsArgSet(port_option)) {
|
||||
const std::string port = args.GetArg(port_option, "");
|
||||
uint16_t n;
|
||||
if (!ParseUInt16(port, &n) || n == 0) {
|
||||
return InitError(InvalidPortErrMsg(port_option, port));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for ([[maybe_unused]] const auto& [arg, unix] : std::vector<std::pair<std::string, bool>>{
|
||||
// arg name UNIX socket support
|
||||
{"-i2psam", false},
|
||||
{"-onion", true},
|
||||
{"-proxy", true},
|
||||
{"-rpcbind", false},
|
||||
{"-torcontrol", false},
|
||||
{"-whitebind", false},
|
||||
{"-zmqpubhashblock", true},
|
||||
{"-zmqpubhashtx", true},
|
||||
{"-zmqpubrawblock", true},
|
||||
{"-zmqpubrawtx", true},
|
||||
{"-zmqpubsequence", true},
|
||||
}) {
|
||||
for (const std::string& socket_addr : args.GetArgs(arg)) {
|
||||
std::string host_out;
|
||||
uint16_t port_out{0};
|
||||
if (!SplitHostPort(socket_addr, port_out, host_out)) {
|
||||
#ifdef HAVE_SOCKADDR_UN
|
||||
// Allow unix domain sockets for some options e.g. unix:/some/file/path
|
||||
if (!unix || !socket_addr.starts_with(ADDR_PREFIX_UNIX)) {
|
||||
return InitError(InvalidPortErrMsg(arg, socket_addr));
|
||||
}
|
||||
#else
|
||||
return InitError(InvalidPortErrMsg(arg, socket_addr));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const std::string& socket_addr : args.GetArgs("-bind")) {
|
||||
std::string host_out;
|
||||
uint16_t port_out{0};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue