+impl<'a> InvoiceBuilder<'a, DerivedSigningPubkey> {
+ invoice_derived_signing_pubkey_builder_methods!(self, Self);
+}
+
+impl<'a, S: SigningPubkeyStrategy> InvoiceBuilder<'a, S> {
+ invoice_builder_methods!(self, Self, Self, self, S, mut);
+ invoice_builder_methods_common!(self, Self, self.invoice.fields_mut(), Self, self, S, Bolt12Invoice, mut);
+}
+
+#[cfg(all(c_bindings, not(test)))]
+impl<'a> InvoiceWithExplicitSigningPubkeyBuilder<'a> {
+ invoice_explicit_signing_pubkey_builder_methods!(self, &mut Self);
+ invoice_builder_methods!(self, &mut Self, (), (), ExplicitSigningPubkey);
+ invoice_builder_methods_common!(self, &mut Self, self.invoice.fields_mut(), (), (), ExplicitSigningPubkey, Bolt12Invoice);
+}
+
+#[cfg(all(c_bindings, test))]
+impl<'a> InvoiceWithExplicitSigningPubkeyBuilder<'a> {
+ invoice_explicit_signing_pubkey_builder_methods!(self, &mut Self);
+ invoice_builder_methods!(self, &mut Self, &mut Self, self, ExplicitSigningPubkey);
+ invoice_builder_methods_common!(self, &mut Self, self.invoice.fields_mut(), &mut Self, self, ExplicitSigningPubkey, Bolt12Invoice);
+}
+
+#[cfg(all(c_bindings, not(test)))]
+impl<'a> InvoiceWithDerivedSigningPubkeyBuilder<'a> {
+ invoice_derived_signing_pubkey_builder_methods!(self, &mut Self);
+ invoice_builder_methods!(self, &mut Self, (), (), DerivedSigningPubkey);
+ invoice_builder_methods_common!(self, &mut Self, self.invoice.fields_mut(), (), (), DerivedSigningPubkey, Bolt12Invoice);
+}
+
+#[cfg(all(c_bindings, test))]
+impl<'a> InvoiceWithDerivedSigningPubkeyBuilder<'a> {
+ invoice_derived_signing_pubkey_builder_methods!(self, &mut Self);
+ invoice_builder_methods!(self, &mut Self, &mut Self, self, DerivedSigningPubkey);
+ invoice_builder_methods_common!(self, &mut Self, self.invoice.fields_mut(), &mut Self, self, DerivedSigningPubkey, Bolt12Invoice);
+}
+
+#[cfg(c_bindings)]
+impl<'a> From<InvoiceWithExplicitSigningPubkeyBuilder<'a>>
+for InvoiceBuilder<'a, ExplicitSigningPubkey> {
+ fn from(builder: InvoiceWithExplicitSigningPubkeyBuilder<'a>) -> Self {
+ let InvoiceWithExplicitSigningPubkeyBuilder {
+ invreq_bytes, invoice, signing_pubkey_strategy,
+ } = builder;
+
+ Self {
+ invreq_bytes, invoice, signing_pubkey_strategy,
+ }
+ }
+}
+
+#[cfg(c_bindings)]
+impl<'a> From<InvoiceWithDerivedSigningPubkeyBuilder<'a>>
+for InvoiceBuilder<'a, DerivedSigningPubkey> {
+ fn from(builder: InvoiceWithDerivedSigningPubkeyBuilder<'a>) -> Self {
+ let InvoiceWithDerivedSigningPubkeyBuilder {
+ invreq_bytes, invoice, signing_pubkey_strategy,
+ } = builder;
+
+ Self {
+ invreq_bytes, invoice, signing_pubkey_strategy,
+ }
+ }
+}
+
+/// A semantically valid [`Bolt12Invoice`] that hasn't been signed.
+///
+/// # Serialization
+///
+/// This is serialized as a TLV stream, which includes TLV records from the originating message. As
+/// such, it may include unknown, odd TLV records.
+#[derive(Clone)]
+pub struct UnsignedBolt12Invoice {
+ bytes: Vec<u8>,
+ contents: InvoiceContents,
+ tagged_hash: TaggedHash,
+}
+
+/// A function for signing an [`UnsignedBolt12Invoice`].
+pub trait SignBolt12InvoiceFn {
+ /// Signs a [`TaggedHash`] computed over the merkle root of `message`'s TLV stream.
+ fn sign_invoice(&self, message: &UnsignedBolt12Invoice) -> Result<Signature, ()>;
+}
+
+impl<F> SignBolt12InvoiceFn for F
+where
+ F: Fn(&UnsignedBolt12Invoice) -> Result<Signature, ()>,
+{
+ fn sign_invoice(&self, message: &UnsignedBolt12Invoice) -> Result<Signature, ()> {
+ self(message)
+ }