1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * Builds an [`Offer`] for the \"offer to be paid\" flow.
14 * See [module-level documentation] for usage.
16 * [module-level documentation]: self
18 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
19 public class OfferWithDerivedMetadataBuilder extends CommonBase {
20 OfferWithDerivedMetadataBuilder(Object _dummy, long ptr) { super(ptr); }
21 @Override @SuppressWarnings("deprecation")
22 protected void finalize() throws Throwable {
24 if (ptr != 0) { bindings.OfferWithDerivedMetadataBuilder_free(ptr); }
28 long ret = bindings.OfferWithDerivedMetadataBuilder_clone_ptr(this.ptr);
29 Reference.reachabilityFence(this);
34 * Creates a copy of the OfferWithDerivedMetadataBuilder
36 public OfferWithDerivedMetadataBuilder clone() {
37 long ret = bindings.OfferWithDerivedMetadataBuilder_clone(this.ptr);
38 Reference.reachabilityFence(this);
39 if (ret >= 0 && ret <= 4096) { return null; }
40 org.ldk.structs.OfferWithDerivedMetadataBuilder ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OfferWithDerivedMetadataBuilder(null, ret); }
41 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
46 * Similar to [`OfferBuilder::new`] except, if [`OfferBuilder::path`] is called, the signing
47 * pubkey is derived from the given [`ExpandedKey`] and [`EntropySource`]. This provides
48 * recipient privacy by using a different signing pubkey for each offer. Otherwise, the
49 * provided `node_id` is used for the signing pubkey.
51 * Also, sets the metadata when [`OfferBuilder::build`] is called such that it can be used by
52 * [`InvoiceRequest::verify`] to determine if the request was produced for the offer given an
55 * [`InvoiceRequest::verify`]: crate::offers::invoice_request::InvoiceRequest::verify
56 * [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey
58 public static OfferWithDerivedMetadataBuilder deriving_signing_pubkey(byte[] node_id, org.ldk.structs.ExpandedKey expanded_key, org.ldk.structs.EntropySource entropy_source) {
59 long ret = bindings.OfferWithDerivedMetadataBuilder_deriving_signing_pubkey(InternalUtils.check_arr_len(node_id, 33), expanded_key.ptr, entropy_source.ptr);
60 Reference.reachabilityFence(node_id);
61 Reference.reachabilityFence(expanded_key);
62 Reference.reachabilityFence(entropy_source);
63 if (ret >= 0 && ret <= 4096) { return null; }
64 org.ldk.structs.OfferWithDerivedMetadataBuilder ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OfferWithDerivedMetadataBuilder(null, ret); }
65 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
66 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(expanded_key); };
67 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(entropy_source); };
72 * Adds the chain hash of the given [`Network`] to [`Offer::chains`]. If not called,
73 * the chain hash of [`Network::Bitcoin`] is assumed to be the only one supported.
75 * See [`Offer::chains`] on how this relates to the payment currency.
77 * Successive calls to this method will add another chain hash.
79 public void chain(org.ldk.enums.Network network) {
80 bindings.OfferWithDerivedMetadataBuilder_chain(this.ptr, network);
81 Reference.reachabilityFence(this);
82 Reference.reachabilityFence(network);
83 if (this != null) { this.ptrs_to.add(this); };
87 * Sets the [`Offer::amount`] as an [`Amount::Bitcoin`].
89 * Successive calls to this method will override the previous setting.
91 public void amount_msats(long amount_msats) {
92 bindings.OfferWithDerivedMetadataBuilder_amount_msats(this.ptr, amount_msats);
93 Reference.reachabilityFence(this);
94 Reference.reachabilityFence(amount_msats);
95 if (this != null) { this.ptrs_to.add(this); };
99 * Sets the [`Offer::absolute_expiry`] as seconds since the Unix epoch. Any expiry that has
100 * already passed is valid and can be checked for using [`Offer::is_expired`].
102 * Successive calls to this method will override the previous setting.
104 public void absolute_expiry(long absolute_expiry) {
105 bindings.OfferWithDerivedMetadataBuilder_absolute_expiry(this.ptr, absolute_expiry);
106 Reference.reachabilityFence(this);
107 Reference.reachabilityFence(absolute_expiry);
108 if (this != null) { this.ptrs_to.add(this); };
112 * Sets the [`Offer::description`].
114 * Successive calls to this method will override the previous setting.
116 public void description(java.lang.String description) {
117 bindings.OfferWithDerivedMetadataBuilder_description(this.ptr, description);
118 Reference.reachabilityFence(this);
119 Reference.reachabilityFence(description);
120 if (this != null) { this.ptrs_to.add(this); };
124 * Sets the [`Offer::issuer`].
126 * Successive calls to this method will override the previous setting.
128 public void issuer(java.lang.String issuer) {
129 bindings.OfferWithDerivedMetadataBuilder_issuer(this.ptr, issuer);
130 Reference.reachabilityFence(this);
131 Reference.reachabilityFence(issuer);
132 if (this != null) { this.ptrs_to.add(this); };
136 * Adds a blinded path to [`Offer::paths`]. Must include at least one path if only connected by
137 * private channels or if [`Offer::signing_pubkey`] is not a public node id.
139 * Successive calls to this method will add another blinded path. Caller is responsible for not
140 * adding duplicate paths.
142 public void path(org.ldk.structs.BlindedPath path) {
143 bindings.OfferWithDerivedMetadataBuilder_path(this.ptr, path.ptr);
144 Reference.reachabilityFence(this);
145 Reference.reachabilityFence(path);
146 if (this != null) { this.ptrs_to.add(path); };
147 if (this != null) { this.ptrs_to.add(this); };
151 * Sets the quantity of items for [`Offer::supported_quantity`]. If not called, defaults to
154 * Successive calls to this method will override the previous setting.
156 public void supported_quantity(org.ldk.structs.Quantity quantity) {
157 bindings.OfferWithDerivedMetadataBuilder_supported_quantity(this.ptr, quantity.ptr);
158 Reference.reachabilityFence(this);
159 Reference.reachabilityFence(quantity);
160 if (this != null) { this.ptrs_to.add(quantity); };
161 if (this != null) { this.ptrs_to.add(this); };
165 * Builds an [`Offer`] from the builder's settings.
167 public Result_OfferBolt12SemanticErrorZ build() {
168 long ret = bindings.OfferWithDerivedMetadataBuilder_build(this.ptr);
169 Reference.reachabilityFence(this);
170 if (ret >= 0 && ret <= 4096) { return null; }
171 Result_OfferBolt12SemanticErrorZ ret_hu_conv = Result_OfferBolt12SemanticErrorZ.constr_from_ptr(ret);
172 if (this != null) { this.ptrs_to.add(this); };