Skip to content

Commit 3664e66

Browse files
committed
xmr scanning
1 parent a684201 commit 3664e66

9 files changed

+74
-94
lines changed

assets_js_bitrequest_core.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ $(document).ready(function() {
5858
selectbox();
5959
pickselect();
6060
canceldialogtrigger();
61-
console.log({glob_config});
61+
console.log({
62+
glob_config
63+
});
6264
})
6365

6466
// Check for PHP support by fetching fiat currencies from local API PHP file
@@ -528,7 +530,9 @@ function finishfunctions() {
528530

529531
setTimeout(function() { // wait for ios app detection
530532
detectapp();
531-
console.log({glob_const});
533+
console.log({
534+
glob_const
535+
});
532536
}, 700);
533537
//getapp
534538
close_app_panel();
@@ -3280,7 +3284,7 @@ function show_vk() {
32803284
function show_vk_cb(kd) {
32813285
const svk_string = kd.svk ? "<br/><strong style='color:#8d8d8d'>" + translate("secretviewkey") + "</strong> <span class='adbox adboxl select' data-type='Viewkey'>" + kd.svk + "</span><br/>" : "",
32823286
ssk_string = kd.ssk ? "<br/><strong style='color:#8d8d8d'>" + translate("secretspendkey") + "</strong> <span class='adbox adboxl select' data-type='Spendkey'>" + kd.ssk + "</span>" : ""
3283-
3287+
32843288
$("#show_vk").text(translate("hide"));
32853289
$("#pk_span").html(svk_string + ssk_string).addClass("shwpk").slideDown(200);
32863290
}

assets_js_bitrequest_fetchblocks.js

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -364,31 +364,17 @@ function monero_fetch(rd, api_data, rdo) {
364364
const txd = xmr_scan_data(value, rdo.setconfirmations, "xmr", data.blockchain_height);
365365
if (txd) {
366366
const xid_match = match_xmr_pid(xmr_ia, payment_id, txd.payment_id); // match xmr payment_id if set
367-
if (xid_match === true) {
368-
if (rdo.pending === "polling") {
369-
if (txd.txhash === rd.txhash && txd.ccval) {
370-
txdat = txd;
371-
if (source === "list") {
372-
const tx_listitem = append_tx_li(txd, rd.requesttype);
373-
if (tx_listitem) {
374-
transactionlist.append(tx_listitem.data(txd));
375-
counter++;
376-
}
377-
}
378-
return false;
379-
}
380-
} else if (rdo.pending === "scanning") {
381-
if (txd.transactiontime > rdo.request_timestamp && txd.ccval) {
382-
txdat = txd;
383-
if (source === "list") {
384-
const tx_listitem = append_tx_li(txd, rd.requesttype);
385-
if (tx_listitem) {
386-
transactionlist.append(tx_listitem.data(txd));
387-
counter++;
388-
}
367+
if (xid_match) {
368+
if (txd.ccval && txd.transactiontime > rdo.request_timestamp) {
369+
txdat = txd;
370+
if (source === "list") {
371+
const tx_listitem = append_tx_li(txd, rd.requesttype);
372+
if (tx_listitem) {
373+
transactionlist.append(tx_listitem.data(txd));
374+
counter++;
389375
}
390-
return false;
391376
}
377+
return false;
392378
}
393379
}
394380
}

assets_js_bitrequest_lang_en.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ function lang_en(id, data) {
479479
"cardmax": "Request exceeds card's maximum",
480480
"minamount": "Minimum request amount is " + data.min,
481481
"waitingforpayment": "Waiting for payment",
482-
"websocketoffline": "websocket offline",
482+
"websocketoffline": "node offline",
483483

484484
// PIN PANEL
485485
"pleaseenter": "Please enter your pin",

assets_js_bitrequest_lang_fr.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ function lang_fr(id, data) {
479479
"cardmax": "La demande dépasse le maximum de la carte",
480480
"minamount": "Le montant minimum de la demande est de " + data.min,
481481
"waitingforpayment": "En attente de paiement",
482-
"websocketoffline": "websocket hors ligne",
482+
"websocketoffline": "node hors ligne",
483483

484484
// PIN PANEL
485485
"pleaseenter": "Veuillez entrer votre code PIN",

assets_js_bitrequest_lang_nl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ function lang_nl(id, data) {
479479
"cardmax": "Bedrag is hoger dan de Boltcard limiet",
480480
"minamount": "Minimumale verzoek bedrag is " + data.min,
481481
"waitingforpayment": "In afwachting van betaling",
482-
"websocketoffline": "websocket offline",
482+
"websocketoffline": "node offline",
483483

484484
// PIN PANEL
485485
"pleaseenter": "Toets uw pincode in",

assets_js_bitrequest_payments.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,14 @@ function wake_panel() {
130130
// Sets a timer to close the request dialog after 3 minutes
131131
function set_request_timer() {
132132
// close request dialog after 3 minutes
133+
if (!glob_const.paymentpopup.hasClass("live")) return;
133134
clearTimeout(glob_let.request_timer);
134-
glob_const.paymentdialogbox.removeClass("timer");
135135
glob_let.request_timer = setTimeout(function() {
136136
cpd_pollcheck();
137137
}, 180000, function() {
138138
clearTimeout(glob_let.request_timer);
139139
});
140+
glob_const.paymentdialogbox.removeClass("timer");
140141
setTimeout(function() {
141142
glob_const.paymentdialogbox.addClass("timer");
142143
}, 500);

assets_js_bitrequest_polling.js

Lines changed: 33 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ function address_polling_init(time_out, api_dat, retry) {
112112
}
113113
socket_info({
114114
"url": api_data.name
115-
}, true);
115+
}, true, true);
116116
glob_let.pinging[ping_id] = setInterval(function() {
117117
address_polling(timeout, api_data);
118118
}, timeout);
@@ -139,21 +139,21 @@ function address_polling(timeout, api_data) {
139139
};
140140
continue_select(request, api_data, rdo);
141141
poll_animate();
142-
socket_info(api_data, true);
142+
socket_info(api_data, true, true);
143143
}
144144

145145
// Polling
146146

147147
// XMR Poll
148148

149149
// Initializes Monero node connection
150-
function init_xmr_node(cachetime, address, vk, request_ts) {
150+
function init_xmr_node(cachetime, address, vk) {
151151
const payload = {
152152
"address": address,
153153
"view_key": vk,
154154
"create_account": true,
155155
"generated_locally": false
156-
};
156+
}
157157
api_proxy({
158158
"api": "mymonero api",
159159
"search": "login",
@@ -178,9 +178,12 @@ function init_xmr_node(cachetime, address, vk, request_ts) {
178178
}
179179
const start_height = data.start_height;
180180
if (start_height > -1) { // success!
181+
const rq_init = request.rq_init,
182+
request_ts_utc = rq_init + glob_const.timezone,
183+
request_ts = request_ts_utc - 30000; // 30 second compensation
181184
socket_info({
182185
"url": "mymonero api"
183-
}, true);
186+
}, true, true);
184187
glob_let.pinging[address] = setInterval(function() {
185188
poll_animate();
186189
ping_xmr_node(cachetime, address, vk, request_ts);
@@ -191,15 +194,15 @@ function init_xmr_node(cachetime, address, vk, request_ts) {
191194
notify(translate("notmonitored"), 500000, "yes");
192195
}).fail(function(xhr, stat, err) {
193196
if (get_next_proxy()) {
194-
init_xmr_node(cachetime, address, vk, request_ts);
197+
init_xmr_node(cachetime, address, vk);
195198
return
196199
}
197200
notify(translate("errorvk"));
198201
});
199202
}
200203

201204
// Pings Monero node for transaction updates
202-
function ping_xmr_node(cachetime, address, vk, request_ts, txhash) {
205+
function ping_xmr_node(cachetime, address, vk, request_ts) {
203206
if (!isopenrequest()) { // only when request is visible
204207
forceclosesocket();
205208
return;
@@ -223,49 +226,39 @@ function ping_xmr_node(cachetime, address, vk, request_ts, txhash) {
223226
}
224227
}
225228
}).done(function(e) {
226-
const data = br_result(e).result,
227-
transactions = data.transactions;
229+
const data = br_result(e).result;
230+
if (data.Error) {
231+
socket_info({
232+
"url": api_name
233+
}, false, true);
234+
clearpinging(address);
235+
return
236+
}
237+
const transactions = data.transactions;
228238
if (!transactions) return;
229239
socket_info({
230240
"url": api_name
231-
}, true);
241+
}, true, true);
232242
const set_confirmations = q_obj(request, "set_confirmations") || 0,
233-
txflip = transactions.reverse();
234-
$.each(txflip, function(dat, value) {
243+
txflip = transactions.reverse(),
244+
txflip_strip = txflip.slice(0, 25); // get last 25 transactions
245+
$.each(txflip_strip, function(dat, value) {
235246
const txd = xmr_scan_data(value, set_confirmations, "xmr", data.blockchain_height);
236-
if (txd) {
237-
if (txd.ccval) {
238-
const tx_hash = txd.txhash;
239-
if (tx_hash) {
240-
if (txhash) {
241-
if (txhash === tx_hash) {
242-
confirmations(txd);
243-
}
244-
return
245-
}
246-
if (txd.transactiontime > request_ts) {
247-
const requestlist = $("#requestlist > li.rqli"),
248-
txid_match = filter_list(requestlist, "txhash", tx_hash); // check if txhash already exists
249-
if (txid_match.length) {
250-
return
251-
}
252-
confirmations(txd, true);
253-
if (set_confirmations > 0) {
254-
clearpinging(address);
255-
tx_polling_init(txd, {
256-
"api": true,
257-
"name": "blockchair_xmr",
258-
"display": true
259-
});
260-
}
261-
}
262-
}
247+
if (txd.ccval && txd.transactiontime > request_ts) {
248+
confirmations(txd, true);
249+
if (set_confirmations > 0) {
250+
clearpinging(address);
251+
tx_polling_init(txd, {
252+
"api": true,
253+
"name": "blockchair_xmr",
254+
"display": true
255+
});
263256
}
264257
}
265258
});
266259
}).fail(function() {
267260
if (get_next_proxy()) {
268-
ping_xmr_node(cachetime, address, vk, request_ts, txhash);
261+
ping_xmr_node(cachetime, address, vk, request_ts);
269262
return
270263
}
271264
clearpinging(address);

assets_js_bitrequest_sockets.js

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ function init_socket(socket_node, address, retry) {
3535
return
3636
}
3737
glob_let.rpc_attempts = {};
38-
const payment = request.payment,
39-
rq_init = request.rq_init,
40-
request_ts_utc = rq_init + glob_const.timezone,
41-
request_ts = request_ts_utc - 30000;
38+
const payment = request.payment;
4239
let socket_name;
4340
if (socket_node) {
4441
socket_name = socket_node.name;
@@ -151,13 +148,12 @@ function init_socket(socket_node, address, retry) {
151148
if (payment === "monero") {
152149
const vk = request.viewkey || get_vk(address);
153150
if (vk) {
154-
trigger_requeststates(); // update outgoing
155151
const account = vk.account || address,
156152
viewkey = vk.vk;
157153
request.monitored = true;
158154
request.viewkey = vk;
159155
closenotify();
160-
init_xmr_node(9, account, viewkey, request_ts);
156+
init_xmr_node(9, account, viewkey);
161157
return
162158
}
163159
request.monitored = false;
@@ -1321,22 +1317,22 @@ function socket_info(snode, live, polling) {
13211317
console.log("Connected: " + snode.url);
13221318
glob_const.paymentpopup.addClass("live");
13231319
closenotify();
1324-
} else {
1325-
setTimeout(function() {
1326-
if (is_openrequest() !== true) {
1327-
return
1328-
}
1329-
if (glob_const.paymentdialogbox.hasClass("transacting")) {
1330-
return
1331-
}
1332-
if ($("#paymentaddress").hasClass("live")) {
1333-
return
1334-
}
1335-
const l2nws = glob_const.paymentpopup.find("li.nwl2.online");
1336-
if (!l2nws.length) {
1337-
glob_const.paymentpopup.removeClass("live");
1338-
notify(translate("websocketoffline"), 500000, "yes");
1339-
}
1340-
}, 1000);
1320+
return
13411321
}
1322+
setTimeout(function() {
1323+
if (!is_openrequest()) {
1324+
return
1325+
}
1326+
const l2nws = glob_const.paymentpopup.find("li.nwl2.online");
1327+
if (!l2nws.length) {
1328+
glob_const.paymentpopup.removeClass("live");
1329+
}
1330+
if (glob_const.paymentdialogbox.hasClass("transacting")) {
1331+
return
1332+
}
1333+
if ($("#paymentaddress").hasClass("live")) {
1334+
return
1335+
}
1336+
notify(translate("websocketoffline"), 500000, "yes");
1337+
}, 1000);
13421338
}

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ <h2 class="tl_page6">I would like to get paid in:</h2>
169169
</div><br />
170170
<p id="loadtext"><span>Loading</span> ...</p>
171171
</div>
172-
<div id="payment" class="popbg flex">
172+
<div id="payment" class="popbg flex live">
173173
<div id="paymentdialog" class="dialog">
174174
<div id="paymentdialogbox">
175175
</div>

0 commit comments

Comments
 (0)