pub struct SignedRawInvoice { /* private fields */ }
Expand description

Represents a signed RawInvoice with cached hash. The signature is not checked and may be invalid.

Invariants

The hash has to be either from the deserialized invoice or from the serialized raw_invoice.

Implementations§

source§

impl SignedRawInvoice

source

pub fn into_parts(self) -> (RawInvoice, [u8; 32], InvoiceSignature)

Disassembles the SignedRawInvoice into its three parts:

  1. raw invoice
  2. hash of the raw invoice
  3. signature
source

pub fn raw_invoice(&self) -> &RawInvoice

The RawInvoice which was signed.

source

pub fn signable_hash(&self) -> &[u8; 32]

The hash of the RawInvoice that was signed.

source

pub fn signature(&self) -> &InvoiceSignature

InvoiceSignature for the invoice.

source

pub fn recover_payee_pub_key(&self) -> Result<PayeePubKey, Error>

Recovers the public key used for signing the invoice from the recoverable signature.

source

pub fn check_signature(&self) -> bool

Checks if the signature is valid for the included payee public key or if none exists if it’s valid for the recovered signature (which should always be true?).

Methods from Deref<Target = RawInvoice>§

source

pub fn signable_hash(&self) -> [u8; 32]

Calculate the hash of the encoded RawInvoice which should be signed.

source

pub fn known_tagged_fields( &self ) -> FilterMap<Iter<'_, RawTaggedField>, fn(_: &RawTaggedField) -> Option<&TaggedField>>

Returns an iterator over all tagged fields with known semantics.

(C-not exported) As there is not yet a manual mapping for a FilterMap

source

pub fn payment_hash(&self) -> Option<&Sha256>

source

pub fn description(&self) -> Option<&Description>

source

pub fn payee_pub_key(&self) -> Option<&PayeePubKey>

source

pub fn description_hash(&self) -> Option<&Sha256>

source

pub fn expiry_time(&self) -> Option<&ExpiryTime>

source

pub fn min_final_cltv_expiry_delta(&self) -> Option<&MinFinalCltvExpiryDelta>

source

pub fn payment_secret(&self) -> Option<&PaymentSecret>

source

pub fn features(&self) -> Option<&InvoiceFeatures>

source

pub fn fallbacks(&self) -> Vec<&Fallback>

(C-not exported) as we don’t support Vec<&NonOpaqueType>

source

pub fn private_routes(&self) -> Vec<&PrivateRoute>

source

pub fn amount_pico_btc(&self) -> Option<u64>

source

pub fn currency(&self) -> Currency

Trait Implementations§

source§

impl Clone for SignedRawInvoice

source§

fn clone(&self) -> SignedRawInvoice

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for SignedRawInvoice

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Deref for SignedRawInvoice

§

type Target = RawInvoice

The resulting type after dereferencing.
source§

fn deref(&self) -> &RawInvoice

Dereferences the value.
source§

impl Display for SignedRawInvoice

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl FromStr for SignedRawInvoice

use lightning_invoice::*;

let invoice = "lnbc100p1psj9jhxdqud3jxktt5w46x7unfv9kz6mn0v3jsnp4q0d3p2sfluzdx45tqcs\
h2pu5qc7lgq0xs578ngs6s0s68ua4h7cvspp5q6rmq35js88zp5dvwrv9m459tnk2zunwj5jalqtyxqulh0l\
5gflssp5nf55ny5gcrfl30xuhzj3nphgj27rstekmr9fw3ny5989s300gyus9qyysgqcqpcrzjqw2sxwe993\
h5pcm4dxzpvttgza8zhkqxpgffcrf5v25nwpr3cmfg7z54kuqq8rgqqqqqqqq2qqqqq9qq9qrzjqd0ylaqcl\
j9424x9m8h2vcukcgnm6s56xfgu3j78zyqzhgs4hlpzvznlugqq9vsqqqqqqqlgqqqqqeqq9qrzjqwldmj9d\
ha74df76zhx6l9we0vjdquygcdt3kssupehe64g6yyp5yz5rhuqqwccqqyqqqqlgqqqqjcqq9qrzjqf9e58a\
guqr0rcun0ajlvmzq3ek63cw2w282gv3z5uupmuwvgjtq2z55qsqqg6qqqyqqqrtnqqqzq3cqygrzjqvphms\
ywntrrhqjcraumvc4y6r8v4z5v593trte429v4hredj7ms5z52usqq9ngqqqqqqqlgqqqqqqgq9qrzjq2v0v\
p62g49p7569ev48cmulecsxe59lvaw3wlxm7r982zxa9zzj7z5l0cqqxusqqyqqqqlgqqqqqzsqygarl9fh3\
8s0gyuxjjgux34w75dnc6xp2l35j7es3jd4ugt3lu0xzre26yg5m7ke54n2d5sym4xcmxtl8238xxvw5h5h5\
j5r6drg6k6zcqj0fcwg";

let parsed_1 = invoice.parse::<Invoice>();

let parsed_2 = match invoice.parse::<SignedRawInvoice>() {
	Ok(signed) => match Invoice::from_signed(signed) {
		Ok(invoice) => Ok(invoice),
		Err(e) => Err(ParseOrSemanticError::SemanticError(e)),
	},
	Err(e) => Err(ParseOrSemanticError::ParseError(e)),
};

assert!(parsed_1.is_ok());
assert_eq!(parsed_1, parsed_2);
§

type Err = ParseError

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl Hash for SignedRawInvoice

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq<SignedRawInvoice> for SignedRawInvoice

source§

fn eq(&self, other: &SignedRawInvoice) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for SignedRawInvoice

source§

impl StructuralEq for SignedRawInvoice

source§

impl StructuralPartialEq for SignedRawInvoice

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.