') + ')', '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); } })(); })(); Document better optional features by mattfaltyn · Pull Request #1514 · lightningdevkit/rust-lightning · GitHub
Skip to content

Document better optional features - #1514

Merged
TheBlueMatt merged 1 commit into
lightningdevkit:mainfrom
mattfaltyn:issue438
Jun 13, 2022
Merged

Document better optional features#1514
TheBlueMatt merged 1 commit into
lightningdevkit:mainfrom
mattfaltyn:issue438

Conversation

@mattfaltyn

Copy link
Copy Markdown
Contributor

Closes#438.

Issue: Post #428 merge, would be great to document FeatureContext* setters (lightning/src/ln/msgs.rs), I don't think optional features are documented anyway in the current codebase beyond references to BOLT.

Changes: Added documentation in features.rs on what the currently-supported features do in the LDK based on BOLT-9 feature flags.

@codecov-commenter

codecov-commenter commented Jun 2, 2022

Copy link
Copy Markdown

Codecov Report

Merging #1514 (86299c5) into main (716539e) will decrease coverage by 0.01%.
The diff coverage is n/a.

@@ Coverage Diff @@## main #1514 +/- ##
==========================================
- Coverage 90.93% 90.91% -0.02% 
==========================================
Files 80 80 Lines 43469 43469 Branches 43469 43469 ==========================================
- Hits 39527 39520 -7 - Misses 3942 3949 +7 
Impacted FilesCoverage Δ
lightning/src/ln/features.rs99.46% <ø> (ø)
lightning/src/chain/mod.rs63.63% <0.00%> (-4.55%)⬇️
lightning/src/ln/functional_tests.rs96.98% <0.00%> (-0.08%)⬇️
lightning/src/chain/channelmonitor.rs91.18% <0.00%> (-0.06%)⬇️

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 716539e...86299c5. Read the comment docs.

@TheBlueMattTheBlueMatt left a comment

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.

Thanks! This already needs rebase for the ZeroConf feature lol. sorry about that.

Comment threadlightning/src/ln/features.rs Outdated
//! - `DataLossProtect` - requires/supports that a node, which has somehow fallen behind (e.g. has been restored from old backup),
//! can detect that it has fallen behind
//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md) for more information).
//! - `set_data_loss_protect_optional` - sets this feature to optional.

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.

Hmm, do we need to list the methods? In general I think users should never change them manually.

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.

Sounds good - I will remove them.

Comment threadlightning/src/ln/features.rs Outdated
//! And the implementation can interpret a feature if the feature is known to it.
//!
//! The following features are currently supported in the LDK:
//! - `DataLossProtect` - requires/supports that a node, which has somehow fallen behind (e.g. has been restored from old backup),

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.

We should mention somewhere what we require vs support. I think currently we may only require StaticRemoteKey, but in the near future we'll probably require VariableLengthOnion too.

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 will make two lists: one for required features (StaticRemoteKey and VariableLengthOnion) and one for supported features (everything else).

TheBlueMatt
TheBlueMatt previously approved these changes Jun 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.

Thanks for having a look! Just a few suggestions/nits/remarks.

Comment threadlightning/src/ln/features.rs Outdated
//! (see [BOLT-3](https://github.com/lightning/bolts/blob/master/03-transactions.md) for more information).
//!
//! The following features are currently supported in the LDK:
//! - `DataLossProtect` - requires/supports that a node, which has somehow fallen behind (e.g. has been restored from old backup),

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.

Suggested change
//! - `DataLossProtect` - requires/supports that a node, which has somehow fallen behind (e.g. has been restored from old backup),
//! - `DataLossProtect` - requires/supports that a node which has somehow fallen behind, e.g., has been restored from an old backup,

Comment threadlightning/src/ln/features.rs Outdated
//! - `ShutdownAnySegwit` - requires/supports that future segwit versions are allowed in `shutdown`
//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-initiation-shutdown) for more information).
//! - `ChannelType` - node supports the channel_type field in open/accept
//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-initiation-shutdown) for more information).

@tnulltnullJun 10, 2022

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.

I think this link to BOLT 2 and the following two should not link to the closing-initiation-shutdown subsection.

Comment threadlightning/src/ln/features.rs Outdated
//! - `SCIDPrivacy` - supply channel aliases for routing
//! (see [BOLT-2](https://github.com/lightning/bolts/blob/master/02-peer-protocol.md#closing-initiation-shutdown) for more information).
//! - `Keysend` - send funds to a node without an invoice
//! (see [BOLT-11](https://github.com/lightning/bolts/blob/master/11-payment-encoding.md) for more information).

@tnulltnullJun 10, 2022

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.

Pointing users towards this URL may be misleading since BOLT 11 does AFAIK not contain any further information on keysend payments?

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 think you are right - I will link to the Keysend feature assignment proposal.

@TheBlueMatt
TheBlueMatt merged commit d6feb1c into lightningdevkit:mainJun 13, 2022
@TheBlueMattTheBlueMatt mentioned this pull request Jun 29, 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.

Document better optional features (data_loss_protect, upfront_shutdown_script,...)

4 participants

@mattfaltyn@codecov-commenter@tnull@TheBlueMatt