Bootup the masternode, look for a 16120 Lux input and register on the network
| 13 | // Bootup the masternode, look for a 16120 Lux input and register on the network |
| 14 | // |
| 15 | void CActiveMasternode::ManageStatus() { |
| 16 | std::string errorMessage; |
| 17 | |
| 18 | if (!fMasterNode) return; |
| 19 | |
| 20 | if (fDebug) LogPrintf("CActiveMasternode::ManageStatus() - Begin\n"); |
| 21 | |
| 22 | //need correct adjusted time to send ping |
| 23 | bool fIsInitialDownload = IsInitialBlockDownload(); |
| 24 | if (fIsInitialDownload) { |
| 25 | status = MASTERNODE_SYNC_IN_PROCESS; |
| 26 | LogPrintf("CActiveMasternode::ManageStatus() - Sync in progress. Must wait until sync is complete to start masternode.\n"); |
| 27 | return; |
| 28 | } |
| 29 | |
| 30 | if (status == MASTERNODE_INPUT_TOO_NEW || status == MASTERNODE_NOT_CAPABLE || status == MASTERNODE_SYNC_IN_PROCESS) { |
| 31 | status = MASTERNODE_NOT_PROCESSED; |
| 32 | } |
| 33 | |
| 34 | if (status == MASTERNODE_NOT_PROCESSED) { |
| 35 | if (strMasterNodeAddr.empty()) { |
| 36 | if (!GetLocal(service)) { |
| 37 | notCapableReason = "Can't detect external address. Please use the masternodeaddr configuration option."; |
| 38 | status = MASTERNODE_NOT_CAPABLE; |
| 39 | LogPrintf("CActiveMasternode::ManageStatus() - not capable: %s\n", notCapableReason.c_str()); |
| 40 | return; |
| 41 | } |
| 42 | } else { |
| 43 | service = CService(strMasterNodeAddr, true); |
| 44 | } |
| 45 | |
| 46 | LogPrintf("CActiveMasternode::ManageStatus() - Checking inbound connection to '%s'\n", service.ToString().c_str()); |
| 47 | |
| 48 | if (!ConnectNode(CAddress(service, NODE_NETWORK), service.ToString().c_str())) { |
| 49 | notCapableReason = "Could not connect to " + service.ToString(); |
| 50 | status = MASTERNODE_NOT_CAPABLE; |
| 51 | LogPrintf("CActiveMasternode::ManageStatus() - not capable: %s\n", notCapableReason.c_str()); |
| 52 | return; |
| 53 | } |
| 54 | |
| 55 | if (pwalletMain->IsLocked()) { |
| 56 | notCapableReason = "Wallet is locked."; |
| 57 | status = MASTERNODE_NOT_CAPABLE; |
| 58 | LogPrintf("CActiveMasternode::ManageStatus() - not capable: %s\n", notCapableReason.c_str()); |
| 59 | return; |
| 60 | } |
| 61 | |
| 62 | // Set defaults |
| 63 | status = MASTERNODE_NOT_CAPABLE; |
| 64 | notCapableReason = "Unknown. Check debug.log for more information.\n"; |
| 65 | |
| 66 | // Choose coins to use |
| 67 | CPubKey pubKeyCollateralAddress; |
| 68 | CKey keyCollateralAddress; |
| 69 | |
| 70 | if (GetMasterNodeVin(vin, pubKeyCollateralAddress, keyCollateralAddress)) { |
| 71 | if (GetInputAge(vin) < MASTERNODE_MIN_CONFIRMATIONS) { |
| 72 | LogPrintf("CActiveMasternode::ManageStatus() - Input must have least %d confirmations - %d confirmations\n", MASTERNODE_MIN_CONFIRMATIONS, GetInputAge(vin)); |
no test coverage detected