-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprogram.go
More file actions
275 lines (257 loc) · 7.49 KB
/
program.go
File metadata and controls
275 lines (257 loc) · 7.49 KB
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
package main
import (
"context"
"time"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/widget"
"github.com/deroproject/derohe/rpc"
"github.com/deroproject/derohe/walletapi"
"github.com/deroproject/derohe/walletapi/rpcserver"
)
// simple way to compress byte size
const kilobyte = float64(1024)
// a simple way to convert units
const atomic_units = 100000
// simple way to set file permissions
const default_file_permissions = 0644
// simple way to set dismiss
const dismiss = `dismiss`
// simple way to set confirm
const confirm = `confirm`
// simple way to set timeouts
const timeout = time.Second * 9 // the world is a really big place
const deadline = time.Second * 300 // some content is just bigger
// simple way to identify gnomon
const gnomonSC = `a05395bb0cf77adc850928b0db00eb5ca7a9ccbafd9a38d021c8d299ad5ce1a4`
// simple way to accept or reject things
const reject = false
const accept = true
// simple way to determine the max ;
// walletapi.Show_Transfers establishes a max height
// https://github.com/deroproject/derohe/blob/main/walletapi/wallet.go#L252
const max_height = "5000000000000"
// simple way to create a global context and cancel func
var ctxConnection context.Context
var cancelConnection context.CancelFunc
var heightChan = make(chan int64)
var checkChan = make(chan int64)
// not to be confused with an app, this is a program:
var program = components{
activities: activities{
registration: widget.NewActivity(),
},
lists: lists{
transactions: new(widget.List),
asset_list: new(widget.List),
},
sliders: sliders{
notifications: widget.NewSlider(0.0, 1.0),
network: widget.NewSlider(0.0, 1.0),
},
toggles: toggles{
ws_server: widget.NewRadioGroup([]string{"off", "on"}, nil),
indexer: widget.NewRadioGroup([]string{"off", "on"}, nil),
rpc_server: widget.NewRadioGroup([]string{}, nil),
simulator: widget.NewRadioGroup([]string{}, nil),
},
checks: checks{
replyback: widget.NewCheck("replyback?", nil),
},
buttons: buttons{
open_file: widget.NewButton("", nil),
open_wallet: widget.NewButton("open wallet", nil),
send: widget.NewButton("SEND", nil),
assets: widget.NewButton("ASSETS", nil),
keys: widget.NewButton("KEYS", nil),
transactions: widget.NewButton("TXS", nil),
ws_server: widget.NewButton("WS SERVER", nil),
ws_on_off: widget.NewButton("TURN WS ON", nil),
rpc_server: widget.NewButton("RPC SERVER", nil),
indexer: widget.NewButton("INDEXER", nil),
idx_on_off: widget.NewButton("TURN IDX ON", nil),
update_password: widget.NewButton("UPDATE PASSWORD", nil),
simulator: widget.NewButton("SIMULATOR", nil),
simulation: widget.NewButton("TURN SIMULATOR ON", nil),
connections: widget.NewButton("CONNECTIONS", nil),
balance_rescan: widget.NewButton("BALANCE RESCAN", nil),
notifications: widget.NewButton("NOTIFICATIONS", nil),
asset_scan: widget.NewButton("ASSET SCAN", nil),
token_add: widget.NewButton("TOKEN ADD", nil),
explorer: widget.NewButton("EXPLORE BLOCKCHAIN", nil),
contracts: widget.NewButton("SMART CONTRACTS", nil),
encryption: widget.NewButton("ENCRYPTION TOOLS", nil),
},
hyperlinks: hyperlinks{
// header
home: widget.NewHyperlink("home", nil),
tools: widget.NewHyperlink("tools", nil),
configs: widget.NewHyperlink("configs", nil),
logout: widget.NewHyperlink("logout", nil),
// supplemental
lockscreen: widget.NewHyperlink(" 🔒", nil),
unlock: widget.NewHyperlink("unlock", nil),
create: widget.NewHyperlink("create", nil),
generate: widget.NewHyperlink("generate address", nil),
restore: widget.NewHyperlink("restore wallet", nil),
address: widget.NewHyperlink("address", nil),
login: widget.NewHyperlink("login", nil),
save: widget.NewHyperlink("save", nil),
},
labels: labels{
height: widget.NewLabel("BLOCK: 0000000000000"), // 5000000000000 is max
connection: widget.NewLabel("NODE: 🔴"),
loggedin: widget.NewLabel("WALLET: 🔴"),
ws_server: widget.NewLabel("WS: 🔴"),
ws_notice: widget.NewLabel("WS Server runs at ws://127.0.0.1:44326/xswd"),
rpc_server: widget.NewLabel("RPC: 🔴"),
idx_notice: widget.NewLabel("not connected"),
indexer: widget.NewLabel("IDX: 🔴"),
current_node: widget.NewLabel(""),
notice: widget.NewLabel(""),
balance: widget.NewLabel("0.00000"),
counter: makeCenteredWrappedLabel(`Registration POW takes time 20min-2hrs...
If on battery, plug device in.
Please do not leave this page.`),
address: widget.NewLabel("ADDRESS: "),
seed: widget.NewLabel("SEED PHRASE"),
secret: widget.NewLabel("SECRET KEY"),
public: widget.NewLabel("PUBLIC KEY"),
mainnet: makeCenteredWrappedLabel("mainnet"),
testnet: makeCenteredWrappedLabel("testnet"),
simulator: makeCenteredWrappedLabel("simulator"),
},
entries: entries{
wallet: widget.NewEntry(),
file: widget.NewEntry(),
username: widget.NewEntry(),
password: widget.NewEntry(),
node: widget.NewEntry(),
pass: widget.NewEntry(),
seed: widget.NewEntry(),
secret: widget.NewEntry(),
public: widget.NewEntry(),
counterparty: widget.NewEntry(),
recipient: widget.NewEntry(),
amount: widget.NewEntry(),
dst: widget.NewEntry(),
comment: widget.NewEntry(),
ws_port: widget.NewEntry(),
indexer: widget.NewEntry(),
},
selections: selections{
assets: widget.NewSelect([]string{""}, func(s string) {}),
},
tables: tables{
connections: widget.NewTable(
func() (rows int, cols int) { return 0, 0 },
func() fyne.CanvasObject { return widget.NewLabel("") },
func(tci widget.TableCellID, co fyne.CanvasObject) {},
),
},
rpc_server: new(rpcserver.RPCServer),
wallet: new(walletapi.Wallet_Disk),
node: nodes{
transactions: make(map[string]rpc.GetTransaction_Result),
blocks: make(map[uint64]rpc.GetBlock_Result),
list: node_list,
},
name: "simple-wallet",
size: fyne.NewSize(900, 600),
}
var password_size = fyne.NewSize(program.size.Width/3, program.size.Height/4)
// it would be ideal to have... like 20, or a callable list
var node_list = []struct {
ip string
name string
}{
{
ip: "",
name: "preferred",
},
{
ip: "127.0.0.1:10102",
name: "localhost",
},
}
var pool_headers = []string{
"height built",
"tx hash",
"fee",
"ring size",
"tx size [kB]",
}
var block_headers = []string{
"height",
"topo height",
"age",
"miniblocks", // why would we need to know if there was less than 10?
"size [kiB]",
"tx hash",
"type",
"fees",
"ring size",
"tx size [kB]",
}
var search_headers_block = []string{
"TOPO HEIGHT",
"BUILD HEIGHT",
"BLID",
"PREVIOUS",
"UNIX TIME",
"UTC TIME",
"AGE",
"MAJOR.MINIOR VERSION",
"REWARD",
"SIZE kB",
"MINIBLOCKS",
"CONFIRMATIONS",
}
var search_headers_registration = []string{
"TXID",
"TYPE",
"BLOCK",
"ADDRESS",
"VALID",
}
var search_headers_normal = []string{
"TXID",
"TYPE",
"BLOCK",
"BLID",
"BUILD HEIGHT",
"ROOT HASH",
"UNIX TIME",
"UTC TIME",
"AGE",
"TOPO HEIGHT",
"FEES",
"SIZE kB",
"VERSION",
"CONFIRMATIONS",
"TYPE",
"OUTPUTS",
"RING SIZE",
}
var search_headers_sc_prefix = []string{
"TXID",
"TYPE",
"BLOCK",
"SCID RESERVES", // this is a k/v pair
}
var search_headers_sc_body = []string{
"BLID",
"ROOT HASH",
"BUILD HEIGHT",
"UNIX TIME",
"UTC TIME",
"AGE",
"TOPO HEIGHT",
"FEES",
"SIZE kB",
"VERSION",
"CONFIRMATIONS",
"SIGNATURE TYPE",
"RING SIZE",
"SENDER",
"RING MEMBERS",
}