Skip to content

Commit 790cf3c

Browse files
committed
misc improvements
1 parent 858e4ad commit 790cf3c

10 files changed

+53
-24
lines changed

assets_js_bitrequest_core.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ function finish_functions() {
323323
//handle_ln_connect
324324
//handle_address
325325
//handle_viewkey
326+
//handle_node_url
326327

327328
// ** Helper Functions: **
328329
open_url();
@@ -1549,7 +1550,7 @@ function set_result(result) {
15491550
} else if (scan_subtype === "viewkey") {
15501551
handle_viewkey(result, payment_type);
15511552
} else if (scan_subtype === "add_node") {
1552-
$("#popup .formbox input#rpc_url_input").val(result);
1553+
handle_node_url(result);
15531554
}
15541555
window.history.back();
15551556
return false;
@@ -1621,6 +1622,16 @@ function handle_viewkey(result, payment) {
16211622
popnotify("error", "invalid " + payment + " viewkey");
16221623
}
16231624

1625+
// Validates URL / IP QR codes
1626+
function handle_node_url(result) {
1627+
const is_valid_entry = is_valid_url_or_ip(result);
1628+
if (!is_valid_entry) {
1629+
popnotify("error", tl("invalidurl"));
1630+
return
1631+
}
1632+
$("#popup .formbox input#rpc_url_input").val(result);
1633+
}
1634+
16241635
// ** Helper Functions: **
16251636

16261637
// Handles external URL opening with loader and browser targeting

assets_js_bitrequest_lang_controller.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ function tl(id, dat) {
9999
return lang_string;
100100
}
101101
// use english if string is not found.
102-
return languages.en.obj;
102+
return languages.en.obj || id;
103103
} catch (err) {
104104
console.error(err.name, err.message);
105105
// use english if language is not found.
106-
return languages.en.obj;
106+
return languages.en.obj || id;
107107
}
108108
}
109109

