/* This makes sure to call functions on the node which only return cached data. This ensures it returns promptly, and doesn't hang waiting for a response when the node is having issues. */ void status(CryptoNote::INode &node, CryptoNote::WalletGreen &wallet) { uint32_t localHeight = node.getLastLocalBlockHeight(); uint32_t remoteHeight = node.getLastKnownBlockHeight(); uint32_t walletHeight = wallet.getBlockCount() - 1; /* Print the heights of local, remote, and wallet */ printHeights(localHeight, remoteHeight, walletHeight); std::cout << std::endl; /* Print the network and wallet sync status in percentage */ printSyncStatus(localHeight, remoteHeight, walletHeight); std::cout << std::endl; /* Print the network hashrate, based on the last local block */ printHashrate(node.getLastLocalBlockHeaderInfo().difficulty); /* Print the amount of peers we have */ printPeerCount(node.getPeerCount()); std::cout << std::endl; /* Print a summary of the sync status */ printSyncSummary(localHeight, remoteHeight, walletHeight); }
void balance(CryptoNote::INode &node, CryptoNote::WalletGreen &wallet, bool viewWallet) { const uint64_t unconfirmedBalance = wallet.getPendingBalance(); const uint64_t confirmedBalance = wallet.getActualBalance(); const uint64_t totalBalance = unconfirmedBalance + confirmedBalance; const uint32_t localHeight = node.getLastLocalBlockHeight(); const uint32_t remoteHeight = node.getLastKnownBlockHeight(); const uint32_t walletHeight = wallet.getBlockCount(); std::cout << "Available balance: " << SuccessMsg(formatAmount(confirmedBalance)) << std::endl << "Locked (unconfirmed) balance: " << WarningMsg(formatAmount(unconfirmedBalance)) << std::endl << "Total balance: " << InformationMsg(formatAmount(totalBalance)) << std::endl; if (viewWallet) { std::cout << std::endl << InformationMsg("Please note that view only wallets " "can only track incoming transactions,") << std::endl << InformationMsg("and so your wallet balance may appear " "inflated.") << std::endl; } if (localHeight < remoteHeight) { std::cout << std::endl << InformationMsg("Your daemon is not fully synced with " "the network!") << std::endl << "Your balance may be incorrect until you are fully " << "synced!" << std::endl; } /* Small buffer because wallet height doesn't update instantly like node height does */ else if (walletHeight + 1000 < remoteHeight) { std::cout << std::endl << InformationMsg("The blockchain is still being scanned for " "your transactions.") << std::endl << "Balances might be incorrect whilst this is ongoing." << std::endl; } }
void blockchainHeight(CryptoNote::INode &node, CryptoNote::WalletGreen &wallet) { const uint32_t localHeight = node.getLastLocalBlockHeight(); const uint32_t remoteHeight = node.getLastKnownBlockHeight(); const uint32_t walletHeight = wallet.getBlockCount() - 1; /* This is the height that the wallet has been scanned to. The blockchain can be fully updated, but we have to walk the chain to find our transactions, and this number indicates that progress. */ std::cout << "Wallet blockchain height: "; /* Small buffer because wallet height doesn't update instantly like node height does */ if (walletHeight + 1000 > remoteHeight) { std::cout << SuccessMsg(std::to_string(walletHeight)); } else { std::cout << WarningMsg(std::to_string(walletHeight)); } std::cout << std::endl << "Local blockchain height: "; if (localHeight == remoteHeight) { std::cout << SuccessMsg(std::to_string(localHeight)); } else { std::cout << WarningMsg(std::to_string(localHeight)); } std::cout << std::endl << "Network blockchain height: " << SuccessMsg(std::to_string(remoteHeight)) << std::endl; if (localHeight == 0 && remoteHeight == 0) { std::cout << WarningMsg("Uh oh, it looks like you don't have ") << WarningMsg(WalletConfig::daemonName) << WarningMsg(" open!") << std::endl; } else if (walletHeight + 1000 < remoteHeight && localHeight == remoteHeight) { std::cout << InformationMsg("You are synced with the network, but the " "blockchain is still being scanned for " "your transactions.") << std::endl << "Balances might be incorrect whilst this is ongoing." << std::endl; } else if (localHeight == remoteHeight) { std::cout << SuccessMsg("Yay! You are synced!") << std::endl; } else { std::cout << WarningMsg("Be patient, you are still syncing with the " "network!") << std::endl; } }