-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmnestimator_windows.py
101 lines (87 loc) · 4.71 KB
/
mnestimator_windows.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#########################################################################
## DIMECOIN Master Node earnings estimator v0.0.1 ##
## Created by Dalamar 10/15/2022 ##
## This utility is intended to provide an estimate of earnings. ##
## There are no guarentees of complete accuracy and this must not ##
## be considered financial advice. ##
## use this at your own risk! ##
#########################################################################
'''
Formula is (n/t)*r*b*a
n = total number of masternodes an operator controls.
t = the total number of masternodes on the network
r = the current block reward
b = blocks in an average day
a = average masternode payment (%)
'''
import os
import json
class MNEstimator:
def __init__(self):
self.defaultCliPath = "C:\Program Files\Dimecoin\daemon" # Path where your cli.exe is located i.e C:\Program Files\Dimecoin\daemon
self.datadir = "" # Leave this blank if you're not using the -datadir argument. i.e -datadir=C:\Program Files\Dimecoin\Blockchain
self.defaultCliExe = "dimecoin-cli.exe" # the cli.exe file
self.pathandCli = self.defaultCliPath + "\\" + self.defaultCliExe
self.mnfile = self.defaultCliPath + "\\data\\mns.json"
def getmasternodes(self):
command = f"{self.pathandCli} {self.datadir} masternode list status \"ENABLED\""
print(f"executing: {command}")
mns = os.popen(command)
masternode_list = mns.read()
masternodes = json.loads(masternode_list)
# All Enabled master nodes are added to the masternode_list
# Using a list comprehension we can search those results for a count of how many 'ENABLED' master nodes exist
matches = [match for match in masternodes.items() if "ENABLED" in match]
#print(len(matches))
mncount = len(matches)
return mncount
def getblocktemplate(self):
command = f"{self.pathandCli} {self.datadir} getblocktemplate"
print(f"executing: {command}")
blocktemplate = os.popen(command)
blocktemplate_list = blocktemplate.read()
btjson = json.loads(blocktemplate_list)
# Extract the current block reward
mndata = btjson["masternode"]
mndict = {}
for i in mndata:
mndict.update(i)
mnamount = mndict["amount"]
blockreward = int(mnamount) * .00001
#print(str(blockreward))
return blockreward
def mncalc(self,n):
t = self.getmasternodes()
r = self.getblocktemplate()
# Estimating 64 second block time would be about 1,440 blocks per 24hrs.
b = input("Enter the average number of blocks in 24 hours (Leave blank for default 1440): ")
if b == "":
b = 1440
a = input("Enter the average master node extraction percent ie .45 (Leave blank for default of 45%): ")
if a == "":
a = .45
reward_total = (int(n)/t)*r*int(b)*float(a)
plus5 = (float(reward_total) * 0.05) + float(reward_total)
minus5 = float(reward_total) - (float(reward_total) * 0.05)
print(f"If you operate {n} masternode(s), there is a total of {t} enabled masternode(s), the current block reward is {r}, the average daily blocks is {b}, and the average masternode payment percent is {float(a) * 100}%")
print(f"({n}/{t}) * {r} * {b} * {a}% = {reward_total}")
reward_total = "{:,}".format(reward_total)
plus5 = "{:,}".format(plus5)
minus5 = "{:,}".format(minus5)
print(f"The total ESTIMATED daily masternode reward is: {reward_total}")
print("Variance for fluctuating data + or - 5%:")
print(f"Estimate plus 5%: {plus5} minus 5%: {minus5}")
def startup(self):
n = input("How many master nodes do you plan to operate? (Leave blank for default of 1): ")
if n == "":
n = 1
self.mncalc(n)
if __name__ == '__main__':
_dc = MNEstimator()
welcome = f"""************************************************************************************************************
* Welcome to the Master Node estimator tool. This tool is intended to provide estimates only. *
* This is not financial advice. *
* Use this utility at your own risk! *
************************************************************************************************************"""
print(welcome)
_dc.startup()