+ /**
+ * Similar to [`Offer::request_invoice`] except it:
+ * - derives the [`InvoiceRequest::payer_id`] such that a different key can be used for each
+ * request,
+ * - sets [`InvoiceRequest::payer_metadata`] when [`InvoiceRequestBuilder::build`] is called
+ * such that it can be used by [`Bolt12Invoice::verify`] to determine if the invoice was
+ * requested using a base [`ExpandedKey`] from which the payer id was derived, and
+ * - includes the [`PaymentId`] encrypted in [`InvoiceRequest::payer_metadata`] so that it can
+ * be used when sending the payment for the requested invoice.
+ *
+ * Useful to protect the sender's privacy.
+ *
+ * [`InvoiceRequest::payer_id`]: crate::offers::invoice_request::InvoiceRequest::payer_id
+ * [`InvoiceRequest::payer_metadata`]: crate::offers::invoice_request::InvoiceRequest::payer_metadata
+ * [`Bolt12Invoice::verify`]: crate::offers::invoice::Bolt12Invoice::verify
+ * [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey
+ */
+ public request_invoice_deriving_payer_id(expanded_key: ExpandedKey, entropy_source: EntropySource, payment_id: Uint8Array): Result_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ {
+ const ret: bigint = bindings.Offer_request_invoice_deriving_payer_id(this.ptr, CommonBase.get_ptr_of(expanded_key), CommonBase.get_ptr_of(entropy_source), bindings.encodeUint8Array(bindings.check_arr_len(payment_id, 32)));
+ const ret_hu_conv: Result_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ = Result_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ.constr_from_ptr(ret);
+ CommonBase.add_ref_from(this, expanded_key);
+ CommonBase.add_ref_from(this, entropy_source);
+ return ret_hu_conv;
+ }
+
+ /**
+ * Similar to [`Offer::request_invoice_deriving_payer_id`] except uses `payer_id` for the
+ * [`InvoiceRequest::payer_id`] instead of deriving a different key for each request.
+ *
+ * Useful for recurring payments using the same `payer_id` with different invoices.
+ *
+ * [`InvoiceRequest::payer_id`]: crate::offers::invoice_request::InvoiceRequest::payer_id
+ */
+ public request_invoice_deriving_metadata(payer_id: Uint8Array, expanded_key: ExpandedKey, entropy_source: EntropySource, payment_id: Uint8Array): Result_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ {
+ const ret: bigint = bindings.Offer_request_invoice_deriving_metadata(this.ptr, bindings.encodeUint8Array(bindings.check_arr_len(payer_id, 33)), CommonBase.get_ptr_of(expanded_key), CommonBase.get_ptr_of(entropy_source), bindings.encodeUint8Array(bindings.check_arr_len(payment_id, 32)));
+ const ret_hu_conv: Result_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ = Result_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ.constr_from_ptr(ret);
+ CommonBase.add_ref_from(this, expanded_key);
+ CommonBase.add_ref_from(this, entropy_source);
+ return ret_hu_conv;
+ }
+
+ /**
+ * Creates an [`InvoiceRequestBuilder`] for the offer with the given `metadata` and `payer_id`,
+ * which will be reflected in the `Bolt12Invoice` response.
+ *
+ * The `metadata` is useful for including information about the derivation of `payer_id` such
+ * that invoice response handling can be stateless. Also serves as payer-provided entropy while
+ * hashing in the signature calculation.
+ *
+ * This should not leak any information such as by using a simple BIP-32 derivation path.
+ * Otherwise, payments may be correlated.
+ *
+ * Errors if the offer contains unknown required features.
+ *
+ * [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
+ */
+ public request_invoice(metadata: Uint8Array, payer_id: Uint8Array): Result_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ {
+ const ret: bigint = bindings.Offer_request_invoice(this.ptr, bindings.encodeUint8Array(metadata), bindings.encodeUint8Array(bindings.check_arr_len(payer_id, 33)));
+ const ret_hu_conv: Result_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ = Result_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ.constr_from_ptr(ret);
+ return ret_hu_conv;
+ }
+
+ /**
+ * Generates a non-cryptographic 64-bit hash of the Offer.
+ */
+ public hash(): bigint {
+ const ret: bigint = bindings.Offer_hash(this.ptr);
+ return ret;
+ }
+