Skip to content

Commit c2e8da5

Browse files
committed
proxy version 0.025
1 parent de10639 commit c2e8da5

17 files changed

+150
-270
lines changed

assets_js_bitrequest_core.js

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ function finish_functions() {
488488
// ** URL & Link Handling: **
489489
//set_xmr_node_access
490490
//check_intents
491-
//expand_shoturl
491+
//expand_shorturl
492492
//expand_bitly_url
493493
//open_blockexplorer_url
494494
//blockexplorer_url
@@ -533,7 +533,6 @@ function finish_functions() {
533533
//buildpage
534534
//append_coinsetting
535535
//setting_sub_address
536-
//truncate
537536
//append_address
538537
//append_request
539538

@@ -3930,7 +3929,7 @@ function get_pdf_url(request_data) {
39303929
invoice_data[transclear("network")] = network;
39313930
}
39323931
const proxy_url = d_proxy();
3933-
return proxy_url + "proxy/v1/receipt/?data=" + btoa(JSON.stringify(invoice_data));
3932+
return proxy_url + "/proxy/v1/receipt/?data=" + btoa(JSON.stringify(invoice_data));
39343933
}
39353934

39363935
// ** Archive Management: **
@@ -4075,7 +4074,7 @@ function lnd_lookup_invoice(proxy, impl, hash, node_id, peer_id, password) {
40754074
const proxy_data = lnurl_deform(proxy),
40764075
proxy_host = proxy_data.url,
40774076
proxy_key = password || proxy_data.k,
4078-
api_url = proxy_host + "proxy/v1/ln/api/",
4077+
api_url = proxy_host + "/proxy/v1/ln/api/",
40794078
request_data = {
40804079
"method": "POST",
40814080
"cache": false,
@@ -4408,7 +4407,7 @@ function check_intents(encoded_scheme) {
44084407
}
44094408

44104409
// Expands shortened URLs with caching and platform handling
4411-
function expand_shoturl(input_param) {
4410+
function expand_shorturl(input_param) {
44124411
if (input_param.startsWith("4bR")) { // handle bitly shortlink
44134412
expand_bitly_url(input_param);
44144413
return
@@ -4432,7 +4431,7 @@ function expand_shoturl(input_param) {
44324431
"method": "POST",
44334432
"cache": false,
44344433
"timeout": 5000,
4435-
"url": proxy_url + "proxy/v1/inv/api/",
4434+
"url": proxy_url + "/proxy/v1/inv/api/",
44364435
"data": request_payload
44374436
}).done(function(response) {
44384437
const parsed_data = br_result(response).result;
@@ -4794,7 +4793,7 @@ function build_settings() {
47944793
<span class='" + setting.icon + "'></span>\
47954794
<div class='atext'>\
47964795
<h2>" + tl(setting_id) + "</h2>\
4797-
<p>" + truncate(display_val) + "</p>\
4796+
<p>" + truncate_middle(display_val) + "</p>\
47984797
</div>\
47994798
<div class='iconbox'>\
48004799
<span class='icon-pencil'></span>\
@@ -4815,7 +4814,7 @@ function render_settings(excludes) {
48154814
const selected_val = setting.selected,
48164815
trans_val = tl(selected_val),
48174816
display_val = setting_id === "accountsettings" ? selected_val : (trans_val || selected_val); // Exclude translations
4818-
$("#" + setting.id).data(setting).find("p").text(truncate(display_val));
4817+
$("#" + setting.id).data(setting).find("p").text(truncate_middle(display_val));
48194818
}
48204819
});
48214820
}
@@ -5000,22 +4999,7 @@ function append_coinsetting(currency, settings) {
50004999
// Subtitle for settings
50015000
function setting_sub_address(name, url, custom) {
50025001
const sub_title = (custom === true || name === "electrum") ? url || name : name || url;
5003-
return exists(sub_title) ? truncate(sub_title) : "";
5004-
}
5005-
5006-
// Shorten long titles
5007-
function truncate(str) {
5008-
// Check if value is a string
5009-
if (typeof str === "string") {
5010-
// If the string is too short to truncate, return it as is
5011-
if (str.length <= 35) {
5012-
return str;
5013-
}
5014-
const first_part = str.substring(0, 9),
5015-
last_part = str.substring(str.length - 18);
5016-
return first_part + "...." + last_part;
5017-
}
5018-
return str;
5002+
return exists(sub_title) ? truncate_middle(sub_title) : "";
50195003
}
50205004

50215005
// Creates address list item with source icons, monitoring status, and action buttons
@@ -5283,7 +5267,7 @@ function append_request(rd) {
52835267
<ul class='transactionlist'>\
52845268
<h2>" + history_text + "</h2>\
52855269
</ul>\
5286-
<div class='api_source'>" + source_html + "</div>\
5270+
<div class='api_source'>" + truncate_middle(source_html, 15, 18, 41) + "</div>\
52875271
</div>\
52885272
<div class='brstatuspanel flex'>\
52895273
<img src='" + c_icons("confirmed") + "'>\

assets_js_bitrequest_fetchblocks.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ function process_lightning_payment(rd, api_data, rdo) {
9595
"method": "POST",
9696
"cache": false,
9797
"timeout": 5000,
98-
"url": proxy_url + "proxy/v1/ln/api/",
98+
"url": proxy_url + "/proxy/v1/ln/api/",
9999
"data": {
100100
"fn": "ln-request-status",
101101
"id": payment_id,
@@ -128,7 +128,7 @@ function process_lightning_payment(rd, api_data, rdo) {
128128
"method": "POST",
129129
"cache": false,
130130
"timeout": 5000,
131-
"url": proxy_url + "proxy/v1/ln/api/",
131+
"url": proxy_url + "/proxy/v1/ln/api/",
132132
"data": {
133133
"fn": "ln-invoice-status",
134134
"imp": implementation,
@@ -252,7 +252,7 @@ function process_lightning_payment(rd, api_data, rdo) {
252252
"method": "POST",
253253
"cache": false,
254254
"timeout": 5000,
255-
"url": proxy_url + "proxy/v1/ln/api/",
255+
"url": proxy_url + "/proxy/v1/ln/api/",
256256
"data": {
257257
"fn": "ln-invoice-status",
258258
"imp": implementation,
@@ -2887,7 +2887,7 @@ function nimiq_scan_data(data, setconfirmations, latest_block, txhash) {
28872887
const raw_confs = data.confirmations || get_block_confirmations(data.height, latest_block),
28882888
block_confs = (raw_confs < 0) ? 0 : raw_confs,
28892889
tx_hash = txhash || data.hash || null,
2890-
final_confs = (confirmed) ? null : setconfirmations;
2890+
final_confs = (data.confirmed) ? null : setconfirmations;
28912891
return {
28922892
"ccval": data.value / 1e5,
28932893
"transactiontime": tx_timestamp,

assets_js_bitrequest_lightning.js

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ function node_option_li(node_info, selected, action, proxy_url, proxy_key) {
272272
"method": "POST",
273273
"cache": false,
274274
"timeout": 5000,
275-
"url": proxy_url + "proxy/v1/ln/api/",
275+
"url": proxy_url + "/proxy/v1/ln/api/",
276276
"data": {
277277
"imp": implementation,
278278
"fn": "ln-list-invoices",
@@ -452,18 +452,24 @@ function lightning_option_li(is_live, node_info, selected, invoices, proxy_url)
452452
option.slideDown(500);
453453
if (has_invoices) {
454454
invoices.reverse().forEach(function(invoice) {
455-
const invoice_id = invoice.payment_request ? " " + invoice.payment_request.slice(0, 16) :
456-
(invoice.serialized ? " " + invoice.serialized.slice(0, 16) : ""),
457-
invoice_title = invoice.memo || invoice.description || "invoice" + invoice_id,
458-
timestamp = invoice.creation_date || invoice.timestamp || false,
459-
invoice_date = timestamp ? short_date(parseInt(timestamp * 1000) + glob_const.timezone) : "",
460-
settlement_icon = invoice.settled === true || invoice.status === "paid" ? "icon-checkmark" :
461-
(invoice.settled === false || invoice.status === "expired" ? "icon-clock" : false),
462-
icon_span = settlement_icon ? "<span class='" + settlement_icon + "'></span>" : "<img src='" + implementation_icon + "' class='lnd_icon'>";
463-
invoices_list += "<div class='ivli'><div class='invoice_memo clearfix'>" +
464-
"<div class='iv_title'>" + icon_span + " " + invoice_title + "</div>" +
465-
"<div class='iv_date'>" + invoice_date + "</div></div>" +
466-
"<div class='invoice_body'><pre>" + highlight_json_syntax(invoice) + "</pre></div></div>";
455+
const invoice_description = invoice.memo || invoice.description;
456+
if (invoice_description && invoice_description.indexOf("test invoice ") === 0) {
457+
// filter out test invoices
458+
} else {
459+
const invoice_id = invoice.payment_request ? " " + invoice.payment_request.slice(0, 16) :
460+
(invoice.serialized ? " " + invoice.serialized.slice(0, 16) : ""),
461+
invoice_title = invoice_description || "invoice" + invoice_id,
462+
bolt_card = invoice_title.indexOf("Boltcard") === 0 ? " <img src='boltcard.png' class='boltcard' title='paid with the boltcard'>" : "",
463+
timestamp = invoice.creation_date || invoice.timestamp || false,
464+
invoice_date = timestamp ? short_date(parseInt(timestamp * 1000) + glob_const.timezone) : "",
465+
settlement_icon = invoice.settled === true || invoice.status === "paid" ? "icon-checkmark" :
466+
(invoice.settled === false || invoice.status === "expired" ? "icon-clock" : false),
467+
icon_span = settlement_icon ? "<span class='" + settlement_icon + "'></span>" : "<img src='" + implementation_icon + "' class='lnd_icon'>";
468+
invoices_list += "<div class='ivli'><div class='invoice_memo clearfix'>" +
469+
"<div class='iv_title' title='" + invoice_title + "'>" + icon_span + " " + truncate_middle(invoice_title) + bolt_card + "</div>" +
470+
"<div class='iv_date'>" + invoice_date + "</div></div>" +
471+
"<div class='invoice_body'><pre>" + highlight_json_syntax(invoice) + "</pre></div></div>";
472+
}
467473
});
468474
} else {
469475
const invoice_msg = is_locked ? tl("invoiceslocked", {
@@ -590,7 +596,7 @@ function add_proxy_option(option_list, key, proxy_info, selected) {
590596
"method": "POST",
591597
"cache": false,
592598
"timeout": 5000,
593-
"url": proxy_url + "proxy/v1/ln/api/",
599+
"url": proxy_url + "/proxy/v1/ln/api/",
594600
"data": {
595601
"pingpw": true,
596602
"x-api": proxy_data.k
@@ -833,7 +839,7 @@ function test_lnd_proxy(proxy_url, proxy_id, proxy_key) {
833839
"method": "POST",
834840
"cache": false,
835841
"timeout": 5000,
836-
"url": proxy_url + "proxy/v1/ln/api/",
842+
"url": proxy_url + "/proxy/v1/ln/api/",
837843
"data": {
838844
"add": true,
839845
"x-api": proxy_key
@@ -1122,7 +1128,7 @@ function test_create_invoice(implementation, proxy_data, node_host, node_key) {
11221128
"method": "POST",
11231129
"cache": false,
11241130
"timeout": 20000,
1125-
"url": proxy_url + "proxy/v1/ln/api/",
1131+
"url": proxy_url + "/proxy/v1/ln/api/",
11261132
"data": {
11271133
"imp": implementation,
11281134
"host": node_host,
@@ -1173,7 +1179,7 @@ function test_create_invoice(implementation, proxy_data, node_host, node_key) {
11731179
"api_url": node_host + "/v1/invoices",
11741180
"data": {
11751181
"value": 10000,
1176-
"memo": "test invoice LND direct",
1182+
"memo": "test invoice lnd direct",
11771183
"expiry": 180
11781184
},
11791185
"headers": {
@@ -1186,7 +1192,7 @@ function test_create_invoice(implementation, proxy_data, node_host, node_key) {
11861192
"data": {
11871193
"out": false,
11881194
"amount": 10000,
1189-
"memo": "test invoice LNbits direct",
1195+
"memo": "test invoice lnbits direct",
11901196
"expiry": 180
11911197
},
11921198
"headers": {
@@ -1343,7 +1349,7 @@ function prompt_proxy_unlock(proxy_id) {
13431349
"method": "POST",
13441350
"cache": false,
13451351
"timeout": 5000,
1346-
"url": proxy_url + "proxy/v1/ln/api/",
1352+
"url": proxy_url + "/proxy/v1/ln/api/",
13471353
"data": {
13481354
"pingpw": true,
13491355
"x-api": proxy_key_hash
@@ -1494,7 +1500,7 @@ function validate_lnurl_connection(lightning_node) {
14941500
proxy_details = lnurl_deform(lightning_node.proxy_host),
14951501
proxy_host = proxy_details.url,
14961502
proxy_key = proxy_details.k,
1497-
proxy_url = proxy_host + "proxy/v1/ln/api/";
1503+
proxy_url = proxy_host + "/proxy/v1/ln/api/";
14981504

14991505
if (!proxy_host) {
15001506
notify(tl("proxydatamissing"));

assets_js_bitrequest_monitors.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -690,11 +690,11 @@ function update_api_source(rdo, api_data) {
690690
// Updates UI with API source details and connection status indicators
691691
function display_api_source(current_list, api_data) {
692692
const api_url = api_data.url,
693-
api_url_short = truncate(api_url),
693+
api_url_short = truncate_middle(api_url),
694694
provider_name = api_data.name,
695695
api_title = provider_name === "mempool.space" ? api_url : provider_name === "electrum" ? get_string_before_last_colon(api_url_short) : provider_name,
696696
api_source = api_title || api_url_short;
697-
current_list.data("source", api_source).find(".api_source").html("<span class='src_txt' title='" + api_url + "'>" + tl("source") + ": " + api_source + "</span><span class='icon-wifi-off'></span><span class='icon-connection'></span>");
697+
current_list.data("source", api_source).find(".api_source").html("<span class='src_txt' title='" + api_url + "'>" + tl("source") + ": " + truncate_middle(api_source, 15, 18, 41) + "</span><span class='icon-wifi-off'></span><span class='icon-connection'></span>");
698698
}
699699

700700
// ** Transaction Processing: **

assets_js_bitrequest_payments.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ function lnd_put(proxy_url, proxy_key, payload, is_lnurl) {
918918
"method": "POST",
919919
"cache": false,
920920
"timeout": 5000,
921-
"url": proxy_url + "proxy/v1/ln/api/",
921+
"url": proxy_url + "/proxy/v1/ln/api/",
922922
"data": {
923923
"fn": "put",
924924
"pl": payload,
@@ -1696,7 +1696,7 @@ function set_lightning_qr(a, title) {
16961696
rt = srt || request.requesttitle,
16971697
m = rt && rt.length > 1 ? "&m=" + encodeURIComponent(rt) : "",
16981698
nid = ln.lnurl === false ? ln.nid : "",
1699-
url = glob_let.lnd_ph + "proxy/v1/ln/?i=" + ln.imp + "&id=" + request.typecode + ln.pid + nid + "&a=" + (a * 100000000000).toFixed(0) + m,
1699+
url = glob_let.lnd_ph + "/proxy/v1/ln/?i=" + ln.imp + "&id=" + request.typecode + ln.pid + nid + "&a=" + (a * 100000000000).toFixed(0) + m,
17001700
lnurl = lnurl_encode("lnurl", url).toUpperCase();
17011701
$("#qrcode_lnd").html("").qrcode(lnurl);
17021702
set_lightning_uris(lnurl, a);
@@ -2725,7 +2725,7 @@ function custom_shorten(service, shared_url, shared_title, site_thumb, url_hash)
27252725
"method": "POST",
27262726
"cache": false,
27272727
"timeout": 5000,
2728-
"url": server + "proxy/v1/inv/api/",
2728+
"url": server + "/proxy/v1/inv/api/",
27292729
"data": payload
27302730
}).done(function(response) {
27312731
const data = br_result(response).result;
@@ -2741,7 +2741,7 @@ function custom_shorten(service, shared_url, shared_title, site_thumb, url_hash)
27412741
is_default_server = objectkey_in_array(glob_const.proxy_list, "proxy", server),
27422742
short_url = is_default_server ?
27432743
glob_const.approot + "?i=" + server_index.toString() + request_id :
2744-
server + "proxy/v1/inv/4bR" + request_id;
2744+
server + "/proxy/v1/inv/4bR" + request_id;
27452745
share_request(short_url, shared_title);
27462746
if (url_hash) {
27472747
br_set_session("custom_shorturl_" + url_hash, short_url);

assets_js_bitrequest_polling.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -374,9 +374,9 @@ function validate_confirmations(tx_data, direct, ln) {
374374
status_panel.find("span.receivedfiat").text(" (" + received_amount + " " + current_currency + ")");
375375

376376
const exact_match = helper.exact,
377-
monero_valid = crypto_symbol === "xmr" ? (received_formatted > (crypto_amount * 0.97) && received_formatted < (crypto_amount * 1.03)) : true; // error margin for xmr integrated addresses
377+
is_valid = crypto_symbol === "xmr" ? (received_formatted > (crypto_amount * 0.97) && received_formatted < (crypto_amount * 1.03)) : true; // error margin for xmr integrated addresses
378378

379-
if (monero_valid) {
379+
if (is_valid) {
380380
const amount_valid = exact_match ? received_formatted === crypto_amount : received_formatted >= (crypto_amount * 0.97);
381381
if (amount_valid) {
382382
if (tx_confirms >= required_confirms || is_instant === true) {
@@ -395,15 +395,15 @@ function validate_confirmations(tx_data, direct, ln) {
395395
closenotify();
396396
new_status = insufficient_status;
397397
} else {
398-
if (!ln) {
399-
play_audio(glob_const.blip);
398+
if (ln && request.status === "pending") {} else {
399+
//play_audio(glob_const.blip);
400+
payment_dialog.addClass("transacting").attr("data-status", "pending");
401+
const broadcast_msg = ln ? tl("waitingforpayment") : tl("txbroadcasted");
402+
status_header.text(broadcast_msg);
403+
request.status = "pending",
404+
request.pending = "polling";
405+
save_payment_request(direct, ln);
400406
}
401-
payment_dialog.addClass("transacting").attr("data-status", "pending");
402-
const broadcast_msg = ln ? tl("waitingforpayment") : tl("txbroadcasted");
403-
status_header.text(broadcast_msg);
404-
request.status = "pending",
405-
request.pending = "polling";
406-
save_payment_request(direct, ln);
407407
}
408408
status_panel.find("#view_tx").attr("data-txhash", tx_hash);
409409
return new_status;

assets_js_bitrequest_rpcs.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function edit_rpcnode() {
6565
current_node = item_data.selected,
6666
node_name = current_node.name,
6767
node_url = current_node.url,
68-
url_trunc = truncate(node_url),
68+
url_trunc = truncate_middle(node_url),
6969
node_title = (node_name === "electrum" || node_name === "mempool.space") ? url_trunc : node_name || url_trunc,
7070
dialog_html = "\
7171
<div class='formbox' id='settingsbox' data-id='" + glob_let.ap_id + "'>\
@@ -559,7 +559,7 @@ function submit_rpcnode() {
559559
}
560560
loader(true);
561561
set_loader_text(tl("connecttolnur", {
562-
"url": truncate(node_url)
562+
"url": truncate_middle(node_url)
563563
}));
564564
const node_config = {
565565
"url": node_url,

assets_js_bitrequest_settings.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2685,7 +2685,7 @@ function test_append_proxy(options, key, value, selected, dfault) {
26852685
"method": "POST",
26862686
"cache": false,
26872687
"timeout": 5000,
2688-
"url": value + "proxy/v1/ln/api/",
2688+
"url": value + "/proxy/v1/ln/api/",
26892689
"data": {
26902690
"ping": true
26912691
}
@@ -2771,7 +2771,7 @@ function test_custom_proxy(value) {
27712771
"method": "POST",
27722772
"cache": false,
27732773
"timeout": 5000,
2774-
"url": url + "proxy/v1/",
2774+
"url": url + "/proxy/v1/",
27752775
"data": {
27762776
"custom": "add",
27772777
"api_url": "x" // dummy value, don't remove

0 commit comments

Comments
 (0)