Skip to content

Commit c80e122

Browse files
committed
tx monitoring
1 parent 75b951e commit c80e122

File tree

4 files changed

+65
-62
lines changed

4 files changed

+65
-62
lines changed

assets_js_bitrequest_core.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4093,18 +4093,19 @@ function add_historical_data(transaction_list, tx_history) {
40934093
function animate_confbar(conf_bar, delay_index) {
40944094
conf_bar.css("transform", "translate(-100%)");
40954095
const tx_data = conf_bar.closest("li").data(),
4096-
confirm_ratio = (tx_data.confirmations / tx_data.setconfirmations) * 100,
4096+
confirmations = tx_data.confirmations;
4097+
if (!confirmations) return
4098+
const confirm_ratio = (confirmations / tx_data.setconfirmations) * 100,
40974099
capped_percent = (confirm_ratio > 100) ? 100 : confirm_ratio,
40984100
final_position = (capped_percent - 100).toFixed(2);
40994101
setTimeout(function() {
4100-
conf_bar.css("transform", "tl(" + final_position + "%)");
4101-
}, delay_index * 500);
4102+
conf_bar.css("transform", "translate(" + final_position + "%)");
4103+
}, delay_index * 250);
41024104
}
41034105

41044106
// Shows transaction metadata on double click for touch devices
41054107
function show_transaction_meta() {
41064108
$(document).on("dblclick", ".requestlist li .transactionlist li", function() {
4107-
if (!glob_const.supportsTouch) return
41084109
const tx_item = $(this),
41094110
tx_meta = tx_item.children(".historic_meta");
41104111
if (tx_meta.is(":visible")) {

assets_js_bitrequest_monitors.js

Lines changed: 51 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -781,11 +781,11 @@ function validate_payment_amounts(rd, rdo) {
781781
if (first_transaction_time) {
782782
const is_crypto = rd.iscrypto,
783783
pending_status = rd.pending,
784-
required_confirmations = rd.set_confirmations,
785-
confirmation_interval = required_confirmations === false ? 0 : (required_confirmations ? parseInt(required_confirmations) : 1),
786-
minimum_confirmations = rd.lightning ? 1 : confirmation_interval, // set minimum confirmations to 1
784+
set_confirmations = rd.set_confirmations || 1, // set minimum confirmations to 1
787785
first_transaction = transaction_items.first(),
788786
first_confirmations = first_transaction.data("confirmations"),
787+
no_conf = rd.no_conf || first_confirmations === false,
788+
conf = no_conf ? 0 : first_confirmations,
789789
latest_transaction_time = first_transaction.data("transactiontime"),
790790
time_offset = Math.abs(now() - (first_transaction_time - glob_const.timezone)),
791791
single_transaction = transaction_count === 1,
@@ -808,27 +808,27 @@ function validate_payment_amounts(rd, rdo) {
808808
transaction_counter++;
809809
const current_transaction = $(this),
810810
transaction_data = current_transaction.data(),
811-
correction_confirmations = transaction_data.instant_lock ? 0 : minimum_confirmations; // correction if dash instant_lock
811+
correction_confirmations = transaction_data.instant_lock ? 0 : set_confirmations; // correction if dash instant_lock
812812
crypto_confirmations = transaction_data.confirmations,
813813
crypto_payment_timestamp = transaction_data.transactiontime,
814814
crypto_transaction_hash = transaction_data.txhash,
815815
total_crypto_amount += parseFloat(transaction_data.ccval) || 0; // sum of outputs
816-
if (crypto_confirmations >= correction_confirmations || rd.no_conf || transaction_data.setconfirmations === false) { // check all confirmations + whitelist for currencies unable to fetch confirmations
816+
if (crypto_confirmations >= correction_confirmations || no_conf || transaction_data.setconfirmations === false) { // check all confirmations + whitelist for currencies unable to fetch confirmations
817817
is_crypto_confirmed = true;
818818
if (total_crypto_amount >= crypto_amount * amount_margin) { // compensation for small fluctuations in rounding amount
819819
current_transaction.addClass("exceed").nextAll().addClass("exceed");
820-
return
820+
return false;
821821
}
822822
} else {
823823
is_crypto_confirmed = false;
824824
}
825-
const confirmation_bar = current_transaction.find(".confbar");
826-
if (confirmation_bar.length > 0) {
827-
confirmation_bar.each(function(bar_index) {
828-
animate_confbar($(this), bar_index);
829-
});
830-
};
831825
});
826+
const conf_bar = transaction_items.find(".confbar");
827+
if (conf_bar.length) {
828+
conf_bar.each(function(i) {
829+
animate_confbar($(this), i);
830+
});
831+
};
832832
if (total_crypto_amount >= crypto_amount * amount_margin) { // compensation for small fluctuations in rounding amount
833833
if (is_crypto_confirmed === false) { // check confirmations outside the loop
834834
crypto_status = "pending",
@@ -860,7 +860,7 @@ function validate_payment_amounts(rd, rdo) {
860860
}
861861
}
862862
} else {
863-
init_fiat_history(rd, rdo, first_confirmations, latest_transaction_time, first_transaction_time);
863+
init_fiat_history(rd, rdo, conf, latest_transaction_time, first_transaction_time);
864864
return
865865
}
866866
}
@@ -879,7 +879,7 @@ function validate_payment_amounts(rd, rdo) {
879879
finalize_request_state(rdo);
880880
return
881881
}
882-
init_fiat_history(rd, rdo, first_confirmations, latest_transaction_time, first_transaction_time);
882+
init_fiat_history(rd, rdo, conf, latest_transaction_time, first_transaction_time);
883883
return
884884
}
885885
}
@@ -904,19 +904,20 @@ function update_transaction_count(status_panel, count) {
904904
// ** Historical Data Processing: **
905905

906906
// Triggers historical fiat data retrieval for transactions based on confirmation status
907-
function init_fiat_history(rd, rdo, conf, latestinput, firstinput) {
908-
const confirm_level = conf || 0,
909-
no_confirm = rd.no_conf || conf === false,
910-
latest_confirm = no_confirm ? 0 : confirm_level, // only update on change
907+
function init_fiat_history(rd, rdo, latestconf, latest_input, firstinput) {
908+
const cache_value = latest_input + latestconf.toString(), // only update on change
911909
cache_prefix = "historic_" + rd.requestid,
912-
historic_cache = br_get_session(cache_prefix),
913-
cache_value = parseInt(latestinput) + parseInt(latest_confirm);
914-
if ((latest_confirm || no_confirm) && cache_value > historic_cache) { //new input detected; call historic api
910+
cache_timestamp = br_get_session(cache_prefix), // set to small amount to trigger lookup exchange rates
911+
cache_session = cache_timestamp || 1,
912+
latest_input_slice = cache_timestamp ? cache_session.slice(0, 13) : latest_input,
913+
latestinput = parseInt(latest_input_slice),
914+
historic_cache = parseInt(cache_session);
915+
if (cache_value > historic_cache) { //new input detected; call historic api
915916
br_remove_session(cache_prefix); // remove historic price cache
916917
const historic_payload = $.extend(rd, {
917-
"latestinput": latestinput,
918-
"latestconf": latest_confirm,
919-
"firstinput": firstinput
918+
latestinput,
919+
latestconf,
920+
firstinput
920921
}),
921922
api_list = "historic_fiat_price_apis",
922923
fiat_api = $("#fiatapisettings").data("selected"),
@@ -1052,8 +1053,8 @@ function fetch_crypto_rates(rd, rdo, fiat_api, api_list, api, currency_rate, usd
10521053
coin_id = api === "coincodex" ? crypto_symbol : // coincodex id
10531054
api === "coingecko" ? payment_method : // coingecko id
10541055
crypto_symbol + "-" + payment_method, // coinpaprika id
1055-
start_time_sec = (first_input - glob_const.timezone) / 1000,
1056-
end_time_sec = (latest_input - glob_const.timezone) / 1000,
1056+
start_time_sec = parseInt((first_input - glob_const.timezone) / 1000),
1057+
end_time_sec = parseInt((latest_input - glob_const.timezone) / 1000),
10571058
erc20_contract = rd.token_contract,
10581059
history_api = api,
10591060
search = history_api === "coincodex" ? get_payload_historic_coincodex(coin_id, start_time_sec, end_time_sec) :
@@ -1080,18 +1081,15 @@ function fetch_crypto_rates(rd, rdo, fiat_api, api_list, api, currency_rate, usd
10801081
tx_reverse = tx_list_length > 1 ? tx_list.get().reverse() : tx_list,
10811082
latest_confirm = rd.latestconf,
10821083
total_amount = rd.amount,
1083-
get_confirmations = rd.set_confirmations,
1084-
confirm_interval = get_confirmations === false ? 0 : (get_confirmations ? parseInt(get_confirmations) : 1),
1085-
is_lightning = rd.lightning,
1086-
set_confirmations = is_lightning ? 1 : confirm_interval, // set minimum confirmations to 1
1087-
is_erc20 = rd.erc20,
1084+
set_confirmations = rd.set_confirmations || 1; // Default to 1
1085+
is_erc20 = rd.erc20,
10881086
historic_usd_value = (total_amount / currency_rate) * usd_rate,
10891087
margin = historic_usd_value < 2 ? 0.60 : 0.95; // be flexible with small amounts
10901088
let tx_counter = 0,
10911089
confirmations = 0,
1092-
payment_timestamp,
1093-
tx_hash,
1094-
received_crypto = 0,
1090+
paymenttimestamp,
1091+
txhash,
1092+
receivedamount = 0,
10951093
received_usd = 0,
10961094
confirmed = false,
10971095
status = "pending",
@@ -1115,9 +1113,9 @@ function fetch_crypto_rates(rd, rdo, fiat_api, api_list, api, currency_rate, usd
11151113
conf_correct = node_data.instant_lock ? 0 : set_confirmations; // correction if dash instant_lock
11161114
current_node.data("historic", historic_object);
11171115
confirmations = node_data.confirmations, // check confirmations
1118-
payment_timestamp = transaction_timestamp,
1119-
tx_hash = node_data.txhash,
1120-
received_crypto += parseFloat(transaction_value) || 0; // sum of outputs CC
1116+
paymenttimestamp = transaction_timestamp,
1117+
txhash = node_data.txhash,
1118+
receivedamount += parseFloat(transaction_value) || 0; // sum of outputs CC
11211119
if ((historic_price && confirmations >= conf_correct) || rd.no_conf === true || node_data.setconfirmations === false) { // check all confirmations + whitelist for currencies unable to fetch confirmations
11221120
confirmed = true;
11231121
} else {
@@ -1126,19 +1124,20 @@ function fetch_crypto_rates(rd, rdo, fiat_api, api_list, api, currency_rate, usd
11261124
let current_usd_sum = received_usd += parseFloat(historic_price * transaction_value) || 0;
11271125
if (current_usd_sum >= historic_usd_value * margin) { //minus 5% dollar for volatility compensation
11281126
current_node.addClass("exceed").nextAll().addClass("exceed");
1127+
return false;
11291128
}
1130-
const conf_bar = current_node.find(".confbar");
1131-
if (conf_bar.length > 0) {
1132-
conf_bar.each(function(i) {
1133-
animate_confbar($(this), i);
1134-
});
1135-
};
11361129
});
1130+
const conf_bar = tx_list.find(".confbar");
1131+
if (conf_bar.length) {
1132+
conf_bar.each(function(i) {
1133+
animate_confbar($(this), i);
1134+
});
1135+
};
11371136
if (received_usd) {
11381137
if (received_usd >= historic_usd_value * margin) { // check total incoming amount // minus 5% dollar for volatility compensation
11391138
if (confirmed === false) { // check confirmations outside the loop
11401139
status = "pending",
1141-
pending = tx_counter === 1 && tx_hash ? "polling" : pending; // switch to tx polling if there's only one transaction and txhash is known
1140+
pending = tx_counter === 1 && txhash ? "polling" : pending; // switch to tx polling if there's only one transaction and txhash is known
11421141
} else {
11431142
status = "paid",
11441143
pending = "no";
@@ -1149,17 +1148,17 @@ function fetch_crypto_rates(rd, rdo, fiat_api, api_list, api, currency_rate, usd
11491148
}
11501149
update_request({
11511150
"requestid": rd.requestid,
1152-
"status": status,
1153-
"receivedamount": received_crypto,
1151+
status,
1152+
receivedamount,
11541153
"fiatvalue": (received_usd / usd_rate) * currency_rate,
1155-
"paymenttimestamp": payment_timestamp,
1156-
"txhash": tx_hash,
1157-
"confirmations": confirmations,
1158-
"pending": pending,
1159-
"lightning": is_lightning
1154+
paymenttimestamp,
1155+
txhash,
1156+
confirmations,
1157+
pending,
1158+
"lightning": rd.lightning
11601159
}, false);
11611160
if (pending !== "no") {
1162-
const cache_value = parseInt(latest_input) + parseInt(latest_confirm);
1161+
const cache_value = latest_input + latest_confirm.toString();
11631162
br_set_session("historic_" + rd.requestid, cache_value); // 'cache' historic data
11641163
}
11651164
finalize_request_state(rdo);

assets_js_bitrequest_payments.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -688,10 +688,9 @@ function continue_request() {
688688
request_name = decoded_data && decoded_data.n ? decoded_data.n : null,
689689
request_title = decoded_data && decoded_data.t ? decoded_data.t : null,
690690
eth_layer2_networks = decoded_data && decoded_data.l2 ? decoded_data.l2 : [],
691-
current_confirmations = q_obj(coin_settings, "confirmations"),
692-
no_confirmations = !current_confirmations || !is_monitored,
691+
current_confirmations = q_obj(coin_settings, "confirmations.selected"),
693692
data_obj_confirmations = q_obj(decoded_data, "c"),
694-
set_confirmations = parseFloat(data_obj_confirmations) || no_confirmations ? 0 : current_confirmations.selected || 0,
693+
set_confirmations = parseFloat(data_obj_confirmations) || current_confirmations,
695694
is_instant = !set_confirmations,
696695
page_name_currency_param = is_crypto_account ? "" : payment_currency + " ",
697696
page_name = request_name ? tl("sharetitlename", {
@@ -740,7 +739,7 @@ function continue_request() {
740739
"requesttitle": request_title,
741740
"eth_l2s": eth_layer2_networks,
742741
set_confirmations,
743-
"no_conf": no_confirmations,
742+
"no_conf": !is_monitored,
744743
"instant": is_instant,
745744
"shared": is_request && request_timestamp !== null, // check if request is from a shared source,
746745
"iszero": is_zero_amount,

assets_styles_styles.css

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,12 +1240,12 @@ html.dragmode .currentpage .applist li.dragging {
12401240

12411241
.requestlist li[data-status="new"] .metalist li.receivedamount,
12421242
.requestlist li[data-status="new"] .metalist li.payday {
1243-
display: none;
1243+
display: block;
12441244
}
12451245

12461246
.requestlist li.rqli.lightning .metalist li.receivedamount,
12471247
.requestlist li.rqli.lightning .metalist li.payday {
1248-
display: none;
1248+
display: block;
12491249
}
12501250

12511251
.requestlist li.rqli.lightning[data-status="paid"] .metalist li.receivedamount,
@@ -1528,6 +1528,10 @@ html.dragmode .currentpage .applist li.dragging {
15281528
display: inline;
15291529
}
15301530

1531+
.transactionlist li .txli_content .icon-checkmark {
1532+
display: inline!important;
1533+
}
1534+
15311535
.requestlist li[data-pending="unknown"] .icon-eye-blocked {
15321536
display: inline;
15331537
}

0 commit comments

Comments
 (0)