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 OfferWithExplicitMetadataBuilder extends CommonBase {
20 OfferWithExplicitMetadataBuilder(Object _dummy, long ptr) { super(ptr); }
21 @Override @SuppressWarnings("deprecation")
22 protected void finalize() throws Throwable {
24 if (ptr != 0) { bindings.OfferWithExplicitMetadataBuilder_free(ptr); }
28 long ret = bindings.OfferWithExplicitMetadataBuilder_clone_ptr(this.ptr);
29 Reference.reachabilityFence(this);
34 * Creates a copy of the OfferWithExplicitMetadataBuilder
36 public OfferWithExplicitMetadataBuilder clone() {
37 long ret = bindings.OfferWithExplicitMetadataBuilder_clone(this.ptr);
38 Reference.reachabilityFence(this);
39 if (ret >= 0 && ret <= 4096) { return null; }
40 org.ldk.structs.OfferWithExplicitMetadataBuilder ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OfferWithExplicitMetadataBuilder(null, ret); }
41 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
46 * Creates a new builder for an offer using the [`Offer::signing_pubkey`] for signing invoices.
47 * The associated secret key must be remembered while the offer is valid.
49 * Use a different pubkey per offer to avoid correlating offers.
53 * If constructing an [`Offer`] for use with a [`ChannelManager`], use
54 * [`ChannelManager::create_offer_builder`] instead of [`OfferBuilder::new`].
56 * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
57 * [`ChannelManager::create_offer_builder`]: crate::ln::channelmanager::ChannelManager::create_offer_builder
59 public static OfferWithExplicitMetadataBuilder of(byte[] signing_pubkey) {
60 long ret = bindings.OfferWithExplicitMetadataBuilder_new(InternalUtils.check_arr_len(signing_pubkey, 33));
61 Reference.reachabilityFence(signing_pubkey);
62 if (ret >= 0 && ret <= 4096) { return null; }
63 org.ldk.structs.OfferWithExplicitMetadataBuilder ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.OfferWithExplicitMetadataBuilder(null, ret); }
64 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
69 * Sets the [`Offer::metadata`] to the given bytes.
71 * Successive calls to this method will override the previous setting.
73 public Result_NoneBolt12SemanticErrorZ metadata(byte[] metadata) {
74 long ret = bindings.OfferWithExplicitMetadataBuilder_metadata(this.ptr, metadata);
75 Reference.reachabilityFence(this);
76 Reference.reachabilityFence(metadata);
77 if (ret >= 0 && ret <= 4096) { return null; }
78 Result_NoneBolt12SemanticErrorZ ret_hu_conv = Result_NoneBolt12SemanticErrorZ.constr_from_ptr(ret);
79 if (this != null) { this.ptrs_to.add(this); };
84 * Adds the chain hash of the given [`Network`] to [`Offer::chains`]. If not called,
85 * the chain hash of [`Network::Bitcoin`] is assumed to be the only one supported.
87 * See [`Offer::chains`] on how this relates to the payment currency.
89 * Successive calls to this method will add another chain hash.
91 public void chain(org.ldk.enums.Network network) {
92 bindings.OfferWithExplicitMetadataBuilder_chain(this.ptr, network);
93 Reference.reachabilityFence(this);
94 Reference.reachabilityFence(network);
95 if (this != null) { this.ptrs_to.add(this); };
99 * Sets the [`Offer::amount`] as an [`Amount::Bitcoin`].
101 * Successive calls to this method will override the previous setting.
103 public void amount_msats(long amount_msats) {
104 bindings.OfferWithExplicitMetadataBuilder_amount_msats(this.ptr, amount_msats);
105 Reference.reachabilityFence(this);
106 Reference.reachabilityFence(amount_msats);
107 if (this != null) { this.ptrs_to.add(this); };
111 * Sets the [`Offer::absolute_expiry`] as seconds since the Unix epoch. Any expiry that has
112 * already passed is valid and can be checked for using [`Offer::is_expired`].
114 * Successive calls to this method will override the previous setting.
116 public void absolute_expiry(long absolute_expiry) {
117 bindings.OfferWithExplicitMetadataBuilder_absolute_expiry(this.ptr, absolute_expiry);
118 Reference.reachabilityFence(this);
119 Reference.reachabilityFence(absolute_expiry);
120 if (this != null) { this.ptrs_to.add(this); };
124 * Sets the [`Offer::description`].
126 * Successive calls to this method will override the previous setting.
128 public void description(java.lang.String description) {
129 bindings.OfferWithExplicitMetadataBuilder_description(this.ptr, description);
130 Reference.reachabilityFence(this);
131 Reference.reachabilityFence(description);
132 if (this != null) { this.ptrs_to.add(this); };
136 * Sets the [`Offer::issuer`].
138 * Successive calls to this method will override the previous setting.
140 public void issuer(java.lang.String issuer) {
141 bindings.OfferWithExplicitMetadataBuilder_issuer(this.ptr, issuer);
142 Reference.reachabilityFence(this);
143 Reference.reachabilityFence(issuer);
144 if (this != null) { this.ptrs_to.add(this); };
148 * Adds a blinded path to [`Offer::paths`]. Must include at least one path if only connected by
149 * private channels or if [`Offer::signing_pubkey`] is not a public node id.
151 * Successive calls to this method will add another blinded path. Caller is responsible for not
152 * adding duplicate paths.
154 public void path(org.ldk.structs.BlindedPath path) {
155 bindings.OfferWithExplicitMetadataBuilder_path(this.ptr, path.ptr);
156 Reference.reachabilityFence(this);
157 Reference.reachabilityFence(path);
158 if (this != null) { this.ptrs_to.add(path); };
159 if (this != null) { this.ptrs_to.add(this); };
163 * Sets the quantity of items for [`Offer::supported_quantity`]. If not called, defaults to
166 * Successive calls to this method will override the previous setting.
168 public void supported_quantity(org.ldk.structs.Quantity quantity) {
169 bindings.OfferWithExplicitMetadataBuilder_supported_quantity(this.ptr, quantity.ptr);
170 Reference.reachabilityFence(this);
171 Reference.reachabilityFence(quantity);
172 if (this != null) { this.ptrs_to.add(quantity); };
173 if (this != null) { this.ptrs_to.add(this); };
177 * Builds an [`Offer`] from the builder's settings.
179 public Result_OfferBolt12SemanticErrorZ build() {
180 long ret = bindings.OfferWithExplicitMetadataBuilder_build(this.ptr);
181 Reference.reachabilityFence(this);
182 if (ret >= 0 && ret <= 4096) { return null; }
183 Result_OfferBolt12SemanticErrorZ ret_hu_conv = Result_OfferBolt12SemanticErrorZ.constr_from_ptr(ret);
184 if (this != null) { this.ptrs_to.add(this); };