Allow building Invoice from Bolt11InvoiceDescriptionRef
What changed, and why it matters
This commit adds a small convenience method to make it easier to copy invoice descriptions from one Lightning invoice to another. It is a routine developer-experience improvement with no apparent security relevance.
No security action required; treat as normal code-review/functional change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch introduces InvoiceBuilder::invoice_description_ref(), which accepts a Bolt11InvoiceDescriptionRef<'_> and delegates to the existing description() or description_hash() builders. It mirrors the pre-existing invoice_description() method but works with the borrowed/ref variant of the description type. No logic changes to validation, cryptography, or state handling.
Changed components
lightning-invoice/src/lib.rsInvoiceBuilder APIInspect captured patch +10 / −0
diff --git a/lightning-invoice/src/lib.rs b/lightning-invoice/src/lib.rs
index 9e330a9..fda7c10 100644
--- a/lightning-invoice/src/lib.rs
+++ b/lightning-invoice/src/lib.rs
@@ -777,6 +777,16 @@ impl<H: tb::Bool, T: tb::Bool, C: tb::Bool, S: tb::Bool, M: tb::Bool>
Bolt11InvoiceDescription::Hash(hash) => self.description_hash(hash.0),
}
}
+
+ /// Set the description or description hash. This function is only available if no description (hash) was set.
+ pub fn invoice_description_ref(
+ self, description_ref: Bolt11InvoiceDescriptionRef<'_>,
+ ) -> InvoiceBuilder<tb::True, H, T, C, S, M> {
+ match description_ref {
+ Bolt11InvoiceDescriptionRef::Direct(desc) => self.description(desc.clone().0 .0),
+ Bolt11InvoiceDescriptionRef::Hash(hash) => self.description_hash(hash.0),
+ }
+ }
}
impl<D: tb::Bool, T: tb::Bool, C: tb::Bool, S: tb::Bool, M: tb::Bool>
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.