-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsilme-qt
executable file
·152 lines (100 loc) · 4.48 KB
/
silme-qt
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/usr/bin/python
# Copyright (c) 2018 CVSC
# Distributed under the MIT/X11 software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
from Tkinter import *
import thread
import time
import tkMessageBox
from main import *
from subprocess import check_output
class silme:
def __init__(self, root):
self.root = root
self.frame = Frame(self.root)
self.frame.pack()
self.c = StringVar()
self.t = StringVar()
self.addr_ = StringVar()
self.balance_ = StringVar()
self.connection_ = StringVar()
self.startorstopmining_ = StringVar()
self.binfo_ = StringVar()
thread.start_new_thread(self._update, ())
self.addr()
self.mining()
self.balance()
self.send()
self.blockchain()
def blockchaininfo(self):
return "Height: %d | Difficulty: %d" %(CBlockchainDB().getBestHeight(), CalculateDiff())
def _update(self):
if not internetConnection():
tkMessageBox.showinfo("Error", "Please check your network connection and try again.")
self.root.destroy()
else:
addr = GenerateNewKey()
while True:
self.startorstopmining_.set(self.sosm())
self.addr_.set(addr)
self.balance_.set(CWalletDB().GetBalance())
self.binfo_.set(self.blockchaininfo())
time.sleep(3)
def sosm(self):
out = check_output("ps aux |grep python", shell=True)
if "./miner" in out:
return "Stop"
else:
return "Start"
def addr(self):
addr_f = LabelFrame(self.frame, text="Address", padx=5, pady=5)
addr_f.grid(sticky=E+W)
Entry(self.frame, state="readonly", textvariable=self.addr_, width=80).grid(in_=addr_f)
def balance(self):
addr_balance = LabelFrame(self.frame, text="Balance", padx=5, pady=5)
addr_balance.grid(sticky=E+W)
Entry(self.frame, state="readonly", textvariable=self.balance_, width=50).grid(in_=addr_balance)
def mining(self):
mining_f = LabelFrame(self.frame, text="Mining", padx=3, pady=5)
mining_f.grid(sticky=E+W)
send_b = Button(self.frame, command=self.__mining, textvariable=self.startorstopmining_).grid(in_=mining_f, row=0, column=4, sticky=W+E)
def blockchain(self):
blockchain_info = LabelFrame(self.frame, text="Blockchain Info", padx=5, pady=5)
blockchain_info.grid(sticky=E+W)
Entry(self.frame, state="readonly", textvariable=self.binfo_, width=50).grid(in_=blockchain_info)
def send(self):
send_f = LabelFrame(self.frame, text="Send Coin", padx=5, pady=15)
send_f.grid(sticky=E+W)
to_l = Label(self.frame, text="To: ").grid(in_=send_f)
self.to = Entry(self.frame)
self.to.grid(in_=send_f, row=0, column=1, sticky=W)
amount_l = Label(self.frame, text="Amount: ").grid(in_=send_f, row=0, column=3, sticky=W)
self.amount = Entry(self.frame, width=4)
self.amount.grid(in_=send_f, row=0, column=4, sticky=W)
Label(self.frame, text=" ").grid(in_=send_f, row=0, column=5)
Label(self.frame, text=" ").grid(in_=send_f, row=0, column=2)
send_b = Button(self.frame, command=self._send, text="Send").grid(in_=send_f, row=0, column=8, sticky=W+E)
def _send(self):
amount = self.amount.get()
recipt = self.to.get()
if not CWalletDB().GenerateTransaction(float(amount), str(recipt)):
tkMessageBox.showinfo("Error", CWalletDB().GenerateTransaction(int(amount), str(recipt)))
return 0
else:
tkMessageBox.showinfo("Sending...", "Your coins are being sent, this could take a while.")
def __mining(self):
if self.startorstopmining_.get() == "Stop":
out = check_output("ps aux |grep python |grep miner |awk '{print $2}'", shell=True)
os.system('kill ' + str(out))
tkMessageBox.showinfo("Mining...", "SilmeMiner Stoped.")
elif self.startorstopmining_.get() == "Start":
os.system('./miner &')
tkMessageBox.showinfo("Mining...", "SilmeMiner Started.")
if __name__ == "__main__":
if not os.path.exists(GetAppDir()):
os.system('python main.py')
root = Tk()
root.geometry("655x330+350+100")
silme(root=root)
root.title("Silme Client")
root.mainloop()