@@ -224,9 +224,8 @@ function check_api(payment, iserc20) {
224
224
function get_api_inputs_init ( rd , api_data ) {
225
225
if ( api_data ) {
226
226
const requestid = rd . requestid ,
227
- rqid = ( requestid ) ? requestid : "" ,
228
- fetch_id = rqid + api_data . name ;
229
- glob_api_attempts [ fetch_id ] = null ; // reset api attempts
227
+ rq_id = ( requestid ) ? requestid : "" ;
228
+ glob_api_attempts [ rq_id + api_data . name ] = null ; // reset api attempts
230
229
get_api_inputs ( rd , false , api_data ) ;
231
230
return
232
231
}
@@ -261,18 +260,22 @@ function get_api_inputs(rd, rdod, api_data) {
261
260
function select_api ( rd , rdo , api_dat ) {
262
261
const txhash = rd . txhash ,
263
262
requestid = rd . requestid ,
264
- fetch_id = ( txhash ) ? txhash : ( requestid ) ? requestid : "" ,
265
- glob_l2 = glob_l2network [ fetch_id ] , // get cached l2 network
263
+ rq_id = ( requestid ) ? requestid : "" ,
264
+ glob_l2 = glob_l2network [ rq_id ] , // get cached l2 network
266
265
api_data = ( glob_l2 ) ? glob_l2 : api_dat ,
267
266
api_name = api_data . name ;
268
- glob_api_attempts [ fetch_id ] = true ;
267
+ glob_api_attempts [ rq_id + api_name ] = true ;
269
268
if ( rd . lightning ) {
270
269
const l_fetch = lightning_fetch ( rd , api_data , rdo ) ;
271
270
if ( l_fetch == "exit" ) {
272
271
return
273
272
}
274
273
}
275
- if ( rd . payment == "monero" ) {
274
+ if ( api_name == "mymonero api" ) {
275
+ monero_fetch ( rd , api_data , rdo ) ;
276
+ return
277
+ }
278
+ if ( api_name == "blockchair_xmr" ) {
276
279
monero_fetch ( rd , api_data , rdo ) ;
277
280
return
278
281
}
@@ -314,7 +317,8 @@ function fail_dialogs(apisrc, error) {
314
317
}
315
318
316
319
function scan_match ( rd , api_data , rdo , counter , txdat , match , l2 ) {
317
- const src = rdo . source ;
320
+ const src = rdo . source ,
321
+ is_api = ( api_data . api ) ? true : false ;
318
322
if ( src == "list" ) {
319
323
tx_count ( rdo . statuspanel , counter ) ;
320
324
}
@@ -330,7 +334,7 @@ function scan_match(rd, api_data, rdo, counter, txdat, match, l2) {
330
334
}
331
335
glob_pinging [ txhash ] = setInterval ( function ( ) {
332
336
if ( glob_paymentpopup . hasClass ( "active" ) ) { // only when request is visible
333
- if ( api_data . api ) {
337
+ if ( is_api ) {
334
338
select_api ( rd , rdo , api_data ) ;
335
339
} else {
336
340
select_rpc ( rd , rdo , api_data ) ;
@@ -349,10 +353,12 @@ function scan_match(rd, api_data, rdo, counter, txdat, match, l2) {
349
353
}
350
354
if ( l2 ) { // Save L2 Network to session storage
351
355
const requestid = rd . requestid ,
352
- fetchid = ( txhash ) ? txhash : ( requestid ) ? requestid : "" ;
353
- if ( glob_l2network [ fetchid ] != api_data ) {
354
- glob_l2network [ fetchid ] = api_data ;
355
- br_set_session ( "l2source" , glob_l2network , true ) ;
356
+ rq_id = ( requestid ) ? requestid : "" ;
357
+ if ( rq_id . length ) {
358
+ if ( glob_l2network [ rq_id ] != api_data ) {
359
+ glob_l2network [ rq_id ] = api_data ;
360
+ br_set_session ( "l2source" , glob_l2network , true ) ;
361
+ }
356
362
}
357
363
}
358
364
return
@@ -362,7 +368,7 @@ function scan_match(rd, api_data, rdo, counter, txdat, match, l2) {
362
368
"error" : "Scanning next l2 rpc" ,
363
369
"console" : true
364
370
} ;
365
- if ( api_data . api ) {
371
+ if ( is_api ) {
366
372
handle_api_fails ( rd , rdo , console_l2 , api_data ) ;
367
373
return
368
374
}
@@ -449,8 +455,8 @@ function get_next_api(this_payment, api_name, requestid) {
449
455
if ( ! $ . isEmptyObject ( apilist ) ) {
450
456
const next_scan = apilist [ apilist . findIndex ( option => option . name == api_name ) + 1 ] ,
451
457
next_api = ( next_scan ) ? next_scan : apilist [ 0 ] ,
452
- rqid = ( requestid ) ? requestid : "" ;
453
- if ( glob_api_attempts [ rqid + next_api . name ] !== true ) {
458
+ rq_id = ( requestid ) ? requestid : "" ;
459
+ if ( glob_api_attempts [ rq_id + next_api . name ] !== true ) {
454
460
return next_api ;
455
461
}
456
462
}
@@ -583,7 +589,9 @@ function api_callback(requestid, nocache) {
583
589
}
584
590
585
591
function get_rpc_inputs_init ( rd , api_data ) {
586
- glob_rpc_attempts [ rd . requestid + api_data . url ] = null ; // reset api attempts
592
+ const requestid = rd . requestid ,
593
+ rq_id = ( requestid ) ? requestid : "" ;
594
+ glob_rpc_attempts [ rq_id + api_data . url ] = null ; // reset api attempts
587
595
get_rpc_inputs ( rd , false , api_data ) ;
588
596
}
589
597
@@ -615,10 +623,10 @@ function get_rpc_inputs(rd, rdod, api_data) {
615
623
function select_rpc ( rd , rdo , api_dat ) {
616
624
const txhash = rd . txhash ,
617
625
requestid = rd . requestid ,
618
- fetch_id = ( txhash ) ? txhash : ( requestid ) ? requestid : "" ,
619
- glob_l2 = glob_l2network [ fetch_id ] , // get cached l2 network
626
+ rq_id = ( requestid ) ? requestid : "" ,
627
+ glob_l2 = glob_l2network [ rq_id ] , // get cached l2 network
620
628
api_data = ( glob_l2 ) ? glob_l2 : api_dat ;
621
- glob_rpc_attempts [ fetch_id ] = true ;
629
+ glob_rpc_attempts [ rq_id + api_data . url ] = true ;
622
630
if ( is_btchain ( rd . payment ) === true ) {
623
631
mempoolspace_rpc ( rd , api_data , rdo , true ) ;
624
632
return
@@ -690,8 +698,8 @@ function get_next_rpc(this_payment, api_url, requestid) {
690
698
if ( ! $ . isEmptyObject ( restlist ) ) {
691
699
const next_scan = restlist [ restlist . findIndex ( option => option . url == api_url ) + 1 ] ,
692
700
next_rpc = ( next_scan ) ? next_scan : restlist [ 0 ] ,
693
- rqid = ( requestid ) ? requestid : "" ;
694
- if ( glob_rpc_attempts [ rqid + next_rpc . url ] !== true ) {
701
+ rq_id = ( requestid ) ? requestid : "" ;
702
+ if ( glob_rpc_attempts [ rq_id + next_rpc . url ] !== true ) {
695
703
return next_rpc ;
696
704
}
697
705
}
@@ -896,7 +904,7 @@ function init_historical_fiat_data(rd, conf, latestinput, firstinput) {
896
904
hc_prefix = "historic_" + thisrequestid ,
897
905
historiccache = br_get_session ( hc_prefix ) ,
898
906
cacheval = latestinput + latestconf ;
899
- if ( cacheval != historiccache ) { //new input detected; call historic api
907
+ if ( ( cacheval - historiccache ) > 1 ) { //new input detected; call historic api
900
908
br_remove_session ( hc_prefix ) ; // remove historic price cache
901
909
const historic_payload = $ . extend ( rd , {
902
910
"latestinput" : latestinput ,
0 commit comments