Skip to content

Commit e850542

Browse files
committed
proxy version 0.021
1 parent 23dbb75 commit e850542

13 files changed

+271
-234
lines changed

assets_js_bitrequest_core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4436,7 +4436,7 @@ function expand_shoturl(input_param) {
44364436
if (input_param) {
44374437
const proxy_index = input_param.slice(0, 1),
44384438
short_id = input_param.slice(1),
4439-
proxy_url = glob_const.proxy_list[proxy_index],
4439+
proxy_url = glob_const.proxy_list[proxy_index].proxy,
44404440
is_secure_url = (proxy_url.indexOf("https://") >= 0);
44414441
if (is_secure_url) {
44424442
const request_payload = {

assets_js_bitrequest_fetchblocks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1849,7 +1849,7 @@ function mempoolspace_blockheight_fails(rd, api_data, rdo, rpc) {
18491849
mempoolspace_rpc(rd, api_data, rdo, rpc);
18501850
}
18511851

1852-
// Processes Nano transactions via RPC with support for account scanning and block verification
1852+
// Processes Electrum transactions via RPC with support for account scanning and block verification
18531853
function electrum_rpc(rd, api_data, rdo, latest_block) {
18541854
const currency = rd.payment,
18551855
tx_list = rdo.transactionlist,

assets_js_bitrequest_lightning.js

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ $(document).ready(function() {
4949
//s_lnd_proxy
5050
//is_local_node
5151
//cancelpd
52-
//node_exists
5352
//fetch_node
5453
//fetch_other_nodes
5554
//fetch_proxy
@@ -1025,7 +1024,7 @@ function add_custom_proxy(proxy_url) {
10251024
const proxy_node = $("#api_proxy"),
10261025
proxy_node_data = proxy_node.data(),
10271026
custom_proxies = proxy_node_data.custom_proxies;
1028-
if (custom_proxies.includes(proxy_url) || glob_const.proxy_list.includes(proxy_url)) {
1027+
if (custom_proxies.includes(proxy_url) || value_in_array(glob_const.proxy_list, proxy_url)) {
10291028
return false;
10301029
}
10311030
custom_proxies.push(proxy_url);
@@ -1100,7 +1099,7 @@ function trigger_ln() {
11001099
return
11011100
}
11021101
const normalized_url = complete_url(input_proxy_url),
1103-
is_default_proxy = $.inArray(normalized_url, glob_const.proxy_list) !== -1;
1102+
is_default_proxy = value_in_array(glob_const.proxy_list, normalized_url);
11041103
if (is_default_proxy) {
11051104
popnotify("error", tl("defaultproxy", {
11061105
"fixed_url": normalized_url
@@ -1243,7 +1242,7 @@ function test_create_invoice(implementation, proxy_data, node_host, node_key) {
12431242
node_services = lightning_data.services,
12441243
node_id_source = node_host ? (implementation == "lnbits" ? node_key : node_host) : proxy_url + implementation,
12451244
node_id = sha_sub(node_id_source, 10),
1246-
is_node_existing = node_exists(node_services, node_id),
1245+
is_node_existing = value_in_array(node_services, node_id),
12471246
default_error = tl("unabletoconnect"),
12481247
unique_id = sha_sub(now(), 10);
12491248

@@ -1586,14 +1585,6 @@ function cancelpd() {
15861585
}
15871586
}
15881587

1589-
// Verifies if node ID exists in provided node list
1590-
function node_exists(node_services, node_id) {
1591-
if (empty_obj(node_services)) {
1592-
return false;
1593-
}
1594-
return node_services.some(node => node.node_id === node_id);
1595-
}
1596-
15971588
// Retrieves node by ID from node list
15981589
function fetch_node(node_services, node_id) {
15991590
return node_services.find(node => node.node_id === node_id);

assets_js_bitrequest_payments.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2745,9 +2745,9 @@ function custom_shorten(service, shared_url, shared_title, site_thumb, url_hash)
27452745
}
27462746
const request_id = data.shorturl;
27472747
if (request_id) {
2748-
const server_index = glob_const.proxy_list.indexOf(server),
2749-
is_default_server = server_index > -1;
2750-
const short_url = is_default_server ?
2748+
const server_index = find_object_index(server, glob_const.proxy_list, "proxy"),
2749+
is_default_server = value_in_array(glob_const.proxy_list, server);
2750+
short_url = is_default_server ?
27512751
glob_const.approot + "?i=" + server_index.toString() + request_id :
27522752
server + "proxy/v1/inv/4bR" + request_id;
27532753
share_request(short_url, shared_title);

assets_js_bitrequest_rpcs.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ $(document).ready(function() {
33
edit_rpcnode();
44
//fetch_electrum_nodes
55
//get_random_electrum_node
6-
//check_node_exists
76
//get_rpc_placeholder
87
//validate_and_add_rpc_node
98
//create_rpc_node_element
@@ -114,7 +113,7 @@ function fetch_electrum_nodes(currency, node_url, predefined_nodes, custom_nodes
114113
let has_nodes = false;
115114
$.each(get_session_nodes, function(index, val) {
116115
const rpc_url = val.rpc_url2,
117-
node_exists = check_node_exists(rpc_url, existing_nodes);
116+
node_exists = value_in_array(rpc_url, existing_nodes);
118117
if (!node_exists) {
119118
node_data = {
120119
"name": "electrum",
@@ -163,8 +162,7 @@ function fetch_electrum_nodes(currency, node_url, predefined_nodes, custom_nodes
163162
filter_ips = is_valid_ipv4(url);
164163
if (filter_ips) {
165164
// filter out electrum ip's and only add regular urls
166-
}
167-
else {
165+
} else {
168166
let tport = null;
169167
if (url) {
170168
const port_arr = nd[2];
@@ -174,7 +172,7 @@ function fetch_electrum_nodes(currency, node_url, predefined_nodes, custom_nodes
174172
}
175173
const port = tport ? ((/^\d/.test(tport)) ? ":" + port : ":" + tport.slice(1)) : "",
176174
rpc_url2 = url + port,
177-
node_exists = check_node_exists(rpc_url2, existing_nodes);
175+
node_exists = value_in_array(existing_nodes, rpc_url2);
178176
if (!node_exists) {
179177
const node_data = {
180178
"name": "electrum",
@@ -243,11 +241,6 @@ function get_random_electrum_node(predefined_nodes) {
243241
return null;
244242
}
245243

246-
// Search for any object in the array that has the matching URL
247-
function check_node_exists(url_to_find, node_array) {
248-
return node_array.some(node => node.url === url_to_find);
249-
}
250-
251244
// Provides template URL examples for different cryptocurrency node configurations and API types
252245
function get_rpc_placeholder(currency) {
253246
return {

assets_js_bitrequest_settings.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2637,9 +2637,9 @@ function trigger_proxy_dialog() {
26372637
// Displays proxy configuration dialog with available servers and custom proxy input
26382638
function pick_api_proxy() {
26392639
$(document).on("click", "#api_proxy", function() {
2640-
const proxies = all_proxies(),
2641-
proxy = d_proxy(),
2642-
content = "\
2640+
const proxies = all_proxies("display"),
2641+
proxy = d_proxy();
2642+
const content = "\
26432643
<div class='formbox' id='proxyformbox'>\
26442644
<h2 class='icon-sphere'>API Proxy</h2>\
26452645
<div class='popnotify'></div>\
@@ -2681,7 +2681,7 @@ function pick_api_proxy() {
26812681
const options = $("#proxyformbox").find(".options");
26822682
$.each(proxies, function(key, value) {
26832683
const selected = (value === proxy),
2684-
dfault = $.inArray(value, glob_const.proxy_list) !== -1;
2684+
dfault = value_in_array(glob_const.proxy_list, value);
26852685
test_append_proxy(options, key, value, selected, dfault);
26862686
});
26872687
})
@@ -2770,7 +2770,7 @@ function test_custom_proxy(value) {
27702770
data = node.data(),
27712771
proxies = data.custom_proxies,
27722772
url = complete_url(value);
2773-
if ($.inArray(url, proxies) !== -1 || $.inArray(url, glob_const.proxy_list) !== -1) {
2773+
if ($.inArray(url, proxies) !== -1 || value_in_array(glob_const.proxy_list, url)) {
27742774
popnotify("error", tl("proxyexists"));
27752775
return false;
27762776
}
@@ -3043,7 +3043,7 @@ function json_check_apikey(keylength, ref, payload, keyval, lastInput) {
30433043
if (keyval.length > keylength) {
30443044
if (ref === "infura" || ref === "alchemy") {
30453045
const txhash = "0x919408272d05b3fd7ccfa1f47c10bea425891c8aa47ba7309dc3beb0b89197f1",
3046-
baseUrl = ref === "infura" ? glob_const.main_eth_node : glob_const.main_alchemy_node,
3046+
base_url = ref === "infura" ? glob_const.main_eth_node : glob_const.main_alchemy_node,
30473047
json = {
30483048
"jsonrpc": "2.0",
30493049
"id": 3,
@@ -3052,7 +3052,7 @@ function json_check_apikey(keylength, ref, payload, keyval, lastInput) {
30523052
};
30533053
api_proxy({
30543054
"api": ref,
3055-
"api_url": baseUrl + keyval,
3055+
"api_url": base_url + keyval,
30563056
"proxy": false,
30573057
"params": {
30583058
"method": "POST",
@@ -3073,8 +3073,8 @@ function json_check_apikey(keylength, ref, payload, keyval, lastInput) {
30733073
});
30743074
return
30753075
}
3076-
const apiData = get_api_data(ref),
3077-
baseUrl = apiData.base_url,
3076+
const api_data = get_api_data(ref),
3077+
base_url = api_data.base_url,
30783078
method = (ref === "firebase" || ref === "bitly") ? "POST" : "GET",
30793079
params = {
30803080
"method": method,
@@ -3096,27 +3096,27 @@ function json_check_apikey(keylength, ref, payload, keyval, lastInput) {
30963096
"bitlink_id": "bit.ly/12a4b6c"
30973097
});
30983098
}
3099-
const apiUrl = baseUrl + search,
3099+
const api_url = base_url + search,
31003100
proxy = (ref === "coinmarketcap"),
3101-
reqData = {
3101+
req_data = {
31023102
"api": ref,
31033103
"search": search,
31043104
"cachetime": 0,
31053105
"cachefolder": "1h",
3106-
"api_url": apiUrl,
3106+
"api_url": api_url,
31073107
"proxy": proxy,
31083108
"params": params
31093109
};
3110-
api_proxy(reqData).done(function(e) {
3110+
api_proxy(req_data).done(function(e) {
31113111
const data = br_result(e).result;
31123112
if (data) {
3113-
const failMsg = tl("apicallfailed");
3113+
const fail_msg = tl("apicallfailed");
31143114
if ((ref === "etherscan" || ref === "arbiscan" || ref === "polygonscan" || ref === "bscscan") && data.status != 1) {
31153115
if (str_match(data.result, "Invalid API Key")) {
31163116
api_fail(ref, keyval);
31173117
} else {
31183118
notify(tl("apicallerror"));
3119-
const content = "<h2 class='icon-blocked'>" + failMsg + "</h2><p class='doselect'>" + data.message + "</p>";
3119+
const content = "<h2 class='icon-blocked'>" + fail_msg + "</h2><p class='doselect'>" + data.message + "</p>";
31203120
popdialog(content, "canceldialog");
31213121
}
31223122
return
@@ -3133,7 +3133,7 @@ function json_check_apikey(keylength, ref, payload, keyval, lastInput) {
31333133
api_fail(ref, keyval);
31343134
} else {
31353135
notify(tl("apicallerror"));
3136-
const content = "<h2 class='icon-blocked'>" + failMsg + "</h2><p class='doselect'>" + data.error + "</p>";
3136+
const content = "<h2 class='icon-blocked'>" + fail_msg + "</h2><p class='doselect'>" + data.error + "</p>";
31373137
popdialog(content, "canceldialog");
31383138
}
31393139
return
@@ -3157,7 +3157,7 @@ function json_check_apikey(keylength, ref, payload, keyval, lastInput) {
31573157
api_fail(ref, keyval);
31583158
} else {
31593159
notify(tl("apicallerror"));
3160-
const content = "<h2 class='icon-blocked'>" + failMsg + "</h2><p class='doselect'>" + data.error + "</p>";
3160+
const content = "<h2 class='icon-blocked'>" + fail_msg + "</h2><p class='doselect'>" + data.error + "</p>";
31613161
popdialog(content, "canceldialog");
31623162
}
31633163
return
@@ -3170,7 +3170,7 @@ function json_check_apikey(keylength, ref, payload, keyval, lastInput) {
31703170
api_fail(ref, keyval);
31713171
} else {
31723172
notify(tl("apicallerror"));
3173-
const content = "<h2 class='icon-blocked'>" + failMsg + "</h2><p class='doselect'>" + data.error + "</p>";
3173+
const content = "<h2 class='icon-blocked'>" + fail_msg + "</h2><p class='doselect'>" + data.error + "</p>";
31743174
popdialog(content, "canceldialog");
31753175
}
31763176
}
@@ -3183,7 +3183,7 @@ function json_check_apikey(keylength, ref, payload, keyval, lastInput) {
31833183
api_fail(ref, keyval);
31843184
} else {
31853185
notify(tl("apicallerror"));
3186-
const content = "<h2 class='icon-blocked'>" + failMsg + "</h2><p class='doselect'>" + ec + "</p>";
3186+
const content = "<h2 class='icon-blocked'>" + fail_msg + "</h2><p class='doselect'>" + ec + "</p>";
31873187
popdialog(content, "canceldialog");
31883188
}
31893189
return
@@ -3194,7 +3194,7 @@ function json_check_apikey(keylength, ref, payload, keyval, lastInput) {
31943194
api_fail(ref, keyval);
31953195
} else {
31963196
notify(tl("apicallerror"));
3197-
const content = "<h2 class='icon-blocked'>" + failMsg + "</h2><p class='doselect'>" + data.error + "</p>";
3197+
const content = "<h2 class='icon-blocked'>" + fail_msg + "</h2><p class='doselect'>" + data.error + "</p>";
31983198
popdialog(content, "canceldialog");
31993199
}
32003200
return

0 commit comments

Comments
 (0)