') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); lightning-invoice/utils: Actually add expiry to invoices by dunxen · Pull Request #1474 · lightningdevkit/rust-lightning · GitHub
Skip to content

lightning-invoice/utils: Actually add expiry to invoices - #1474

Merged
TheBlueMatt merged 2 commits into
lightningdevkit:mainfrom
dunxen:2022-05-actually-add-expiry
May 10, 2022
Merged

lightning-invoice/utils: Actually add expiry to invoices#1474
TheBlueMatt merged 2 commits into
lightningdevkit:mainfrom
dunxen:2022-05-actually-add-expiry

Conversation

@dunxen

Copy link
Copy Markdown
Contributor

My bad.

I've also added the expiry to non-phantom invoice utilities.

This should now fix#1411

tnull
tnull previously approved these changes May 10, 2022

@tnulltnull left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tiny nit, otherwise LGTM.

Comment threadlightning-invoice/src/utils.rs Outdated
@dunxen
dunxenforce-pushed the 2022-05-actually-add-expiry branch from 983a462 to b61a7a2CompareMay 10, 2022 13:21

@jkczyzjkczyz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick turnaround! We should have caught this in review, so no worries.

Comment threadlightning-invoice/src/utils.rs
Comment threadlightning-invoice/src/utils.rs Outdated
@dunxen
dunxenforce-pushed the 2022-05-actually-add-expiry branch from b61a7a2 to ec774ffCompareMay 10, 2022 15:41
@codecov-commenter

codecov-commenter commented May 10, 2022

Copy link
Copy Markdown

Codecov Report

Merging #1474 (717047c) into main (29727a3) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head 717047c differs from pull request most recent head 3369b29. Consider uploading reports for the commit 3369b29 to get more accurate results

@@ Coverage Diff @@## main #1474 +/- ##
==========================================
- Coverage 90.94% 90.93% -0.01% 
==========================================
Files 75 75 Lines 41891 41900 +9 Branches 41891 41900 +9 ==========================================
+ Hits 38097 38102 +5 - Misses 3794 3798 +4 
Impacted FilesCoverage Δ
lightning-invoice/src/payment.rs92.75% <100.00%> (ø)
lightning-invoice/src/utils.rs96.89% <100.00%> (+0.04%)⬆️
lightning/src/ln/functional_tests.rs97.11% <0.00%> (-0.07%)⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 29727a3...3369b29. Read the comment docs.

Comment threadlightning-invoice/src/utils.rs Outdated
@dunxen
dunxenforce-pushed the 2022-05-actually-add-expiry branch from ec774ff to c962c18CompareMay 10, 2022 17:01
@TheBlueMatt

Copy link
Copy Markdown
Collaborator

Needs rebase, it appears?

@dunxen

Copy link
Copy Markdown
ContributorAuthor

Rebasing

@dunxen

Copy link
Copy Markdown
ContributorAuthor

Needs rebase, it appears?

Beat me to it. Was quite behind on my local.

@dunxen
dunxenforce-pushed the 2022-05-actually-add-expiry branch from c962c18 to 717047cCompareMay 10, 2022 17:13

@jkczyzjkczyz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good modulo some test changes.

Comment threadlightning-invoice/src/utils.rs Outdated
Comment threadlightning-invoice/src/utils.rs Outdated
@dunxen
dunxenforce-pushed the 2022-05-actually-add-expiry branch from 717047c to 3369b29CompareMay 10, 2022 18:23
Comment on lines -231 to +234
channelmanager, keys_manager, network, amt_msat, description, duration
channelmanager, keys_manager, network, amt_msat,
description, duration, invoice_expiry_delta_secs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: would just wrap at 100 chars instead of making them evenly distributed to ease future automation

let invoice = ::utils::create_phantom_invoice::<EnforcingSigner, &test_utils::TestKeysInterface>(Some(payment_amt), payment_hash, "test".to_string(), 3600, route_hints, &nodes[1].keys_manager, Currency::BitcoinTestnet).unwrap();
let invoice = ::utils::create_phantom_invoice::<
EnforcingSigner, &test_utils::TestKeysInterface
>(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: bleh, I hate these kinds of blank lines. Better to \n\t after the = or run over 100 chars than this :(

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll get to these in a follow-up today :) (also Jeff's)

@TheBlueMatt
TheBlueMatt merged commit edd3030 into lightningdevkit:mainMay 10, 2022
@dunxen
dunxen deleted the 2022-05-actually-add-expiry branch May 11, 2022 08:39
dunxen added a commit to dunxen/rust-lightning that referenced this pull request May 11, 2022
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Include expiry in invoices

5 participants

@dunxen@codecov-commenter@TheBlueMatt@tnull@jkczyz