forked from ben-abraham/raven-trader-pro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
52 lines (41 loc) · 1.69 KB
/
main.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
from jsonrpcclient.requests import Request
from requests import post, get
from decimal import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5 import uic
import sys, getopt, argparse, json, time, getpass, os.path
from ui.preview_order import PreviewTransactionDialog
from ui.order_details import OrderDetailsDialog
from ui.new_order import NewOrderDialog
from ui.main_window import MainWindow
from swap_transaction import SwapTransaction
from swap_storage import SwapStorage
from util import *
from rvn_rpc import *
from config import *
## Main app entry point
if __name__ == "__main__":
chain_info = do_rpc("getblockchaininfo")
app = QApplication(sys.argv)
#If the headers and blocks are not within 5 of each other,
#then the chain is likely still syncing
chain_updated = False if not chain_info else\
(chain_info["headers"] - chain_info["blocks"]) < 5
if chain_info and chain_updated:
swap_storage = SwapStorage()
swap_storage.on_load()
window = MainWindow(swap_storage)
window.show()
app.exec_()
swap_storage.on_close()
elif chain_info:
show_error("Sync Error",
"Server appears to not be fully synchronized. Must be at the latest tip to continue.",
"Network: {}\r\nCurrent Headers: {}\r\nCurrent Blocks: {}".format(chain_info["chain"], chain_info["headers"], chain_info["blocks"]))
else:
show_error("Error connecting",
"Error connecting to RPC server.\r\n{}".format(RPC_URL),
"Make sure the following configuration variables are in your raven.conf file"+
"\r\n\r\nserver=1\r\nrpcuser={}\r\nrpcpassword={}".format(RPC_USERNAME, RPC_PASSWORD))