/
functions.go
82 lines (72 loc) · 1.71 KB
/
functions.go
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
package main
import (
"crypto/sha256"
"github.com/dReam-dApps/dReams/rpc"
)
// Select menu changes daemon address
func whichDaemon(s string) {
switch s {
case "TESTNET":
rpc.Daemon.Rpc = "127.0.0.1:40102"
case "SIMULATOR":
rpc.Daemon.Rpc = "127.0.0.1:20000"
case "CUSTOM":
confirmPopUp() /// enter custom address in new window
default:
rpc.Daemon.Rpc = "127.0.0.1:10102"
}
}
// Check if daemon is connected
func isDaemonConnected() {
if rpc.Daemon.Connect {
if !daemonCheckBox.Checked {
logger.Println("[dSlate] Daemon RPC Connected")
}
daemonCheckBox.SetChecked(true)
} else {
if debug {
logger.Println("[dSlate] Daemon RPC Not Connected")
}
currentHeight.SetText("Height:")
if daemonCheckBox.Checked {
daemonCheckBox.SetChecked(false)
}
}
}
// Check if wallet is connected
func isWalletConnected() {
if rpc.Wallet.Connect {
if !walletCheckBox.Checked {
logger.Println("[dSlate] Wallet RPC Connected")
walletCheckBox.SetChecked(true)
}
GetBalance()
} else {
if debug {
logger.Println("[dSlate] Wallet RPC Not Connected")
}
if walletCheckBox.Checked {
walletCheckBox.SetChecked(false)
rpc.Wallet.Connect = false
}
}
if walletCheckBox.Checked { /// if wallet is connected and any changes to inputs, show disconnected
checkPass()
if rpcWalletInput.Text != rpc.Wallet.Rpc {
walletBalance.SetText("Balance: ")
rpc.Wallet.Address = ""
walletCheckBox.SetChecked(false)
rpc.Wallet.Connect = false
}
}
}
// Check if user:pass has changed
func checkPass() {
data := []byte(rpcLoginInput.Text)
hash := sha256.Sum256(data)
if hash != passHash {
walletBalance.SetText("Balance: ")
walletCheckBox.SetChecked(false)
rpc.Wallet.Connect = false
}
}