@@ -155,67 +155,74 @@ function fetch_electrum_nodes(currency, node_url, predefined_nodes, custom_nodes
155155 result = q_obj ( api_result , "result" ) ,
156156 list_length = result . length ;
157157 let done = false ;
158- if ( list_length && result ) {
159- $ . each ( result , function ( node_id , nd ) {
160- const url = nd [ 0 ] ;
161- let tport = null ;
162- if ( url ) {
163- const port_arr = nd [ 2 ] ;
164- if ( is_array ( port_arr ) ) {
165- tport = port_arr [ 1 ] ;
166- }
158+ if ( list_length && is_array ( result ) ) {
159+ short_list = ( list_length > 75 ) ? result . slice ( 0 , 75 ) : result ;
160+ $ . each ( short_list , function ( node_id , nd ) {
161+ const url = nd [ 1 ] || nd [ 0 ] ,
162+ filter_ips = is_valid_ipv4 ( url ) ;
163+ if ( filter_ips ) {
164+ // filter out electrum ip's and only add regular urls
167165 }
168- const port = tport ? ( ( / ^ \d / . test ( tport ) ) ? ":" + port : ":" + tport . slice ( 1 ) ) : "" ,
169- rpc_url2 = url + port ,
170- node_exists = check_node_exists ( rpc_url2 , existing_nodes ) ;
171- if ( ! node_exists ) {
172- const node_data = {
173- "name" : "electrum" ,
174- "url" : rpc_url2 ,
175- "display" : true
176- } ,
177- test_tx = glob_const . test_tx [ currency ] ;
178- api_proxy ( {
179- "api" : currency ,
180- "cachetime" : 25 ,
181- "cachefolder" : "1h" ,
182- "custom" : "electrum" ,
183- "api_url" : rpc_url2 ,
184- "proxy" : true ,
185- "params" : {
186- "method" : "POST" ,
187- "cache" : true ,
188- "data" : JSON . stringify ( {
189- "id" : sha_sub ( rpc_url2 , 6 ) ,
190- "method" : "blockchain.transaction.get" ,
191- "ref" : test_tx ,
192- "node" : rpc_url2
193- } )
194- }
195- } ) . done ( function ( e ) {
196- const api_result = br_result ( e ) ,
197- result = q_obj ( api_result , "result" ) ;
198- if ( is_valid_tx_hex ( result ) ) {
199- const is_selected = rpc_url2 === node_url ;
200- create_rpc_node_element ( api_options , true , node_id , node_data , is_selected , true ) ;
201- node_list_obj . push ( {
202- node_id,
203- rpc_url2
204- } ) ;
166+ else {
167+ let tport = null ;
168+ if ( url ) {
169+ const port_arr = nd [ 2 ] ;
170+ if ( is_array ( port_arr ) ) {
171+ tport = port_arr [ 1 ] ;
205172 }
206- } ) . always ( function ( ) {
207- if ( done ) return ;
208- const count = list_length - node_id ;
209- if ( count === 1 || count === 2 || count === 3 ) { // some margin for flexibility
210- done = true ;
211- const margin_timeout = setTimeout ( function ( ) {
212- br_set_session ( "electrum_" + currency , node_list_obj , true ) ;
213- rpc_list . addClass ( "show_select" ) ;
214- } , 500 , function ( ) {
215- clearTimeout ( margin_timeout ) ;
216- } ) ;
217- }
218- } ) ;
173+ }
174+ const port = tport ? ( ( / ^ \d / . test ( tport ) ) ? ":" + port : ":" + tport . slice ( 1 ) ) : "" ,
175+ rpc_url2 = url + port ,
176+ node_exists = check_node_exists ( rpc_url2 , existing_nodes ) ;
177+ if ( ! node_exists ) {
178+ const node_data = {
179+ "name" : "electrum" ,
180+ "url" : rpc_url2 ,
181+ "display" : true
182+ } ,
183+ test_tx = glob_const . test_tx [ currency ] ;
184+ api_proxy ( {
185+ "api" : currency ,
186+ "cachetime" : 25 ,
187+ "cachefolder" : "1h" ,
188+ "custom" : "electrum" ,
189+ "api_url" : rpc_url2 ,
190+ "proxy" : true ,
191+ "params" : {
192+ "method" : "POST" ,
193+ "cache" : true ,
194+ "data" : JSON . stringify ( {
195+ "id" : sha_sub ( rpc_url2 , 6 ) ,
196+ "method" : "blockchain.transaction.get" ,
197+ "ref" : test_tx ,
198+ "node" : rpc_url2
199+ } )
200+ }
201+ } ) . done ( function ( e ) {
202+ const api_result = br_result ( e ) ,
203+ result2 = q_obj ( api_result , "result" ) ;
204+ if ( is_valid_tx_hex ( result2 ) ) {
205+ const is_selected = rpc_url2 === node_url ;
206+ create_rpc_node_element ( api_options , true , node_id , node_data , is_selected , true ) ;
207+ node_list_obj . push ( {
208+ node_id,
209+ rpc_url2
210+ } ) ;
211+ }
212+ } ) . always ( function ( ) {
213+ if ( done ) return ;
214+ const count = list_length - node_id ;
215+ if ( count === 1 || count === 2 || count === 3 ) { // some margin for flexibility
216+ done = true ;
217+ const margin_timeout = setTimeout ( function ( ) {
218+ br_set_session ( "electrum_" + currency , node_list_obj , true ) ;
219+ rpc_list . addClass ( "show_select" ) ;
220+ } , 500 , function ( ) {
221+ clearTimeout ( margin_timeout ) ;
222+ } ) ;
223+ }
224+ } ) ;
225+ }
219226 }
220227 } ) ;
221228 }
0 commit comments