Skip to content

Commit 298c28b

Browse files
committed
prevent deriving new btc address for lightning request
1 parent 72e7501 commit 298c28b

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

assets_js_bitrequest_bip39.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,6 @@ $(document).ready(function() {
8686
//finish_seed
8787
//seed_callback
8888
//deactivate_xpubs
89-
90-
// Test triggers
91-
//derive_addone_trigger();
9289
//derive_addone
9390
//get_latest_index
9491
//key_cc
@@ -1091,13 +1088,6 @@ function get_latest_index(alist) {
10911088
return Math.max.apply(Math, index);
10921089
}
10931090

1094-
// Sets up event listener for adding a new address
1095-
function derive_addone_trigger() {
1096-
$(document).on("click", ".addonexx", function() {
1097-
derive_addone($(this).attr("data-currency"), true);
1098-
})
1099-
}
1100-
11011091
// Derives and adds a new address for a given currency
11021092
function derive_addone(currency, extra) {
11031093
const dd = derive_data(currency, extra);
@@ -1282,7 +1272,15 @@ function derive_obj(source, keycc, coindat, bip32, add) {
12821272

12831273
// Checks if there's a pending request for the given address data
12841274
function ch_pending(dat) {
1285-
return $("#requestlist li[data-address='" + dat.address + "'][data-pending='scanning'][data-cmcid='" + dat.cmcid + "']").length > 0;
1275+
const rqli = $("#requestlist li.rqli[data-address='" + dat.address + "'][data-pending='scanning'][data-cmcid='" + dat.cmcid + "']");
1276+
if (rqli.length) {
1277+
const ln_dat = rqli.data("lightning");
1278+
if (ln_dat && ln_dat.hybrid === false) {
1279+
return false;
1280+
}
1281+
return true;
1282+
}
1283+
return false;
12861284
}
12871285

12881286
// Counts the number of unique elements in an array

assets_js_bitrequest_payments.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2369,7 +2369,7 @@ function sharebutton() {
23692369
$(document).on("click", "#sharebutton", function() {
23702370
const thisbttn = $(this);
23712371
if (request.payment === "bitcoin" && helper.lnd_status) {
2372-
const lnd_only = glob_paymentdialogbox.attr("data-lswitch") === "lnd_ao" ? $("#fallback_address").is(":visible") ? !$("#fallback_address .switchpanel").hasClass("true") : true : false;
2372+
const lnd_only = is_ln_only();
23732373
validaterequestdata(lnd_only);
23742374
setTimeout(function() { // wait for url to change
23752375
share(thisbttn);
@@ -2841,7 +2841,8 @@ function saverequest(direct) {
28412841
requesttimestamp = thispaymenttimestamp || (dataobject && dataobject.ts) || (thisrequesttype === "incoming" ? null : timestamp), // null is unknown timestamp
28422842
unhashed = thispayment + thiscurrency + amount_string + thisaddress + request.requestname + request.requesttitle + sc_string + ln_id,
28432843
savedtxhash = request.txhash,
2844-
requestid = thisrequesttype === "local" && savedtxhash ? hashcode(savedtxhash) : hashcode(unhashed),
2844+
is_local = thisrequesttype === "local",
2845+
requestid = is_local && savedtxhash ? hashcode(savedtxhash) : hashcode(unhashed),
28452846
requestcache = br_get_local("requests", true),
28462847
requestid_param = gets.requestid,
28472848
checkout = direct !== "init" && thisrequesttype === "checkout",
@@ -2960,13 +2961,13 @@ function saverequest(direct) {
29602961
if (coinsettings) {
29612962
const reuse = coinsettings["Reuse address"];
29622963
if (reuse) {
2963-
const addressli = filter_addressli(thispayment, "address", thisaddress);
2964-
addressli.addClass("used").data("used", true);
29652964
if (reuse.selected === false) {
29662965
// Derive new address
2967-
if (hybrid === false) {
2966+
if (hybrid === false || is_ln_only()) {
29682967
// Do nothing
29692968
} else {
2969+
const addressli = filter_addressli(thispayment, "address", thisaddress);
2970+
addressli.addClass("used").data("used", true);
29702971
saveaddresses(thispayment, false);
29712972
derive_addone(thispayment);
29722973
}

assets_js_br_query.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
//tofixedspecial
2424
//get_search
2525
//renderlnconnect
26+
//is_ln_only
2627
//cleanb64
2728
//b64urldecode
2829
//geturlparameters
@@ -334,6 +335,11 @@ function renderlnconnect(str) {
334335
return search;
335336
}
336337

338+
// Checks if request is hybrid or lightning only
339+
function is_ln_only() {
340+
return glob_paymentdialogbox.attr("data-lswitch") === "lnd_ao" ? $("#fallback_address").is(":visible") ? !$("#fallback_address .switchpanel").hasClass("true") : true : false;
341+
}
342+
337343
// Cleans base64 encoded string for URL use
338344
function cleanb64(str) {
339345
return str.replace(/\+/g, "-").replace(/\//g, "_");

0 commit comments

Comments
 (0)