def status(bot): return ( "First you should check your node's status by running " "<c>curium-cli masternode status<c> on your node's VPS.\n\n" "The status of your node can hint towards the problem of why your " "node isn't running. Here are the known states and their likely causes:\n\n" "<b>Node just started, not yet activated<b>\n\n" "Simply means your blocks aren't up-to-date yet with the current " "blockcount. Run <c>curium-cli getinfo<c> on the VPS to see your current " "blockHeight at <c>blocks<c>, and compare it to the current blockHeight that " "you can see when you send me <cb>info<ca>\n\n" "<b>Broadcast IP doesn't match external IP<b>\n\n" "Most likely culprit is a duplicate IP/genkey/txhash in the " "config file. Verify that all node entries in the <c>masternode.conf<c> file " " have a unique IP/genkey/txhash+id. If your VPS has multiple IP's, adding " "externalip=yourNodeIP in the <c>curium.conf<c> of a daemon will direct it" " towards the IP you specified.\n\n" "<b>Not capable masternode: invalid protocol version<b>\n\n" "Your node is not up-to-date on the latest version. Compare the version you" " see when you run <c>curium-cli getinfo<c> at <c>version<c> to the latest version at ") +\ messages.link(bot.messenger, "https://curium.cc/wallets/", "Curium wallets") +\ (" for more info on the current version.\n\n" "<b>Not capable masternode: masternode not in masternodelist<b>\n\n" "The node hasn't yet connected to the network. This can have " "several reasons; your desktop-wallet is outdated, your node is " "outdated or you didn't yet issue a <c>Start alias<c> command while the " "desktop-wallet was synced.")
def detail(bot, update): response = messages.markdown("<u><b>Detail<b><u>\n\n", bot.messenger) userInfo = util.crossMessengerSplit(update) userId = userInfo['user'] if 'user' in userInfo else None userName = userInfo[ 'name'] if 'name' in userInfo else update.message.from_user.name logger.debug("detail - user: {}".format(userId)) nodesFound = False user = bot.database.getUser(userId) userNodes = bot.database.getAllNodes(userId) if user == None or userNodes == None or len(userNodes) == 0: response += messages.nodesRequired(bot.messenger) else: with bot.nodeList as nodeList: minimumUptime = nodeList.minimumUptime() top10 = nodeList.enabledWithMinProtocol() * 0.1 for userNode in userNodes: masternode = nodeList.getNodes([userNode['collateral']])[0] response += messages.markdown( ("<b>" + userNode['name'] + " - " + masternode.ip + "<b>"), bot.messenger) response += "\n `Status` " + masternode.status response += "\n `Position` " + messages.markdown( masternode.positionString(minimumUptime, top10), bot.messenger) response += "\n `Payee` " + masternode.payee response += "\n `Active since` " + util.secondsToText( masternode.activeSeconds) response += "\n `Last seen` " + util.secondsToText( int(time.time()) - masternode.lastSeen) response += "\n `Last payout (Block)` " + masternode.payoutBlockString( ) response += "\n `Last payout (Time)` " + masternode.payoutTimeString( ) response += "\n `Protocol` {}".format(masternode.protocol) #response += "\n `Rank` {}".format(masternode.rank) response += "\n " + messages.link( bot.messenger, 'https://explorer3.curium.cc/address/{}'.format( masternode.payee), 'Open the explorer!') response += "\n\n" return response
def nodes(bot, update): response = messages.markdown("<u><b>Nodes<b><u>\n\n", bot.messenger) userInfo = util.crossMessengerSplit(update) userId = userInfo['user'] if 'user' in userInfo else None userName = userInfo['name'] if 'name' in userInfo else None logger.debug("nodes - user: {}".format(userId)) nodesFound = False user = bot.database.getUser(userId) userNodes = bot.database.getAllNodes(userId) if user == None or userNodes == None or len(userNodes) == 0: response += messages.nodesRequired(bot.messenger) else: with bot.nodeList as nodeList: collaterals = list(map(lambda x: x['collateral'], userNodes)) nodes = nodeList.getNodes(collaterals) minimumUptime = nodeList.minimumUptime() top10 = nodeList.enabledWithMinProtocol() * 0.1 for masternode in sorted(nodes, key=lambda x: x.position if x.position > 0 else 100000): userNode = bot.database.getNodes(masternode.collateral, user['id']) payoutText = util.secondsToText(masternode.lastPaidTime) response += messages.markdown( "<b>" + userNode['name'] + "<b> - `" + masternode.status + "`", bot.messenger) response += "\nPosition " + messages.markdown( masternode.positionString(minimumUptime, top10), bot.messenger) response += "\nLast seen " + util.secondsToText( int(time.time()) - masternode.lastSeen) response += "\nLast payout " + masternode.payoutTimeString() response += "\n" + messages.link( bot.messenger, 'https://explorer3.curium.cc/address/{}'.format( masternode.payee), 'Open the explorer!') response += "\n\n" return response
def rewards(bot): with bot.nodeList as nodeList: if not nodeList.synced() or not nodeList.enabled(): return messages.notSynced(bot.messenger) enabled = nodeList.enabled() minPosition = int(enabled * 0.1) qualified = nodeList.qualifiedNormal lastBlock = nodeList.lastBlock # Fallback if for whatever reason the top node could not filtered which # should actually not happen. top10Seconds = (int((qualified * 55) / 0.5) * (1 + bot.aberration)) topNode = list(filter(lambda x: x.position == minPosition, nodeList.nodes.values())) if len(topNode) and topNode[0].lastPaidTime: top10FromList = time.time() - topNode[0].lastPaidTime if top10FromList < 1.2 * top10Seconds: top10Seconds = top10FromList payoutSeconds = top10Seconds + (10 * 60 * 60) payoutDays = payoutSeconds / 86400.0 interval = util.secondsToText(int(payoutSeconds)) currentReward = round(5000.0 * 143500.0 / lastBlock * 0.1,1) / 0.5 perMonth = round((30.5 / payoutDays) * currentReward,1) return ( "The SmartNode rewards are calculated by the following formula\n\n" "```reward = 5000 x 143500 / blockHeight * 0.1```\n\n" "At this moment our blockchain is at the height <b>{}<b> that means" "\n\n```5000 x 143500 / {} * 0.1 => {} SMART per block```\n\n" "Each block with an <b>even<b> blockheight one of the the nodes receive this reward for 2 blocks. With the current " "estimated payout interval of <b>{}<b> you can expect roughly" " <b>{:,} SMART<b> per month per SmartNode. This can vary a bit upwards and downwards though.\n\n" "Due to the constant increase of the <c>blockHeight<c> of the SmartCash blockchain" " the rewards will decrease a little bit every 55 seconds." " Also the increase of the number of qualified nodes will increase the payout interval." " As result your monthly payout will slightly decrease over the time.\n\n" "You can look at the chart in the link below to see the reward decrease " "for the first 4 years after the SmartNode launch.\n\n" ).format(lastBlock, lastBlock, currentReward, interval, perMonth)\ + messages.link(bot.messenger, "https://goo.gl/Va817H", "Click here to open the chart")
def top(bot, update, args): response = "<u><b>Top nodes<b><u>\n\n" userInfo = util.crossMessengerSplit(update) userId = userInfo['user'] if 'user' in userInfo else None userName = userInfo['name'] if 'name' in userInfo else None logger.debug("nodes - user: {}".format(userId)) nodesFound = False user = bot.database.getUser(userId) userNodes = bot.database.getAllNodes(userId) if user == None or userNodes == None or len(userNodes) == 0: response += messages.nodesRequired(bot.messenger) else: invalidFilterValueMsg = "<b>ERROR<b>: Invalid filter value: <b>{}<b>! Valid range: 10 - 100\n\n" topPercent = 10 if len(args) >= 1: if util.isInt(args[0]) and\ int(args[0]) >= 10 and int(args[0]) <= 100: topPercent = int(args[0]) else: response += invalidFilterValueMsg.format( messages.removeMarkdown(args[0])) response += "<b>Filter<b> {}%\n\n".format(topPercent) with bot.nodeList as nodeList: topX = nodeList.enabledWithMinProtocol() * (topPercent / 100) collaterals = list(map(lambda x: x['collateral'], userNodes)) nodes = nodeList.getNodes(collaterals) topNodes = list( filter(lambda x: x.position <= topX and x.position > 0, nodes)) minimumUptime = nodeList.minimumUptime() if len(topNodes): for masternode in sorted(topNodes, key=lambda x: x.position if x.position > 0 else 100000): userNode = bot.database.getNodes(masternode.collateral, user['id']) response += "<b>" + userNode['name'] + "<b>" response += "\nPosition " + messages.markdown( masternode.positionString(minimumUptime), bot.messenger) response += "\n" + messages.link( bot.messenger, 'https://explorer3.curium.cc/address/{}'.format( masternode.payee), 'Open the explorer!') response += "\n\n" else: response += "<b>You have currently no nodes in the top {}% of the queue.<b>\n\n".format( topPercent) return messages.markdown(response, bot.messenger)