]> git.bitcoin.ninja Git - ldk-java/blob - src/main/java/org/ldk/structs/OfferWithDerivedMetadataBuilder.java
[Java] Update auto-generated bindings to LDK 0.0.123
[ldk-java] / src / main / java / org / ldk / structs / OfferWithDerivedMetadataBuilder.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
12  * Builds an [`Offer`] for the \"offer to be paid\" flow.
13  * 
14  * See [module-level documentation] for usage.
15  * 
16  * [module-level documentation]: self
17  */
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 {
23                 super.finalize();
24                 if (ptr != 0) { bindings.OfferWithDerivedMetadataBuilder_free(ptr); }
25         }
26
27         long clone_ptr() {
28                 long ret = bindings.OfferWithDerivedMetadataBuilder_clone_ptr(this.ptr);
29                 Reference.reachabilityFence(this);
30                 return ret;
31         }
32
33         /**
34          * Creates a copy of the OfferWithDerivedMetadataBuilder
35          */
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); };
42                 return ret_hu_conv;
43         }
44
45         /**
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.
50          * 
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
53          * [`ExpandedKey`].
54          * 
55          * [`InvoiceRequest::verify`]: crate::offers::invoice_request::InvoiceRequest::verify
56          * [`ExpandedKey`]: crate::ln::inbound_payment::ExpandedKey
57          */
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); };
68                 return ret_hu_conv;
69         }
70
71         /**
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.
74          * 
75          * See [`Offer::chains`] on how this relates to the payment currency.
76          * 
77          * Successive calls to this method will add another chain hash.
78          */
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); };
84         }
85
86         /**
87          * Sets the [`Offer::amount`] as an [`Amount::Bitcoin`].
88          * 
89          * Successive calls to this method will override the previous setting.
90          */
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); };
96         }
97
98         /**
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`].
101          * 
102          * Successive calls to this method will override the previous setting.
103          */
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); };
109         }
110
111         /**
112          * Sets the [`Offer::description`].
113          * 
114          * Successive calls to this method will override the previous setting.
115          */
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); };
121         }
122
123         /**
124          * Sets the [`Offer::issuer`].
125          * 
126          * Successive calls to this method will override the previous setting.
127          */
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); };
133         }
134
135         /**
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.
138          * 
139          * Successive calls to this method will add another blinded path. Caller is responsible for not
140          * adding duplicate paths.
141          */
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); };
148         }
149
150         /**
151          * Sets the quantity of items for [`Offer::supported_quantity`]. If not called, defaults to
152          * [`Quantity::One`].
153          * 
154          * Successive calls to this method will override the previous setting.
155          */
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); };
162         }
163
164         /**
165          * Builds an [`Offer`] from the builder's settings.
166          */
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); };
173                 return ret_hu_conv;
174         }
175
176 }