src/activemasternode.cpp
//
// Bootup the masternode, look for a 25000 NTRN input and register on the network
//
Bootup the masternode, look for a 25000 NTRN input and register on the network
Bootup the masternode look for a 25000 NTRN input and register on the network
void CActiveMasternode::ManageStatus(CConnman& connman)
{
    std::string errorMessage;
    if(!fMasterNode) return;
    LogPrintf("CActiveMasternode::ManageStatus() - Begin\n");
    bool fIsInitialDownload = IsInitialBlockDownload();
    if(fIsInitialDownload) {
        status = MASTERNODE_SYNC_IN_PROCESS;
        LogPrintf("CActiveMasternode::ManageStatus() - Sync in progress. Must wait until sync is complete to start masternode.\n");
        return;
    }
    if(status == MASTERNODE_INPUT_TOO_NEW || status == MASTERNODE_NOT_CAPABLE || status == MASTERNODE_SYNC_IN_PROCESS){
        status = MASTERNODE_NOT_PROCESSED;
    }
    if(status == MASTERNODE_NOT_PROCESSED) {
        if(strMasterNodeAddr.empty()) {
            if(!GetLocal(service)) {
                notCapableReason = "Can't detect external address. Please use the masternodeaddr configuration option.";
                status = MASTERNODE_NOT_CAPABLE;
                LogPrintf("CActiveMasternode::ManageStatus() - not capable: %s\n", notCapableReason.c_str());
                return;
            }
        } else {
            service = CService(strMasterNodeAddr);
        }
        LogPrintf("CActiveMasternode::ManageStatus() - Checking inbound connection to '%s'\n", service.ToString().c_str());
        if(!connman.ConnectNode((CAddress)service, service.ToString().c_str())){
            notCapableReason = "Could not connect to " + service.ToString();
            status = MASTERNODE_NOT_CAPABLE;
            LogPrintf("CActiveMasternode::ManageStatus() - not capable: %s\n", notCapableReason.c_str());
            return;
        }
        if(pwalletMain->IsLocked()){
            notCapableReason = "Wallet is locked.";
            status = MASTERNODE_NOT_CAPABLE;
            LogPrintf("CActiveMasternode::ManageStatus() - not capable: %s\n", notCapableReason.c_str());
            return;
        }
        status = MASTERNODE_NOT_CAPABLE;
        notCapableReason = "Unknown. Check debug.log for more information.\n";
        CPubKey pubKeyCollateralAddress;
        CKey keyCollateralAddress;
        if(GetMasterNodeVin(vin, pubKeyCollateralAddress, keyCollateralAddress)) {
            if(GetInputAge(vin) < MASTERNODE_MIN_CONFIRMATIONS){
                LogPrintf("CActiveMasternode::ManageStatus() - Input must have least %d confirmations - %d confirmations\n", MASTERNODE_MIN_CONFIRMATIONS, GetInputAge(vin));
                status = MASTERNODE_INPUT_TOO_NEW;
                return;
            }
            LogPrintf("CActiveMasternode::ManageStatus() - Is capable master node!\n");
            status = MASTERNODE_IS_CAPABLE;
            notCapableReason = "";
            pwalletMain->LockCoin(vin.prevout);
            CPubKey pubKeyMasternode;
            CKey keyMasternode;
            if(!darkSendSigner.SetKey(strMasterNodePrivKey, errorMessage, keyMasternode, pubKeyMasternode))
            {
                LogPrintf("Register::ManageStatus() - Error upon calling SetKey: %s\n", errorMessage.c_str());
                return;
            }
            if(!Register(vin, service, keyCollateralAddress, pubKeyCollateralAddress, keyMasternode, pubKeyMasternode, errorMessage)) {
                LogPrintf("CActiveMasternode::ManageStatus() - Error on Register: %s\n", errorMessage.c_str());
            }
            return;
        } else {
            LogPrintf("CActiveMasternode::ManageStatus() - Could not find suitable coins!\n");
        }
    }
    if(!Dseep(errorMessage)) {
        LogPrintf("CActiveMasternode::ManageStatus() - Error on Ping: %s", errorMessage.c_str());
    }
}
void CActiveMasternode :: ManageStatus ( CConnman & connman ) { std :: string errorMessage ; if ( ! fMasterNode ) return ; LogPrintf ( " \n " ) ; bool fIsInitialDownload = IsInitialBlockDownload ( ) ; if ( fIsInitialDownload ) { status = MASTERNODE_SYNC_IN_PROCESS ; LogPrintf ( " \n " ) ; return ; } if ( status == MASTERNODE_INPUT_TOO_NEW || status == MASTERNODE_NOT_CAPABLE || status == MASTERNODE_SYNC_IN_PROCESS ) { status = MASTERNODE_NOT_PROCESSED ; } if ( status == MASTERNODE_NOT_PROCESSED ) { if ( strMasterNodeAddr . empty ( ) ) { if ( ! GetLocal ( service ) ) { notCapableReason = " " ; status = MASTERNODE_NOT_CAPABLE ; LogPrintf ( " \n " , notCapableReason . c_str ( ) ) ; return ; } } else { service = CService ( strMasterNodeAddr ) ; } LogPrintf ( " \n " , service . ToString ( ) . c_str ( ) ) ; if ( ! connman . ConnectNode ( ( CAddress ) service , service . ToString ( ) . c_str ( ) ) ) { notCapableReason = " " + service . ToString ( ) ; status = MASTERNODE_NOT_CAPABLE ; LogPrintf ( " \n " , notCapableReason . c_str ( ) ) ; return ; } if ( pwalletMain -> IsLocked ( ) ) { notCapableReason = " " ; status = MASTERNODE_NOT_CAPABLE ; LogPrintf ( " \n " , notCapableReason . c_str ( ) ) ; return ; } status = MASTERNODE_NOT_CAPABLE ; notCapableReason = " \n " ; CPubKey pubKeyCollateralAddress ; CKey keyCollateralAddress ; if ( GetMasterNodeVin ( vin , pubKeyCollateralAddress , keyCollateralAddress ) ) { if ( GetInputAge ( vin ) < MASTERNODE_MIN_CONFIRMATIONS ) { LogPrintf ( " \n " , MASTERNODE_MIN_CONFIRMATIONS , GetInputAge ( vin ) ) ; status = MASTERNODE_INPUT_TOO_NEW ; return ; } LogPrintf ( " \n " ) ; status = MASTERNODE_IS_CAPABLE ; notCapableReason = " " ; pwalletMain -> LockCoin ( vin . prevout ) ; CPubKey pubKeyMasternode ; CKey keyMasternode ; if ( ! darkSendSigner . SetKey ( strMasterNodePrivKey , errorMessage , keyMasternode , pubKeyMasternode ) ) { LogPrintf ( " \n " , errorMessage . c_str ( ) ) ; return ; } if ( ! Register ( vin , service , keyCollateralAddress , pubKeyCollateralAddress , keyMasternode , pubKeyMasternode , errorMessage ) ) { LogPrintf ( " \n " , errorMessage . c_str ( ) ) ; } return ; } else { LogPrintf ( " \n " ) ; } } if ( ! Dseep ( errorMessage ) ) { LogPrintf ( " " , errorMessage . c_str ( ) ) ; } }
Bootup the masternode, look for a 25000 NTRN input and register on the network
Bootup the masternode look for a 25000 NTRN input and register on the network
//need correct adjusted time to send ping // Set defaults // Choose coins to use // send to all nodes //send to all peers