PIVX Core  5.6.99
P2P Digital Currency
activemasternode.cpp
Go to the documentation of this file.
1 // Copyright (c) 2014-2016 The Dash developers
2 // Copyright (c) 2015-2022 The PIVX Core developers
3 // Distributed under the MIT/X11 software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #include "activemasternode.h"
7 
8 #include "addrman.h"
9 #include "bls/key_io.h"
10 #include "bls/bls_wrapper.h"
11 #include "masternode.h"
12 #include "masternodeconfig.h"
13 #include "masternodeman.h"
14 #include "messagesigner.h"
15 #include "netbase.h"
16 #include "protocol.h"
19 #include "validation.h"
20 
21 // Keep track of the active Masternode
23 
24 static bool GetLocalAddress(CService& addrRet)
25 {
26  // First try to find whatever our own local address is known internally.
27  // Addresses could be specified via 'externalip' or 'bind' option, discovered via UPnP
28  // or added by TorController. Use some random dummy IPv4 peer to prefer the one
29  // reachable via IPv4.
30  CNetAddr addrDummyPeer;
31  bool fFound{false};
32  if (LookupHost("8.8.8.8", addrDummyPeer, false)) {
33  fFound = GetLocal(addrRet, &addrDummyPeer) && CActiveDeterministicMasternodeManager::IsValidNetAddr(addrRet);
34  }
35  if (!fFound && Params().IsRegTestNet()) {
36  if (Lookup("127.0.0.1", addrRet, GetListenPort(), false)) {
37  fFound = true;
38  }
39  }
40  if (!fFound) {
41  // If we have some peers, let's try to find our local address from one of them
42  g_connman->ForEachNodeContinueIf([&fFound, &addrRet](CNode* pnode) {
43  if (pnode->addr.IsIPv4())
44  fFound = GetLocal(addrRet, &pnode->addr) && CActiveDeterministicMasternodeManager::IsValidNetAddr(addrRet);
45  return !fFound;
46  });
47  }
48  return fFound;
49 }
50 
52 {
53  switch (state) {
54  case MASTERNODE_WAITING_FOR_PROTX: return "Waiting for ProTx to appear on-chain";
55  case MASTERNODE_POSE_BANNED: return "Masternode was PoSe banned";
56  case MASTERNODE_REMOVED: return "Masternode removed from list";
57  case MASTERNODE_OPERATOR_KEY_CHANGED: return "Operator key changed or revoked";
58  case MASTERNODE_PROTX_IP_CHANGED: return "IP address specified in ProTx changed";
59  case MASTERNODE_READY: return "Ready";
60  case MASTERNODE_ERROR: return "Error. " + strError;
61  default: return "Unknown";
62  }
63 }
64 
66 {
67  LOCK(cs_main); // Lock cs_main so the node doesn't perform any action while we setup the Masternode
68  LogPrintf("Initializing deterministic masternode...\n");
69  if (strMNOperatorPrivKey.empty()) {
70  return errorOut("ERROR: Masternode operator priv key cannot be empty.");
71  }
72 
73  auto opSk = bls::DecodeSecret(Params(), strMNOperatorPrivKey);
74  if (!opSk) {
75  return errorOut(_("Invalid mnoperatorprivatekey. Please see the documentation."));
76  }
77  info.keyOperator = *opSk;
79  return {true};
80 }
81 
83 {
84  if (!IsReady()) {
85  return errorOut("Active masternode not ready");
86  }
87  dmn = deterministicMNManager->GetListAtChainTip().GetValidMN(info.proTxHash);
88  if (!dmn) {
89  return errorOut(strprintf("Active masternode %s not registered or PoSe banned", info.proTxHash.ToString()));
90  }
91  if (info.pubKeyOperator != dmn->pdmnState->pubKeyOperator.Get()) {
92  return errorOut("Active masternode operator key changed or revoked");
93  }
94  // return key
95  key = info.keyOperator;
96  return {true};
97 }
98 
100 {
101  // set masternode arg if called from RPC
102  if (!fMasterNode) {
103  gArgs.ForceSetArg("-masternode", "1");
104  fMasterNode = true;
105  }
106 
107  if (!deterministicMNManager->IsDIP3Enforced(pindexTip->nHeight)) {
109  strError = "Evo upgrade is not active yet.";
110  LogPrintf("%s -- ERROR: %s\n", __func__, strError);
111  return;
112  }
113 
114  LOCK(cs_main);
115 
116  // Check that our local network configuration is correct
117  if (!fListen) {
118  // listen option is probably overwritten by smth else, no good
120  strError = "Masternode must accept connections from outside. Make sure listen configuration option is not overwritten by some another parameter.";
121  LogPrintf("%s ERROR: %s\n", __func__, strError);
122  return;
123  }
124 
125  if (!GetLocalAddress(info.service)) {
127  strError = "Can't detect valid external address. Please consider using the externalip configuration option if problem persists. Make sure to use IPv4 address only.";
128  LogPrintf("%s ERROR: %s\n", __func__, strError);
129  return;
130  }
131 
132  CDeterministicMNList mnList = deterministicMNManager->GetListForBlock(pindexTip);
133 
135  if (!dmn) {
136  // MN not appeared on the chain yet
137  return;
138  }
139 
140  if (dmn->IsPoSeBanned()) {
142  return;
143  }
144 
145  LogPrintf("%s: proTxHash=%s, proTx=%s\n", __func__, dmn->proTxHash.ToString(), dmn->ToString());
146 
147  if (info.service != dmn->pdmnState->addr) {
149  strError = strprintf("Local address %s does not match the address from ProTx (%s)",
150  info.service.ToStringIPPort(), dmn->pdmnState->addr.ToStringIPPort());
151  LogPrintf("%s ERROR: %s\n", __func__, strError);
152  return;
153  }
154 
155  // Check socket connectivity
156  const std::string& strService = info.service.ToString();
157  LogPrintf("%s: Checking inbound connection to '%s'\n", __func__, strService);
158  SOCKET hSocket = CreateSocket(info.service);
159  if (hSocket == INVALID_SOCKET) {
161  strError = "DMN connectivity check failed, could not create socket to DMN running at " + strService;
162  LogPrintf("%s -- ERROR: %s\n", __func__, strError);
163  return;
164  }
165  bool fConnected = ConnectSocketDirectly(info.service, hSocket, nConnectTimeout, true) && IsSelectableSocket(hSocket);
166  CloseSocket(hSocket);
167 
168  if (!fConnected) {
170  strError = "DMN connectivity check failed, could not connect to DMN running at " + strService;
171  LogPrintf("%s ERROR: %s\n", __func__, strError);
172  return;
173  }
174 
175  info.proTxHash = dmn->proTxHash;
176  g_connman->GetTierTwoConnMan()->setLocalDMN(info.proTxHash);
178  LogPrintf("Deterministic Masternode initialized\n");
179 }
180 
182 {
183  state = _state;
184  SetNullProTx();
185  // MN might have reappeared in same block with a new ProTx
186  Init(pindexTip);
187 }
188 
189 void CActiveDeterministicMasternodeManager::UpdatedBlockTip(const CBlockIndex* pindexNew, const CBlockIndex* pindexFork, bool fInitialDownload)
190 {
191  if (fInitialDownload)
192  return;
193 
194  if (!fMasterNode || !deterministicMNManager->IsDIP3Enforced(pindexNew->nHeight))
195  return;
196 
197  if (state == MASTERNODE_READY) {
198  auto newDmn = deterministicMNManager->GetListForBlock(pindexNew).GetValidMN(info.proTxHash);
199  if (newDmn == nullptr) {
200  // MN disappeared from MN list
201  Reset(MASTERNODE_REMOVED, pindexNew);
202  return;
203  }
204 
205  auto oldDmn = deterministicMNManager->GetListForBlock(pindexNew->pprev).GetMN(info.proTxHash);
206  if (oldDmn == nullptr) {
207  // should never happen if state is MASTERNODE_READY
208  LogPrintf("%s: WARNING: unable to find active mn %s in prev block list %s\n",
209  __func__, info.proTxHash.ToString(), pindexNew->pprev->GetBlockHash().ToString());
210  return;
211  }
212 
213  if (newDmn->pdmnState->pubKeyOperator != oldDmn->pdmnState->pubKeyOperator) {
214  // MN operator key changed or revoked
216  return;
217  }
218 
219  if (newDmn->pdmnState->addr != oldDmn->pdmnState->addr) {
220  // MN IP changed
222  return;
223  }
224  } else {
225  // MN might have (re)appeared with a new ProTx or we've found some peers
226  // and figured out our local address
227  Init(pindexNew);
228  }
229 }
230 
232 {
233  // TODO: check IPv6 and TOR addresses
234  return Params().IsRegTestNet() || (addrIn.IsIPv4() && IsReachable(addrIn) && addrIn.IsRoutable());
235 }
236 
237 
238 /********* LEGACY *********/
239 
240 OperationResult initMasternode(const std::string& _strMasterNodePrivKey, const std::string& _strMasterNodeAddr, bool isFromInit)
241 {
242  if (!isFromInit && fMasterNode) {
243  return errorOut( "ERROR: Masternode already initialized.");
244  }
245 
246  LOCK(cs_main); // Lock cs_main so the node doesn't perform any action while we setup the Masternode
247  LogPrintf("Initializing masternode, addr %s..\n", _strMasterNodeAddr.c_str());
248 
249  if (_strMasterNodePrivKey.empty()) {
250  return errorOut("ERROR: Masternode priv key cannot be empty.");
251  }
252 
253  if (_strMasterNodeAddr.empty()) {
254  return errorOut("ERROR: Empty masternodeaddr");
255  }
256 
257  // Address parsing.
258  const CChainParams& params = Params();
259  int nPort = 0;
260  int nDefaultPort = params.GetDefaultPort();
261  std::string strHost;
262  SplitHostPort(_strMasterNodeAddr, nPort, strHost);
263 
264  // Allow for the port number to be omitted here and just double check
265  // that if a port is supplied, it matches the required default port.
266  if (nPort == 0) nPort = nDefaultPort;
267  if (nPort != nDefaultPort && !params.IsRegTestNet()) {
268  return errorOut(strprintf(_("Invalid -masternodeaddr port %d, only %d is supported on %s-net."),
269  nPort, nDefaultPort, Params().NetworkIDString()));
270  }
271  CService addrTest(LookupNumeric(strHost, nPort));
272  if (!addrTest.IsValid()) {
273  return errorOut(strprintf(_("Invalid -masternodeaddr address: %s"), _strMasterNodeAddr));
274  }
275 
276  // Peer port needs to match the masternode public one for IPv4 and IPv6.
277  // Onion can run in other ports because those are behind a hidden service which has the public port fixed to the default port.
278  if (nPort != GetListenPort() && !addrTest.IsTor()) {
279  return errorOut(strprintf(_("Invalid -masternodeaddr port %d, isn't the same as the peer port %d"),
280  nPort, GetListenPort()));
281  }
282 
283  CKey key;
284  CPubKey pubkey;
285  if (!CMessageSigner::GetKeysFromSecret(_strMasterNodePrivKey, key, pubkey)) {
286  return errorOut(_("Invalid masternodeprivkey. Please see the documentation."));
287  }
288 
291  activeMasternode.service = addrTest;
292  fMasterNode = true;
293 
295  // Check if the masternode already exists in the list
296  CMasternode* pmn = mnodeman.Find(pubkey);
297  if (pmn) activeMasternode.EnableHotColdMasterNode(pmn->vin, pmn->addr);
298  }
299 
300  return {true};
301 }
302 
303 //
304 // Bootup the Masternode, look for a 10000 PIVX input and register on the network
305 //
307 {
308  if (!fMasterNode) return;
309  if (activeMasternodeManager != nullptr) {
310  // Deterministic masternode
311  return;
312  }
313 
314  // !TODO: Legacy masternodes - remove after enforcement
315  LogPrint(BCLog::MASTERNODE, "CActiveMasternode::ManageStatus() - Begin\n");
316 
317  // If a DMN has been registered with same collateral, disable me.
319  if (pmn && deterministicMNManager->GetListAtChainTip().HasMNByCollateral(pmn->vin.prevout)) {
320  LogPrintf("%s: Disabling active legacy Masternode %s as the collateral is now registered with a DMN\n",
321  __func__, pmn->vin.prevout.ToString());
323  notCapableReason = "Collateral registered with DMN";
324  return;
325  }
326 
327  //need correct blocks to send ping
328  if (!Params().IsRegTestNet() && !g_tiertwo_sync_state.IsBlockchainSynced()) {
330  LogPrintf("CActiveMasternode::ManageStatus() - %s\n", GetStatusMessage());
331  return;
332  }
333 
335 
337  if (pmn) {
338  if (pmn->protocolVersion != PROTOCOL_VERSION) {
339  LogPrintf("%s: ERROR Trying to start a masternode running an old protocol version, " /* Continued */
340  "the controller and masternode wallets need to be running the latest release version.\n", __func__);
341  return;
342  }
343  // Update vin and service
344  EnableHotColdMasterNode(pmn->vin, pmn->addr);
345  }
346  }
347 
349  // Set defaults
351  notCapableReason = "";
352 
353  LogPrintf("%s - Checking inbound connection for masternode to '%s'\n", __func__ , service.ToString());
354 
356  if (!g_connman->IsNodeConnected(addr)) {
357  CNode* node = g_connman->ConnectNode(addr);
358  if (!node) {
360  "Masternode address:port connection availability test failed, could not open a connection to the public masternode address (" +
361  service.ToString() + ")";
362  LogPrintf("%s - not capable: %s\n", __func__, notCapableReason);
363  } else {
364  // don't leak allocated object in memory
365  delete node;
366  }
367  return;
368  }
369 
370  notCapableReason = "Waiting for start message from controller.";
371  return;
372  }
373 
374  //send to all peers
375  std::string errorMessage;
376  if (!SendMasternodePing(errorMessage)) {
377  LogPrintf("CActiveMasternode::ManageStatus() - Error on Ping: %s\n", errorMessage);
378  }
379 }
380 
382 {
384  ManageStatus();
385 }
386 
388 {
389  switch (status) {
391  return "Node just started, not yet activated";
393  return "Sync in progress. Must wait until sync is complete to start Masternode";
395  return "Not capable masternode: " + notCapableReason;
397  return "Masternode successfully started";
398  default:
399  return "unknown";
400  }
401 }
402 
403 bool CActiveMasternode::SendMasternodePing(std::string& errorMessage)
404 {
405  if (vin == nullopt) {
406  errorMessage = "Active Masternode not initialized";
407  return false;
408  }
409 
411  errorMessage = "Masternode is not in a running status";
412  return false;
413  }
414 
416  errorMessage = "Error upon masternode key.\n";
417  return false;
418  }
419 
420  LogPrintf("CActiveMasternode::SendMasternodePing() - Relay Masternode Ping vin = %s\n", vin->ToString());
421 
422  const uint256& nBlockHash = mnodeman.GetBlockHashToPing();
423  CMasternodePing mnp(*vin, nBlockHash, GetAdjustedTime());
425  errorMessage = "Couldn't sign Masternode Ping";
426  return false;
427  }
428 
429  // Update lastPing for our masternode in Masternode list
430  CMasternode* pmn = mnodeman.Find(vin->prevout);
431  if (pmn != nullptr) {
432  if (pmn->IsPingedWithin(MasternodePingSeconds(), mnp.sigTime)) {
433  errorMessage = "Too early to send Masternode Ping";
434  return false;
435  }
436 
437  // SetLastPing locks the masternode cs, be careful with the lock order.
438  pmn->SetLastPing(mnp);
439  mnodeman.mapSeenMasternodePing.emplace(mnp.GetHash(), mnp);
440 
441  //mnodeman.mapSeenMasternodeBroadcast.lastPing is probably outdated, so we'll update it
442  CMasternodeBroadcast mnb(*pmn);
443  uint256 hash = mnb.GetHash();
444  if (mnodeman.mapSeenMasternodeBroadcast.count(hash)) {
445  // SetLastPing locks the masternode cs, be careful with the lock order.
446  // TODO: check why are we double setting the last ping here..
447  mnodeman.mapSeenMasternodeBroadcast[hash].SetLastPing(mnp);
448  }
449 
450  mnp.Relay();
451  return true;
452 
453  } else {
454  // Seems like we are trying to send a ping while the Masternode is not registered in the network
455  errorMessage = "Masternode List doesn't include our Masternode, shutting down Masternode pinging service! " + vin->ToString();
457  notCapableReason = errorMessage;
458  return false;
459  }
460 }
461 
462 // when starting a Masternode, this can enable to run as a hot wallet with no funds
464 {
465  if (!fMasterNode) return false;
466 
468 
469  //The values below are needed for signing mnping messages going forward
470  vin = newVin;
471  service = newService;
472 
473  LogPrintf("CActiveMasternode::EnableHotColdMasterNode() - Enabled! You may shut down the cold daemon.\n");
474 
475  return true;
476 }
477 
478 void CActiveMasternode::GetKeys(CKey& _privKeyMasternode, CPubKey& _pubKeyMasternode) const
479 {
481  throw std::runtime_error("Error trying to get masternode keys");
482  }
483  _privKeyMasternode = privKeyMasternode;
484  _pubKeyMasternode = pubKeyMasternode;
485 }
486 
488 {
489  if (activeMasternodeManager == nullptr) {
490  return error("%s: Active Masternode not initialized", __func__);
491  }
493  auto res = activeMasternodeManager->GetOperatorKey(key, dmn);
494  if (!res) {
495  return error("%s: %s", __func__, res.getError());
496  }
497  vin = CTxIn(dmn->collateralOutpoint);
498  return true;
499 }
500 
502 {
503  if (activeMasternodeManager != nullptr) {
504  // deterministic mn
505  key = nullopt;
506  return GetActiveDMNKeys(blsKey, vin);
507  }
508  // legacy mn
509  if (activeMasternode.vin == nullopt) {
510  return error("%s: Active Masternode not initialized", __func__);
511  }
513  return error("%s: MN not started (%s)", __func__, activeMasternode.GetStatusMessage());
514  }
515  vin = *activeMasternode.vin;
516  CKey sk;
517  CPubKey pk;
518  activeMasternode.GetKeys(sk, pk);
519  key = Optional<CKey>(sk);
520  blsKey.Reset();
521  return true;
522 }
OperationResult initMasternode(const std::string &_strMasterNodePrivKey, const std::string &_strMasterNodeAddr, bool isFromInit)
CActiveDeterministicMasternodeManager * activeMasternodeManager
bool GetActiveDMNKeys(CBLSSecretKey &key, CTxIn &vin)
bool GetActiveMasternodeKeys(CTxIn &vin, Optional< CKey > &key, CBLSSecretKey &blsKey)
#define ACTIVE_MASTERNODE_NOT_CAPABLE
#define ACTIVE_MASTERNODE_SYNC_IN_PROCESS
#define ACTIVE_MASTERNODE_STARTED
#define ACTIVE_MASTERNODE_INITIAL
const CChainParams & Params()
Return the currently selected parameters.
void ForceSetArg(const std::string &strArg, const std::string &strValue)
Definition: system.cpp:489
void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) override
Notifies listeners when the block chain tip advances.
static bool IsValidNetAddr(const CService &addrIn)
void Reset(masternode_state_t _state, const CBlockIndex *pindexTip)
OperationResult SetOperatorKey(const std::string &strMNOperatorPrivKey)
void Init(const CBlockIndex *pindexTip)
OperationResult GetOperatorKey(CBLSSecretKey &key, CDeterministicMNCPtr &dmn) const
bool EnableHotColdMasterNode(CTxIn &vin, CService &addr)
Enable cold wallet mode (run a Masternode with no funds)
Optional< CTxIn > vin
void ManageStatus()
Manage status of main Masternode.
std::string GetStatusMessage() const
void GetKeys(CKey &privKeyMasternode, CPubKey &pubKeyMasternode) const
std::string notCapableReason
bool SendMasternodePing(std::string &errorMessage)
Ping Masternode.
A CService with information about it as peer.
Definition: protocol.h:338
CBLSPublicKey GetPublicKey() const
Definition: bls_wrapper.cpp:99
void Reset()
Definition: bls_wrapper.h:92
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: chain.h:139
CBlockIndex * pprev
pointer to the index of the predecessor of this block
Definition: chain.h:145
uint256 GetBlockHash() const
Definition: chain.h:215
int nHeight
height of the entry in the chain. The genesis block has height 0
Definition: chain.h:151
CChainParams defines various tweakable parameters of a given instance of the PIVX system.
Definition: chainparams.h:43
int GetDefaultPort() const
Definition: chainparams.h:74
bool IsRegTestNet() const
Definition: chainparams.h:98
CDeterministicMNCPtr GetMNByOperatorKey(const CBLSPublicKey &pubKey)
An encapsulated private key.
Definition: key.h:30
bool IsValid() const
Check whether this private key is valid.
Definition: key.h:95
uint256 GetHash() const
Definition: masternode.cpp:481
CService addr
Definition: masternode.h:97
void SetLastPing(const CMasternodePing &_lastPing)
Definition: masternode.h:118
CTxIn vin
Definition: masternode.h:96
int protocolVersion
Definition: masternode.h:101
bool IsPingedWithin(int seconds, int64_t now=-1) const
Definition: masternode.h:174
std::map< uint256, CMasternodeBroadcast > mapSeenMasternodeBroadcast
Definition: masternodeman.h:93
uint256 GetBlockHashToPing() const
std::map< uint256, CMasternodePing > mapSeenMasternodePing
Definition: masternodeman.h:95
CMasternode * Find(const COutPoint &collateralOut)
Find an entry.
int64_t sigTime
Definition: masternode.h:46
uint256 GetHash() const
Definition: masternode.cpp:503
static bool GetKeysFromSecret(const std::string &strSecret, CKey &keyRet, CPubKey &pubkeyRet)
Set the private/public key values, returns true if successful.
Network address.
Definition: netaddress.h:120
bool IsTor() const
Check whether this object represents a TOR address.
Definition: netaddress.cpp:390
bool IsRoutable() const
Definition: netaddress.cpp:454
bool IsValid() const
Definition: netaddress.cpp:418
bool IsIPv4() const
Definition: netaddress.cpp:295
Information about a peer.
Definition: net.h:669
const CAddress addr
Definition: net.h:698
std::string ToString() const
Definition: transaction.cpp:18
An encapsulated public key.
Definition: pubkey.h:44
CKeyID GetID() const
Get the KeyID of this public key (hash of its serialization)
Definition: pubkey.h:167
bool IsValid() const
Definition: pubkey.h:183
A combination of a network address (CNetAddr) and a (TCP) port.
Definition: netaddress.h:484
std::string ToStringIPPort() const
Definition: netaddress.cpp:945
std::string ToString() const
Definition: netaddress.cpp:954
bool Sign(const CKey &key, const CKeyID &keyID)
CSignedMessage Class Functions inherited by network signed-messages.
An input of a transaction.
Definition: transaction.h:94
COutPoint prevout
Definition: transaction.h:96
bool IsBlockchainSynced() const
std::string ToString() const
Definition: uint256.cpp:65
256-bit opaque blob.
Definition: uint256.h:138
#define INVALID_SOCKET
Definition: compat.h:64
u_int SOCKET
Definition: compat.h:53
std::unique_ptr< CDeterministicMNManager > deterministicMNManager
std::shared_ptr< const CDeterministicMN > CDeterministicMNCPtr
std::unique_ptr< CConnman > g_connman
Definition: init.cpp:90
@ LOCK
Definition: lockunlock.h:16
#define LogPrint(category,...)
Definition: logging.h:163
int MasternodePingSeconds()
Definition: masternode.cpp:38
CMasternodeMan mnodeman
Masternode manager.
CActiveMasternode activeMasternode
Keep track of the active Masternode.
@ MASTERNODE
Definition: logging.h:59
Optional< CBLSSecretKey > DecodeSecret(const CChainParams &params, const std::string &keyStr)
Definition: key_io.cpp:63
uint16_t GetListenPort()
Definition: net.cpp:104
bool fListen
Definition: net.cpp:90
bool GetLocal(CService &addr, const CNetAddr *paddrPeer)
Definition: net.cpp:110
bool IsReachable(enum Network net)
Definition: net.cpp:253
RecursiveMutex cs_main
Global state.
Definition: validation.cpp:80
void SplitHostPort(std::string in, int &portOut, std::string &hostOut)
Definition: netbase.cpp:71
bool Lookup(const std::string &name, std::vector< CService > &vAddr, int portDefault, bool fAllowLookup, unsigned int nMaxSolutions)
Definition: netbase.cpp:177
CService LookupNumeric(const std::string &name, int portDefault)
Definition: netbase.cpp:209
bool LookupHost(const std::string &name, std::vector< CNetAddr > &vIP, unsigned int nMaxSolutions, bool fAllowLookup)
Definition: netbase.cpp:149
int nConnectTimeout
Definition: netbase.cpp:39
bool ConnectSocketDirectly(const CService &addrConnect, const SOCKET &hSocket, int nTimeout, bool manual_connection)
Definition: netbase.cpp:535
bool CloseSocket(SOCKET &hSocket)
Close socket and set hSocket to INVALID_SOCKET.
Definition: netbase.cpp:742
SOCKET CreateSocket(const CService &addrConnect)
Definition: netbase.cpp:490
OperationResult errorOut(const std::string &errorStr)
boost::optional< T > Optional
Substitute for C++17 std::optional.
Definition: optional.h:12
@ NODE_NETWORK
Definition: protocol.h:318
CBLSSecretKey keyOperator
CBLSPublicKey pubKeyOperator
ArgsManager gArgs
Definition: system.cpp:89
std::atomic< bool > fMasterNode
Definition: system.cpp:87
bool error(const char *fmt, const Args &... args)
Definition: system.h:77
std::string _(const char *psz)
Translation function: Call Translate signal on UI interface, which returns a Optional result.
Definition: system.h:65
TierTwoSyncState g_tiertwo_sync_state
int64_t GetAdjustedTime()
Definition: timedata.cpp:36
#define strprintf
Definition: tinyformat.h:1056