-
Notifications
You must be signed in to change notification settings - Fork 67
/
constants.py
231 lines (195 loc) · 5.2 KB
/
constants.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
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
import os
from os.path import expanduser
import platform
from typing import Dict
NODE_LAUNCHER_RELEASE = '.'.join(map(str, (6, 0, 3)))
TARGET_BITCOIN_RELEASE = 'v0.17.1'
TARGET_LND_RELEASE = 'v0.6-beta-rc4'
class StringConstant(object):
def __init__(self, name: str):
self.name = name.lower()
def __str__(self):
return self.name
def __hash__(self):
return hash(self.name)
def __eq__(self, other):
return other.name == self.name
def __ne__(self, other):
return str(other).lower() != self.name
def __repr__(self):
return self.name
class Network(StringConstant):
pass
TESTNET: Network = Network('testnet')
MAINNET: Network = Network('mainnet')
class OperatingSystem(StringConstant):
pass
DARWIN: OperatingSystem = OperatingSystem('darwin')
LINUX: OperatingSystem = OperatingSystem('linux')
WINDOWS: OperatingSystem = OperatingSystem('windows')
OPERATING_SYSTEM = OperatingSystem(platform.system())
IS_MACOS = OPERATING_SYSTEM == DARWIN
IS_LINUX = OPERATING_SYSTEM == LINUX
IS_WINDOWS = OPERATING_SYSTEM == WINDOWS
# Only relevant for Windows
LOCALAPPDATA = os.path.abspath(os.environ.get('LOCALAPPDATA', ''))
APPDATA = os.path.abspath(os.environ.get('APPDATA', ''))
PROGRAMS = os.environ.get('Programw6432', '')
NODE_LAUNCHER_DATA_PATH: Dict[OperatingSystem, str] = {
DARWIN: expanduser('~/Library/Application Support/Node Launcher/'),
LINUX: expanduser('~/.node_launcher'),
WINDOWS: os.path.join(LOCALAPPDATA, 'Node Launcher')
}
try:
os.mkdir(os.path.join(NODE_LAUNCHER_DATA_PATH[OPERATING_SYSTEM]))
except FileExistsError:
pass
LND_DIR_PATH: Dict[OperatingSystem, str] = {
DARWIN: expanduser('~/Library/Application Support/Lnd/'),
LINUX: expanduser('~/.lnd/'),
WINDOWS: os.path.join(LOCALAPPDATA, 'Lnd')
}
BITCOIN_DATA_PATH: Dict[OperatingSystem, str] = {
DARWIN: expanduser('~/Library/Application Support/Bitcoin/'),
LINUX: expanduser('~/.bitcoin'),
WINDOWS: os.path.join(APPDATA, 'Bitcoin')
}
UPGRADE = 'Please download the latest version of the Node Launcher: ' \
'<a href="https://github.com/PierreRochard/node-launcher/releases/">' \
'https://github.com/PierreRochard/node-launcher/releases' \
'</a>'
GIGABYTE = 1000000000
if IS_WINDOWS:
from keyring.backends.Windows import WinVaultKeyring
keyring = WinVaultKeyring()
if IS_MACOS:
from keyring.backends.OS_X import Keyring
keyring = Keyring()
if IS_LINUX:
from keyring.backends.SecretService import Keyring
keyring = Keyring()
AUTOPRUNE_GB = 150
# How many megabytes to keep
# Total Bitcoin (mainnet) data directory size minus blocks is ~3 GB
# We are targeting 10 GB, so 10 - 3 = 7
MAINNET_PRUNE = 7000
TESTNET_PRUNE = 1000
BITCOIN_TESTNET_PEER_PORT = 18333
BITCOIN_MAINNET_PEER_PORT = 8333
BITCOIN_TESTNET_RPC_PORT = 18332
BITCOIN_MAINNET_RPC_PORT = 8332
LND_DEFAULT_PEER_PORT = 9735
LND_DEFAULT_GRPC_PORT = 10009
LND_DEFAULT_REST_PORT = 8080
LNCLI_COMMANDS = [
'abandonchannel',
'addinvoice',
'changepassword',
'channelbalance',
'closeallchannels',
'closechannel',
'closedchannels',
'connect',
'create',
'debuglevel',
'decodepayreq',
'describegraph',
'disconnect',
'feereport',
'fwdinghistory',
'getchaninfo',
'getinfo',
'getnetworkinfo',
'getnodeinfo',
'help',
'listchaintxns',
'listchannels',
'listinvoices',
'listpayments',
'listpeers',
'lookupinvoice',
'newaddress',
'openchannel',
'payinvoice',
'pendingchannels',
'queryroutes',
'sendcoins',
'sendmany',
'sendpayment',
'sendtoroute',
'signmessage',
'stop',
'unlock',
'updatechanpolicy',
'verifymessage',
'walletbalance'
]
BITCOIN_CLI_COMMANDS = [
'getbestblockhash',
'addnode',
'clearbanned',
'combinepsbt',
'combinerawtransaction',
'converttopsbt',
'createmultisig',
'createpsbt',
'createrawtransaction',
'decodepsbt',
'decoderawtransaction',
'decodescript',
'disconnectnode',
'estimatesmartfee',
'finalizepsbt',
'generatetoaddress',
'getaddednodeinfo',
'getblock',
'getblockchaininfo',
'getblockcount',
'getblockhash',
'getblockheader',
'getblockstats',
'getblocktemplate',
'getchaintips',
'getchaintxstats',
'getconnectioncount',
'getdifficulty',
'getmemoryinfo',
'getmempoolancestors',
'getmempooldescendants',
'getmempoolentry',
'getmempoolinfo',
'getmininginfo',
'getnettotals',
'getnetworkhashps',
'getnetworkinfo',
'getpeerinfo',
'getrawmempool',
'getrawtransaction',
'gettxout',
'gettxoutproof',
'gettxoutsetinfo',
'getzmqnotifications',
'help',
'listbanned',
'logging',
'ping',
'preciousblock',
'prioritisetransaction',
'pruneblockchain',
'savemempool',
'scantxoutset',
'sendrawtransaction',
'setban',
'setnetworkactive',
'signmessagewithprivkey',
'signrawtransaction',
'signrawtransactionwithkey',
'stop',
'submitblock',
'testmempoolaccept',
'uptime',
'validateaddress',
'verifychain',
'verifymessage',
'verifytxoutproof'
]