/** If the Reserves are Depleted, this Tells a miner if there is a new Time Interval with their Previous Block which would signal new release into reserve. If for some reason this is a false flag, the block will be rejected by the network for attempting to deplete the reserves past 0 **/ bool ReleaseAvailable(const CBlockIndex* pindex, int nChannel) { const CBlockIndex* pindexLast = GetLastChannelIndex(pindex, nChannel); if(!pindexLast->pprev) return true; return !(GetChainAge(GetUnifiedTimestamp()) == GetChainAge(pindexLast->GetBlockTime())); }
/** Export the private keys of the current UTXO values. This will allow the importing and exporting of private keys much easier. **/ Value exportkeys(const Array& params, bool fHelp) { if (fHelp || params.size() != 0) throw runtime_error( "exportkeys\n" "This command dumps the private keys and account names of all unspent outputs.\n" "This allows the easy dumping and importing of all private keys on the system\n"); /** Disallow the exporting of private keys if the encryption key is not available in the memory. **/ if (pwalletMain->IsLocked()) throw JSONRPCError(-13, "Error: Please enter the wallet passphrase with walletpassphrase first."); if (Wallet::fWalletUnlockMintOnly) // Nexus: no dumpprivkey in mint-only mode throw JSONRPCError(-102, "Wallet is unlocked for minting only."); /** Compile the list of available Nexus Addresses and their according Balances. **/ map<Wallet::NexusAddress, int64> mapAddresses; if(!pwalletMain->AvailableAddresses((unsigned int)GetUnifiedTimestamp(), mapAddresses)) throw JSONRPCError(-3, "Error Extracting the Addresses from Wallet File. Please Try Again."); /** Loop all entries of the memory map to compile the list of account names and their addresses. JSON object format is a reflection of the import and export options. **/ Object entry; for (map<Wallet::NexusAddress, int64>::iterator it = mapAddresses.begin(); it != mapAddresses.end(); ++it) { /** Extract the Secret key from the Wallet. **/ Wallet::CSecret vchSecret; bool fCompressed; if (!pwalletMain->GetSecret(it->first, vchSecret, fCompressed)) throw JSONRPCError(-4,"Private key for address " + it->first.ToString() + " is not known"); /** Extract the account name from the address book. **/ string strAccount; if(!pwalletMain->mapAddressBook.count(it->first)) strAccount = "Default"; else strAccount = pwalletMain->mapAddressBook[it->first]; /** Compile the Secret Key and account information into a listed pair. **/ string strSecret = Wallet::NexusSecret(vchSecret, fCompressed).ToString(); entry.push_back(Pair(strAccount, strSecret)); } return entry; }
void NexusGUI::setNumBlocks(int count) { // don't show / hide progressBar and it's label if we have no connection(s) to the network if (!clientModel || clientModel->getNumConnections() == 0) { progressBarLabel->setVisible(false); progressBar->setVisible(false); return; } // set trust and block weight on this signal for now... setWeight(clientModel->getTrustWeight(), clientModel->getBlockWeight(), clientModel->getInterestRate()); int nTotalBlocks = clientModel->getNumBlocksOfPeers(); QString tooltip; if(count < nTotalBlocks) { int nRemainingBlocks = nTotalBlocks - count; float nPercentageDone = count / (nTotalBlocks * 0.01f); if (clientModel->getStatusBarWarnings() == "") { progressBarLabel->setText(tr("Synchronizing with network...")); progressBarLabel->setVisible(true); progressBar->setFormat(tr("~%n block(s) remaining", "", nRemainingBlocks)); progressBar->setMaximum(nTotalBlocks); progressBar->setValue(count); progressBar->setVisible(true); } else { progressBarLabel->setText(clientModel->getStatusBarWarnings()); progressBarLabel->setVisible(true); progressBar->setVisible(false); } tooltip = tr("Downloaded %1 of %2 blocks of transaction history (%3% done).").arg(count).arg(nTotalBlocks).arg(nPercentageDone, 0, 'f', 2); } else { if (clientModel->getStatusBarWarnings() == "") progressBarLabel->setVisible(false); else { progressBarLabel->setText(clientModel->getStatusBarWarnings()); progressBarLabel->setVisible(true); } progressBar->setVisible(false); tooltip = tr("Downloaded %1 blocks of transaction history.").arg(count); } QDateTime now = QDateTime::fromTime_t(GetUnifiedTimestamp());//QDateTime::currentDateTime(); QDateTime lastBlockDate = clientModel->getLastBlockDate(); int secs = lastBlockDate.secsTo(now); QString text; // Represent time from last generated block in human readable text if(secs <= 0) { // Fully up to date. Leave text empty. } else if(secs < 60) { text = tr("%n second(s) ago","",secs); } else if(secs < 60*60) { text = tr("%n minute(s) ago","",secs/60); } else if(secs < 24*60*60) { text = tr("%n hour(s) ago","",secs/(60*60)); } else { text = tr("%n day(s) ago","",secs/(60*60*24)); } // Set icon state: spinning if catching up, tick otherwise if(secs < 90*60 && count >= nTotalBlocks) { tooltip = tr("Up to date") + QString(".\n") + tooltip; labelBlocksIcon->setPixmap(QIcon(":/icons/synced").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE)); } else { tooltip = tr("Catching up...") + QString("\n") + tooltip; labelBlocksIcon->setMovie(syncIconMovie); syncIconMovie->start(); } if(!text.isEmpty()) { tooltip += QString("\n"); tooltip += tr("Last received block was generated %1.").arg(text); } labelBlocksIcon->setToolTip(tooltip); progressBarLabel->setToolTip(tooltip); progressBar->setToolTip(tooltip); }