use bech32::u5;
use bitcoin_hashes::Hash;
use bitcoin_hashes::sha256;
+use lightning::ln::features::InvoiceFeatures;
#[cfg(any(doc, test))]
use lightning::routing::network_graph::RoutingFees;
use lightning::routing::router::RouteHintHop;
Fallback(Fallback),
Route(RouteHint),
PaymentSecret(PaymentSecret),
+ Features(InvoiceFeatures),
}
/// SHA-256 hash
pub const TAG_FALLBACK: u8 = 9;
pub const TAG_ROUTE: u8 = 3;
pub const TAG_PAYMENT_SECRET: u8 = 16;
+ pub const TAG_FEATURES: u8 = 5;
}
impl InvoiceBuilder<tb::False, tb::False, tb::False> {
}
self
}
+
+ /// Adds a features field which indicates the set of supported protocol extensions which the
+ /// origin node supports.
+ pub fn features(mut self, features: InvoiceFeatures) -> Self {
+ self.tagged_fields.push(TaggedField::Features(features));
+ self
+ }
}
impl<D: tb::Bool, H: tb::Bool> InvoiceBuilder<D, H, tb::True> {
find_extract!(self.known_tagged_fields(), TaggedField::PaymentSecret(ref x), x)
}
+ pub fn features(&self) -> Option<&InvoiceFeatures> {
+ find_extract!(self.known_tagged_fields(), TaggedField::Features(ref x), x)
+ }
+
pub fn fallbacks(&self) -> Vec<&Fallback> {
self.known_tagged_fields().filter_map(|tf| match tf {
&TaggedField::Fallback(ref f) => Some(f),
self.signed_invoice.payee_pub_key().map(|x| &x.0)
}
- /// Get the payment secret if one was included in the invoice
- pub fn payment_secret(&self) -> Option<&PaymentSecret> {
- self.signed_invoice.payment_secret()
- }
+ /// Get the payment secret if one was included in the invoice
+ pub fn payment_secret(&self) -> Option<&PaymentSecret> {
+ self.signed_invoice.payment_secret()
+ }
+
+ /// Get the invoice features if they were included in the invoice
+ pub fn features(&self) -> Option<&InvoiceFeatures> {
+ self.signed_invoice.features()
+ }
/// Recover the payee's public key (only to be used if none was included in the invoice)
pub fn recover_payee_pub_key(&self) -> PublicKey {
TaggedField::Fallback(_) => constants::TAG_FALLBACK,
TaggedField::Route(_) => constants::TAG_ROUTE,
TaggedField::PaymentSecret(_) => constants::TAG_PAYMENT_SECRET,
+ TaggedField::Features(_) => constants::TAG_FEATURES,
};
u5::try_from_u8(tag).expect("all tags defined are <32")