forked from esotericnonsense/bitcoind-ncurses
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglobal_mod.py
190 lines (179 loc) · 6.02 KB
/
global_mod.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
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
#!/usr/bin/env python
from curses import A_NORMAL
version = "v0.0.33"
modes = ['home', 'wallet', 'peers', 'mempool', 'block', 'tx', 'console', 'net', 'forks', 'quit']
# the following line just declares the default coinmode. Will be overwritten by main.py if user has provided another value as argument
coinmode = None
# now init with nothing...
coin_unit = None
coin_unit_test = None
coin_name = None
coin_smallname = None
rpc_deamon = None
rpc_port = None
rpc_port_test = None
node_port = None
node_port_test = None
reward_base = None # initial reward for mining a block
halving_blockamount = None # number ob blocks after which the reward is being halved
blocks_per_day = None
testnet = None
x = None
y = None
viewport_heigth = None
wallet_support = True # default, gets adjusted in process.py
estimatefee_mode = 0 # default method of retrieving estimatefee values, gets adjusted in rpc.py
def get_default_coinmode():
return 'BTC'
def init_coinmode():
global coinmode
global coin_unit
global coin_unit_test
global coin_name
global coin_smallname
global rpc_deamon
global rpc_port
global rpc_port_test
global node_port
global node_port_test
global reward_base
global halving_blockamount
global blocks_per_day
if coinmode == 'LTC':
# Config for litecoin:
coin_unit = 'LTC'
coin_unit_test = 'TNC'
coin_name = 'Litecoin'
coin_smallname = 'litecoin'
rpc_deamon = coin_smallname + 'd'
rpc_port = '9332'
rpc_port_test = '19332'
node_port = '9333'
node_port_test = '19333'
reward_base = 50 # initial reward for mining a block
halving_blockamount = 840000 # number ob blocks after which the reward is being halved
blocks_per_day = 576
elif coinmode == 'BCH':
# Config for bitcoin cash:
coin_unit = 'BCH'
coin_unit_test = 'TCH'
coin_name = 'Bitcoin Cash'
coin_smallname = 'bitcoincash'
rpc_deamon = 'bitcoind'
rpc_port = '8332'
rpc_port_test = '18332'
node_port = '8333'
node_port_test = '18333'
reward_base = 50 # initial reward for mining a block
halving_blockamount = 210000 # number ob blocks after which the reward is being halved
blocks_per_day = 144
elif coinmode == 'BCHA':
# Config for bitcoin cash:
coin_unit = 'BCHA'
coin_unit_test = 'TCHA'
coin_name = 'Bitcoin Cash ABC'
coin_smallname = 'bitcoincashabc'
rpc_deamon = 'bitcoindabc'
rpc_port = '8332'
rpc_port_test = '18332'
node_port = '8333'
node_port_test = '18333'
reward_base = 50 # initial reward for mining a block
halving_blockamount = 210000 # number ob blocks after which the reward is being halved
blocks_per_day = 144
elif coinmode == 'BSV':
# Config for bitcoin cash SV:
coin_unit = 'BSV'
coin_unit_test = 'TSV'
coin_name = 'Bitcoin Cash SV'
coin_smallname = 'bitcoincashsv'
rpc_deamon = 'bitcoind'
rpc_port = '8332'
rpc_port_test = '18332'
node_port = '8333'
node_port_test = '18333'
reward_base = 50 # initial reward for mining a block
halving_blockamount = 210000 # number ob blocks after which the reward is being halved
blocks_per_day = 144
elif coinmode == 'BTG':
# Config for bitcoin gold:
coin_unit = 'BTG'
coin_unit_test = 'TTG'
coin_name = 'Bitcoin Gold'
coin_smallname = 'bitcoingold'
rpc_deamon = 'bgoldd'
rpc_port = '8332'
rpc_port_test = '18332'
node_port = '8333'
node_port_test = '18333'
reward_base = 50 # initial reward for mining a block
halving_blockamount = 210000 # number ob blocks after which the reward is being halved
blocks_per_day = 144
else:
# Config for bitcoin:
coin_unit = 'BTC'
coin_unit_test = 'TNC'
coin_name = 'Bitcoin'
coin_smallname = 'bitcoin'
rpc_deamon = coin_smallname + 'd'
rpc_port = '8332'
rpc_port_test = '18332'
node_port = '8333'
node_port_test = '18333'
reward_base = 50 # initial reward for mining a block
halving_blockamount = 210000 # number ob blocks after which the reward is being halved
blocks_per_day = 144
def addstr_rjust(window, y, string, attribs=A_NORMAL, padding=0, num_cols=1, col=0):
""" prints out a right-aligned string on the given curses window.
Max x position is taken from module's global variable.
padding = number of spaces as a right margin. Default 0.
num_cols = window can be split into virtual columns. Default 1.
col = virtual column where the string is printed. Default 0 (=first column).
"""
global x
(max_y, max_x) = window.getmaxyx()
if max_x > x: max_x = x
if num_cols > 1:
max_x = int(max_x / num_cols) * (col + 1)
if len(string) <= max_x:
if padding + len(string) <= max_x:
try:
window.addstr(y, max_x - len(string) - padding, string, attribs)
except:
#print("Error! y=" + str(y) + ", max_x=" + str(max_x) + ", len(string)=" + str(len(string)) + ", padding=" + str(padding))
pass
else:
window.addstr(y, max_x - len(string), string, attribs)
def addstr_ljust(window, y, string, attribs=A_NORMAL, padding=0, num_cols=1, col=0):
""" prints out a left-aligned string on the given curses window.
padding = number of spaces as a left margin. Default 0.
num_cols = window can be split into virtual columns. Default 1.
col = virtual column where the string is printed. Default 0 (=first column).
"""
global x
if num_cols > 1:
(max_y, max_x) = window.getmaxyx()
if max_x > x: max_x = x
print_x = int(max_x / num_cols) * col
else:
print_x = 0
window.addstr(y, print_x + padding, string, attribs)
def addstr_cjust(window, y, string, attribs=A_NORMAL, padding=0, num_cols=1, col=0):
""" prints out a centered string on the given curses window.
Max x position is taken from module's global variable.
padding = number of spaces as an additional right margin. Default 0.
num_cols = window can be split into virtual columns. Default 1.
col = virtual column where the string is printed. Default 0 (=first column).
"""
global x
(max_y, max_x) = window.getmaxyx()
if max_x > x: max_x = x
min_x = 0
if num_cols > 1:
max_x = int(max_x / num_cols) * (col + 1)
min_x = int(max_x / num_cols) * col
l = len(string)
print_x = int((max_x - padding - min_x - l) / 2) + min_x
if print_x < 0: print_x = 0
if l <= max_x + print_x:
window.addstr(y, print_x, string, attribs)