@@ -1141,55 +1141,53 @@ def connect(self,
11411141 price = sprice ,
11421142 gigabytes = 0 if hourly else int (units ),
11431143 hours = int (units ) if hourly else 0 ,
1144- next_sequence = True ,
1144+ next_sequence = False ,
11451145 tx_params = tx_params )
11461146 except RpcError as rpc_error :
11471147 details = rpc_error .details ()
11481148 print ("details" , details )
1149- if "expected" in details :
1150- try :
1151- tx = self .sdk .nodes .SubscribeToNode (node_address = address ,
1152- price = sprice ,
1153- gigabytes = 0 if hourly else int (units ),
1154- hours = int (units ) if hourly else 0 ,
1155- next_sequence = False ,
1156- tx_params = tx_params )
1157- except RpcError as rpc_error :
1158- details = rpc_error .details ()
1159- print ("details" , details )
1160- print ("code" , rpc_error .code ())
1161- print ("debug_error_string" , rpc_error .debug_error_string ())
1162- conndesc .write ("GRPC Error... Exiting" )
1163- conndesc .flush ()
1164- conndesc .close ()
1165- self .connected = {"v2ray_pid" : None ,
1166- "result" : False ,
1167- "status" : details ,
1168- "session_id" : None }
1169- print (self .connected )
1170- return
1171- else :
1172- print ("details" , details )
1173- print ("code" , rpc_error .code ())
1174- print ("debug_error_string" , rpc_error .debug_error_string ())
1175- conndesc .write ("GRPC Error... Exiting" )
1176- conndesc .flush ()
1177- conndesc .close ()
1178- self .connected = {"v2ray_pid" : None ,
1179- "result" : False ,
1180- "status" : details ,
1181- "session_id" : None }
1182- print (self .connected )
1183- return
1149+ print ("details" , details )
1150+ print ("code" , rpc_error .code ())
1151+ print ("debug_error_string" , rpc_error .debug_error_string ())
1152+ conndesc .write ("GRPC Error... Exiting" )
1153+ conndesc .flush ()
1154+ conndesc .close ()
1155+ self .connected = {"v2ray_pid" : None ,
1156+ "result" : False ,
1157+ "status" : details ,
1158+ "session_id" : None }
1159+ print (self .connected )
1160+ return
11841161
1185- # Will need to handle log responses with friendly UI response in case of session create error
1186- if tx .get ("log" , None ) is not None :
1187- self .connected = {"v2ray_pid" : None ,
1188- "result" : False ,
1189- "status" : tx ["log" ],
1190- "session_id" : None }
1191- print (self .connected )
1162+ txret = self .check_tx_log (tx )
1163+ if txret == 420 :
1164+ try :
1165+ tx = self .sdk .nodes .SubscribeToNode (node_address = address ,
1166+ price = sprice ,
1167+ gigabytes = 0 if hourly else int (units ),
1168+ hours = int (units ) if hourly else 0 ,
1169+ next_sequence = True ,
1170+ tx_params = tx_params )
1171+ txret = self .check_tx_log (tx )
1172+ if txret in [1 ,420 ]:
1173+ return
1174+ except RpcError as rpc_error :
1175+ details = rpc_error .details ()
1176+ print ("details" , details , flush = True )
1177+ print ("code" , rpc_error .code (), flush = True )
1178+ print ("debug_error_string" , rpc_error .debug_error_string (), flush = True )
1179+ conndesc .write ("GRPC Error... Exiting" )
1180+ conndesc .flush ()
1181+ conndesc .close ()
1182+ self .connected = {"v2ray_pid" : None ,
1183+ "result" : False ,
1184+ "status" : details ,
1185+ "session_id" : None }
1186+ print (self .connected )
1187+ return
1188+ elif txret == 1 :
11921189 return
1190+
11931191
11941192 try :
11951193 tx_response = self .sdk .subscriptions .wait_for_tx (tx ["hash" ], timeout = 25 )
@@ -1368,7 +1366,24 @@ def connect(self,
13681366 "result" : False ,
13691367 "status" : "Bad Response from Node" ,
13701368 "session_id" : session_id }
1371- return
1369+ return
1370+
1371+ def check_tx_log (self , tx ):
1372+ if tx .get ("log" , None ) is not None :
1373+ self .connected = {"v2ray_pid" : None ,
1374+ "result" : False ,
1375+ "status" : tx ["log" ],
1376+ "session_id" : None }
1377+ print (self .connected )
1378+ if "account sequence mismatch" in tx ['log' ]:
1379+ print ("ERROR: 420" )
1380+ return 420
1381+ else :
1382+ print ("ERROR: 1" )
1383+ return 1
1384+ else :
1385+ print ("NO LOG ERROR" )
1386+ return 0
13721387
13731388 def get_balance (self , address ):
13741389 Request = HTTPRequests .MakeRequest ()
0 commit comments