+/// A function for signing an [`UnsignedInvoiceRequest`].
+pub trait SignInvoiceRequestFn {
+ /// Error type returned by the function.
+ type Error;
+
+ /// Signs a [`TaggedHash`] computed over the merkle root of `message`'s TLV stream.
+ fn sign_invoice_request(&self, message: &UnsignedInvoiceRequest) -> Result<Signature, Self::Error>;
+}
+
+impl<F, E> SignInvoiceRequestFn for F
+where
+ F: Fn(&UnsignedInvoiceRequest) -> Result<Signature, E>,
+{
+ type Error = E;
+
+ fn sign_invoice_request(&self, message: &UnsignedInvoiceRequest) -> Result<Signature, E> {
+ self(message)
+ }
+}
+
+impl<F, E> SignFn<UnsignedInvoiceRequest> for F
+where
+ F: SignInvoiceRequestFn<Error = E>,
+{
+ type Error = E;
+
+ fn sign(&self, message: &UnsignedInvoiceRequest) -> Result<Signature, Self::Error> {
+ self.sign_invoice_request(message)
+ }
+}
+