Expose a BOLT 11 Invoice's signable_hash
authorJeffrey Czyz <jkczyz@gmail.com>
Thu, 6 Apr 2023 14:47:45 +0000 (09:47 -0500)
committerJeffrey Czyz <jkczyz@gmail.com>
Fri, 7 Apr 2023 04:15:25 +0000 (23:15 -0500)
Otherwise, an Invoice must first be converted to a SignedRawInvoice to
obtain the hash.

lightning-invoice/src/lib.rs

index 0c73ebc9d7df81f43e13bfeab293306d0923357c..523777455cf074c245384a9e0f996f2fec6933ec 100644 (file)
@@ -1026,6 +1026,11 @@ impl From<PositiveTimestamp> for SystemTime {
 }
 
 impl Invoice {
+       /// The hash of the [`RawInvoice`] that was signed.
+       pub fn signable_hash(&self) -> [u8; 32] {
+               self.signed_invoice.hash
+       }
+
        /// Transform the `Invoice` into it's unchecked version
        pub fn into_signed_raw(self) -> SignedRawInvoice {
                self.signed_invoice