Skip to content

Commit c3589fb

Browse files
committed
misc improvements
1 parent be95674 commit c3589fb

7 files changed

+76
-39
lines changed

assets_js_bitrequest_core.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -549,9 +549,8 @@ function finish_functions() {
549549
//amountshort
550550
check_params();
551551
const ap = all_proxies(),
552-
all_tor_proxies = filter_object_array(ap, "tor", true),
553-
tor_proxy = random_array_item(all_tor_proxies); // pick tor proxy
554-
glob_let.tor_proxy = tor_proxy;
552+
all_tor_proxies = filter_object_array(ap, "tor", true);
553+
glob_let.tor_proxies = filter_object_array(all_tor_proxies, "tor", true);
555554
}
556555

557556
// Updates HTML document language and meta tag attributes based on current language code

assets_js_bitrequest_fetchblocks.js

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,8 @@ function process_ethereum_transactions(rd, api_data, rdo) {
354354
tx_list.append(tx_item.data(parsed_tx));
355355
tx_count++;
356356
}
357+
} else {
358+
return false;
357359
}
358360
}
359361
});
@@ -490,6 +492,8 @@ function blockchair_fetch(rd, api_data, rdo) {
490492
tx_list.append(tx_item.data(parsed_tx));
491493
tx_count++;
492494
}
495+
} else {
496+
return false;
493497
}
494498
}
495499
});
@@ -515,6 +519,8 @@ function blockchair_fetch(rd, api_data, rdo) {
515519
tx_list.append(tx_item.data(parsed_tx));
516520
tx_count++;
517521
}
522+
} else {
523+
return false;
518524
}
519525
}
520526
});
@@ -542,21 +548,21 @@ function blockchair_fetch(rd, api_data, rdo) {
542548
const tx_result = br_result(tx_response).result,
543549
blockchain_data = tx_result.data;
544550
if (blockchain_data) {
545-
if (has_tx(blockchain_data)) {
546-
$.each(blockchain_data, function(date, tx) {
547-
const parsed_tx = blockchair_scan_data(tx, rdo.setconfirmations, currency_symbol, wallet_address, block_height);
548-
if (parsed_tx.transactiontime > rdo.request_timestamp && parsed_tx.ccval) { // get all transactions after requestdate
549-
matched_tx = parsed_tx;
550-
if (source === "requests") {
551-
const tx_item = create_transaction_item(parsed_tx, rd.requesttype);
552-
if (tx_item) {
553-
tx_list.append(tx_item.data(parsed_tx));
554-
tx_count++;
555-
}
551+
$.each(blockchain_data, function(date, tx) {
552+
const parsed_tx = blockchair_scan_data(tx, rdo.setconfirmations, currency_symbol, wallet_address, block_height);
553+
if (parsed_tx.transactiontime > rdo.request_timestamp && parsed_tx.ccval) { // get all transactions after requestdate
554+
matched_tx = parsed_tx;
555+
if (source === "requests") {
556+
const tx_item = create_transaction_item(parsed_tx, rd.requesttype);
557+
if (tx_item) {
558+
tx_list.append(tx_item.data(parsed_tx));
559+
tx_count++;
556560
}
561+
} else {
562+
return false;
557563
}
558-
});
559-
}
564+
}
565+
});
560566
process_scan_results(rd, api_data, rdo, tx_count, matched_tx);
561567
return
562568
}
@@ -701,6 +707,8 @@ function scan_layer2_transactions(rd, api_data, rdo, contract, chainid) {
701707
tx_list.append(tx_item.data(parsed_tx));
702708
tx_count++;
703709
}
710+
} else {
711+
return false;
704712
}
705713
}
706714
});
@@ -750,6 +758,8 @@ function scan_layer2_transactions(rd, api_data, rdo, contract, chainid) {
750758
tx_list.append(tx_item.data(parsed_tx));
751759
tx_count++;
752760
}
761+
} else {
762+
return false;
753763
}
754764
}
755765
});
@@ -803,8 +813,9 @@ function scan_layer2_transactions(rd, api_data, rdo, contract, chainid) {
803813
if (tx_item) {
804814
tx_list.append(tx_item.data(parsed_tx));
805815
}
816+
} else {
817+
return false;
806818
}
807-
return
808819
}
809820
}
810821
});
@@ -853,8 +864,9 @@ function scan_layer2_transactions(rd, api_data, rdo, contract, chainid) {
853864
if (tx_item) {
854865
tx_list.append(tx_item.data(parsed_tx));
855866
}
867+
} else {
868+
return false;
856869
}
857-
return
858870
}
859871
}
860872
});
@@ -983,8 +995,9 @@ function scan_monero_transactions(rd, api_data, rdo, viewkey) {
983995
rdo.transactionlist.append(tx_item.data(tx_data));
984996
tx_count++;
985997
}
998+
} else {
999+
return false;
9861000
}
987-
return false;
9881001
}
9891002
}
9901003
}
@@ -1155,6 +1168,8 @@ function scan_bitcoin_transactions(rd, api_data, rdo, block_height) {
11551168
tx_list.append(tx_item.data(parsed_tx));
11561169
tx_count++;
11571170
}
1171+
} else {
1172+
return false;
11581173
}
11591174
}
11601175
});
@@ -1273,6 +1288,8 @@ function process_blockcypher_transactions(rd, api_data, rdo) {
12731288
tx_list.append(tx_item.data(parsed_tx));
12741289
tx_count++;
12751290
}
1291+
} else {
1292+
return false;
12761293
}
12771294
}
12781295
}
@@ -1378,6 +1395,8 @@ function process_nimiq_transactions(rd, api_data, rdo) {
13781395
tx_list.append(tx_item.data(parsed_tx));
13791396
tx_count++;
13801397
}
1398+
} else {
1399+
return false;
13811400
}
13821401
}
13831402
}
@@ -1591,6 +1610,8 @@ function scan_kaspa_transactions(rd, api_data, rdo, blue_score) {
15911610
tx_list.append(tx_item.data(parsed_tx));
15921611
tx_count++;
15931612
}
1613+
} else {
1614+
return false;
15941615
}
15951616
}
15961617
});
@@ -1688,8 +1709,7 @@ function process_dash_transactions(rd, api_data, rdo) {
16881709
const transactions = api_result.txs;
16891710
if (transactions) {
16901711
if (has_tx(transactions)) {
1691-
const sorted_txs = sort_transactions_by_date(insight_scan_data, transactions);
1692-
$.each(sorted_txs, function(date, tx) {
1712+
$.each(transactions, function(date, tx) {
16931713
const parsed_tx = insight_scan_data(tx, rdo.setconfirmations, rd.address);
16941714
if (parsed_tx.transactiontime > rdo.request_timestamp && parsed_tx.ccval) {
16951715
matched_tx = parsed_tx;
@@ -1699,6 +1719,8 @@ function process_dash_transactions(rd, api_data, rdo) {
16991719
tx_list.append(tx_item.data(parsed_tx));
17001720
tx_count++;
17011721
}
1722+
} else {
1723+
return false;
17021724
}
17031725
}
17041726
});
@@ -2585,7 +2607,7 @@ function blockcypher_scan_data(data, setconfirmations, ccsymbol) {
25852607

25862608
// Processes Insight API transaction data with script pubkey validation and DASH-specific features
25872609
function insight_scan_data(data, setconfirmations, address) {
2588-
const base_time = data.time ? data.time : data.blocktime ? data.blocktime : false,
2610+
const base_time = data.time || data.blocktime,
25892611
tx_timestamp = base_time ? base_time * 1000 : now(),
25902612
tx_time_utc = tx_timestamp ? tx_timestamp + glob_const.timezone : null;
25912613
if (setconfirmations === "sort") {

assets_js_bitrequest_monitors.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,9 @@ function route_blockchain_rpc(rd, api_data, rdo) {
351351
// Processes transaction scan results and handles Ethereum L2, confirmations, and UI updates based on match type
352352
function process_scan_results(rd, api_data, rdo, counter, tx_details, l2) {
353353
glob_let.apikey_fails = false;
354-
const src = rdo.source;
354+
const src = rdo.source,
355+
pending = rdo.pending
356+
tx_hash = tx_details.txhash || rd.txhash;
355357
if (src === "requests") {
356358
if (counter) {
357359
update_transaction_count(rdo.statuspanel, counter);
@@ -362,7 +364,6 @@ function process_scan_results(rd, api_data, rdo, counter, tx_details, l2) {
362364
}
363365
}
364366
if (tx_details) {
365-
const tx_hash = rd.txhash || tx_details.txhash;
366367
if (!tx_hash) return;
367368
const eth_layer2 = tx_details.eth_layer2;
368369
if (src === "requests") {
@@ -383,15 +384,21 @@ function process_scan_results(rd, api_data, rdo, counter, tx_details, l2) {
383384
if (eth_layer2) { // Eth layer 2
384385
initialize_network_status(api_data, "paid");
385386
}
386-
tx_details.txhash = tx_hash;
387387
if (src !== "after_scan") {
388+
if (pending === "scanning") {
389+
const tx_exists = get_requestli("txhash", tx_hash); // scan pending tx's to prevent duplicates, mempool tx's don't have correct timestamps
390+
if (tx_exists.length) {
391+
// duplicate
392+
return
393+
}
394+
}
388395
const status = validate_confirmations(tx_details);
389396
if (status === "paid") {
390397
force_close_socket();
391398
return
392399
}
393400
}
394-
if (rdo.pending === "scanning") { // scanning
401+
if (pending === "scanning") { // scanning
395402
// After scan
396403
if (src === "after_scan") {
397404
glob_const.html.addClass("blurmain_payment");

assets_js_bitrequest_payments.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3186,13 +3186,15 @@ function save_payment_request(direct, lightning_url) {
31863186

31873187
// update username
31883188
const default_name = "Bitrequest";
3189-
if (request_name !== default_name || current_request_type === "local" || current_request_type === "outgoing") {
3190-
const saved_name = request.saved_name;
3191-
if (saved_name === default_name) {
3192-
set_setting("accountsettings", {
3193-
"selected": request_name
3194-
}, request_name);
3195-
save_settings();
3189+
if (request_name) {
3190+
if (request_name !== default_name && (current_request_type === "local" || current_request_type === "outgoing")) {
3191+
const saved_name = request.saved_name;
3192+
if (saved_name === default_name) {
3193+
set_setting("accountsettings", {
3194+
"selected": request_name
3195+
}, request_name);
3196+
save_settings();
3197+
}
31963198
}
31973199
}
31983200
append_request(append_object);

assets_js_bitrequest_polling.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//start_transaction_monitor
1+
//start_transaction_monitor
22
//route_transaction_monitor
33
//monitor_main_chain
44
//monitor_layer2_chain

assets_js_bitrequest_rpcs.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,8 +567,9 @@ function submit_rpcnode() {
567567
validate_rpc_connection(input_section, node_config, currency_name);
568568
return
569569
}
570-
save_rpc_settings(currency_name, selected_config, false);
570+
return
571571
}
572+
save_rpc_settings(currency_name, selected_config, false);
572573
})
573574
}
574575

assets_js_lib_global_queries.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ const br_bipobj = br_get_local("bpdat", true),
3333
displayed_proxies = filter_object_array(br_proxy_list, "display", true),
3434
br_hosted_proxy = random_array_item(displayed_proxies), // load balance proxies
3535
tor_proxies = filter_object_array(br_proxy_list, "tor", true),
36-
tor_proxy = random_array_item(tor_proxies), // pick tor proxy
3736
br_firebase_dynamic_link_domain = "bitrequest.page.link",
3837
br_androidpackagename = "io.bitrequest.app",
3938
br_useragent = navigator.userAgent || navigator.vendor || window.opera,
@@ -227,7 +226,7 @@ const br_bipobj = br_get_local("bpdat", true),
227226
"proxy": 0
228227
},
229228
"overflow_detected": false,
230-
tor_proxy,
229+
tor_proxies,
231230
}
232231

233232
// Global helpers
@@ -863,7 +862,11 @@ function generate_random_number(min, max) {
863862
}
864863
// Returns random element from array using Math.random() distribution
865864
function random_array_item(arr) {
866-
return arr[Math.floor(Math.random() * arr.length)];
865+
if (is_array(arr)) {
866+
return arr[Math.floor(Math.random() * arr.length)];
867+
}
868+
return false;
869+
867870
}
868871

869872
// Initializes API keys from encoded storage or triggers fresh key generation
@@ -1100,7 +1103,10 @@ function api_proxy(ad, p_proxy) {
11001103
// add tor proxy and stringify payload
11011104
if (payload) {
11021105
if (is_onion) {
1103-
payload.tor_proxy = glob_const.tor_proxy.proxy;
1106+
const random_proxy = random_array_item(glob_let.tor_proxies);
1107+
if (random_proxy) {
1108+
payload.tor_proxy = random_proxy.proxy;
1109+
}
11041110
}
11051111
ad.params.data = JSON.stringify(payload);
11061112
}

0 commit comments

Comments
 (0)