assets_js_bitrequest_lang_en.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ function lang_en(id, data) {
123123
"insufficient": "Insufficient",
124124
"new": "New",
125125
"pending": "Pending",
126+
"canceled": "Canceled",
126127
"expired": "expired",
127128
"type": "Type",
128129
"created": "Created",

assets_js_bitrequest_lang_fr.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ function lang_fr(id, data) {
123123
"insufficient": "Insuffisant",
124124
"new": "Nouveau",
125125
"pending": "En attente",
126+
"canceled": "Annulé",
126127
"expired": "expiré",
127128
"type": "Genre",
128129
"created": "Créé",

assets_js_bitrequest_lang_nl.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ function lang_nl(id, data) {
123123
"insufficient": "Onvoldoende",
124124
"new": "Nieuw",
125125
"pending": "In behandeling",
126+
"canceled": "Geannuleerd",
126127
"expired": "verlopen",
127128
"type": "Type",
128129
"created": "Aangemaakt op",

assets_js_bitrequest_lightning.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ function lightning_option_li(is_live, node_info, selected, invoices, proxy_url)
571571
implementation_icon = c_icons(implementation),
572572
lnurl_icon = has_lnurls ? "<div class='opt_icon icon-sphere' data-pe='none'></div>" : "",
573573
option = $("<div class='optionwrap" + status_class + selected_class + "' style='display:none' data-pe='none'>" +
574-
"<span data-value='" + node_id + "' data-live='" + status_icon + "'>" +
574+
"<span data-value='" + node_name + "' data-live='" + status_icon + "'>" +
575575
"<img src='" + implementation_icon + "' class='lnd_icon'/> " + node_name + "</span>" +
576576
"<div class='opt_icon_box' data-pe='none'>" +
577577
"<div class='opt_icon icon-bin' data-pe='none'></div>" +

assets_js_bitrequest_monitors.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,12 @@ function show_api_error(api_source, error_obj) {
563563

564564
// Extracts and normalizes error information from various API response formats
565565
function extract_error_details(error_obj) {
566+
if (typeof error_obj === "string") {
567+
return {
568+
"errorcode": 0,
569+
"errormessage": error_obj
570+
}
571+
}
566572
const error = q_obj(error_obj, "error");
567573
if (!error) return {
568574
"errorcode": 0,
@@ -718,7 +724,7 @@ function create_transaction_item(tx_details, request_type) {
718724
checked_span = "<span class='icon-checkmark' title='" + confirmation_title + "'></span>",
719725
confirmation_span = is_confirmed ? checked_span : confirmations ? "<div class='txli_conf' title='" + confirmation_title + "'><div class='confbar'></div><span>" + confirmation_title + "</span></div>" :
720726
"<div class='txli_conf' title='" + unconfirmed_text + "'><div class='confbar'></div><span>" + unconfirmed_text + "</span></div>",
721-
tx_list_item = $("<li><div class='txli_content'>" + formatted_date + confirmation_span + "<div class='txli_conf txl_canceled'><span class='icon-blocked'></span>Canceled</div><span class='tx_val'> + " + value_string + " <span class='icon-eye show_tx' title='view on blockexplorer'></span></span></div></li>");
727+
tx_list_item = $("<li><div class='txli_content'>" + formatted_date + confirmation_span + "<div class='txli_conf txl_canceled'><span class='icon-blocked'></span>" + tl("canceled") + "</div><span class='tx_val'> + " + value_string + " <span class='icon-eye show_tx' title='view on blockexplorer'></span></span></div></li>");
722728
if (glob_let.tx_list.includes(tx_hash)) { // check for indexed transaction id's
723729
return request_type === "outgoing" ? null : tx_list_item;
724730
}

assets_js_bitrequest_payments.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3295,7 +3295,7 @@ function update_request(update_args, should_save) {
32953295
const meta_status = meta_list.find("li.meta_status"),
32963296
set_confirmations = request_data.set_confirmations || 1,
32973297
conf_text = (update_args.confirmations == 0) ? tl("unconfirmedtx") : update_args.confirmations + " / " + set_confirmations + " " + tl("confirmations");
3298-
meta_status.attr("data-conf", update_args.confirmations).find(".txli_conf > span").text(conf_text);
3298+
meta_status.attr("data-conf", update_args.confirmations).find(".txli_conf > span").text(tl(conf_text));
32993299
const conf_bar = meta_status.find(".txli_conf > .confbar");
33003300
if (conf_bar.length) {
33013301
conf_bar.each(function(i) {

assets_js_bitrequest_rpcs.js

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,16 @@ function fetch_electrum_nodes(currency, node_url, predefined_nodes, custom_nodes
115115
$.each(get_session_nodes, function(index, val) {
116116
const rpc_url = val.rpc_url2,
117117
v = val.v,
118-
node_exists = objectkey_in_array(existing_nodes , "url", rpc_url);
118+
node_exists = objectkey_in_array(existing_nodes, "url", rpc_url);
119119
if (!node_exists) {
120120
const node_data = {
121-
"name": "electrum",
122-
"url": rpc_url,
123-
"display": true,
124-
v
125-
},
126-
node_id = val.node_id,
127-
is_selected = rpc_url === node_url;
121+
"name": "electrum",
122+
"url": rpc_url,
123+
"display": true,
124+
v
125+
},
126+
node_id = val.node_id,
127+
is_selected = rpc_url === node_url;
128128
create_rpc_node_element(api_options, true, node_id, node_data, is_selected, true);
129129
has_nodes = true;
130130
}
@@ -177,7 +177,7 @@ function fetch_electrum_nodes(currency, node_url, predefined_nodes, custom_nodes
177177
}
178178
const port = tport ? ((/^\d/.test(tport)) ? ":" + port : ":" + tport.slice(1)) : "",
179179
rpc_url2 = url + port,
180-
node_exists = objectkey_in_array(existing_nodes , "url", rpc_url2);
180+
node_exists = objectkey_in_array(existing_nodes, "url", rpc_url2);
181181
if (!node_exists) {
182182
const node_data = {
183183
"name": "electrum",
@@ -498,8 +498,15 @@ function submit_rpcnode() {
498498
selected_config = node_input.data(),
499499
input_section = dialog_box.find("#rpc_input_box");
500500
if (input_section.length) {
501-
const node_url = input_section.find("#rpc_url_input").val();
502-
if (node_url.length > 5) {
501+
const node_url = input_section.find("#rpc_url_input").val(),
502+
url_length = node_url.length;
503+
if (url_length) {
504+
const is_valid_entry = is_valid_url_or_ip(node_url);
505+
if (url_length < 6 || !is_valid_entry) {
506+
popnotify("error", tl("invalidurl"));
507+
play_audio(glob_const.funk);
508+
return
509+
}
503510
const options = dialog_box.find("#api_list .options .optionwrap"),
504511
url_exists = nodes_match(options, node_url);
505512
if (url_exists) {
@@ -517,8 +524,8 @@ function submit_rpcnode() {
517524
validate_rpc_connection(input_section, node_config, currency_name);
518525
return
519526
}
527+
save_rpc_settings(currency_name, selected_config, false);
520528
}
521-
save_rpc_settings(currency_name, selected_config, false)
522529
})
523530
}
524531

@@ -646,15 +653,15 @@ function validate_rpc_connection(input_section, node_config, currency_name) {
646653
}
647654
}
648655
}
649-
test_mempoolspace(input_section, node_config, rpc_url, currency_name);
656+
test_mempoolspace(input_section, node_config, currency_name);
650657
}).fail(function(xhr, stat, err) {
651-
test_mempoolspace(input_section, node_config, rpc_url, currency_name);
658+
test_mempoolspace(input_section, node_config, currency_name);
652659
});
653660
return
654661
}
655-
test_mempoolspace(input_section, node_config, rpc_url, currency_name);
662+
test_mempoolspace(input_section, node_config, currency_name);
656663
}).fail(function(xhr, stat, err) {
657-
test_mempoolspace(input_section, node_config, rpc_url, currency_name);
664+
test_mempoolspace(input_section, node_config, currency_name);
658665
});
659666
return
660667
}
@@ -755,9 +762,10 @@ function is_valid_tx_hex(hex_string) {
755762
return is_hex && hex_string.length > 250;
756763
}
757764

758-
function test_mempoolspace(input_section, node_config, rpc_url, currency_name) {
765+
function test_mempoolspace(input_section, node_config, currency_name) {
759766
const test_address = glob_const.test_address[currency_name],
760-
error_message = tl("unabletoconnect");
767+
error_message = tl("unabletoconnect"),
768+
rpc_url = node_config.url;
761769
api_proxy({
762770
"api_url": rpc_url + "/api/address/" + test_address + "/txs",
763771
"proxy": rpc_url.includes(".onion"),

assets_js_bitrequest_sockets.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,7 @@ async function process_nfc_payment(proxy_host, proxy_key, payment_id, node_id, i
512512
"id": payment_id,
513513
"nid": node_id,
514514
"expiry": 60,
515+
"boltcard": true,
515516
"x-api": proxy_key
516517
};
517518
if (request_type === "incoming") {

0 commit comments

Comments
 (0)