[Java] Update auto-generated bindings to LDK 0.0.123
[ldk-java] / src / main / java / org / ldk / structs / InvoiceRequestWithDerivedPayerIdBuilder.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 [`InvoiceRequest`] from 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 InvoiceRequestWithDerivedPayerIdBuilder extends CommonBase {
20         InvoiceRequestWithDerivedPayerIdBuilder(Object _dummy, long ptr) { super(ptr); }
21         @Override @SuppressWarnings("deprecation")
22         protected void finalize() throws Throwable {
23                 super.finalize();
24                 if (ptr != 0) { bindings.InvoiceRequestWithDerivedPayerIdBuilder_free(ptr); }
25         }
26
27         /**
28          * Builds a signed [`InvoiceRequest`] after checking for valid semantics.
29          */
30         public Result_InvoiceRequestBolt12SemanticErrorZ build_and_sign() {
31                 long ret = bindings.InvoiceRequestWithDerivedPayerIdBuilder_build_and_sign(this.ptr);
32                 Reference.reachabilityFence(this);
33                 if (ret >= 0 && ret <= 4096) { return null; }
34                 Result_InvoiceRequestBolt12SemanticErrorZ ret_hu_conv = Result_InvoiceRequestBolt12SemanticErrorZ.constr_from_ptr(ret);
35                 if (this != null) { this.ptrs_to.add(this); };
36                 // Due to rust's strict-ownership memory model, in some cases we need to "move"
37                 // an object to pass exclusive ownership to the function being called.
38                 // In most cases, we avoid this being visible in GC'd languages by cloning the object
39                 // at the FFI layer, creating a new object which Rust can claim ownership of
40                 // However, in some cases (eg here), there is no way to clone an object, and thus
41                 // we actually have to pass full ownership to Rust.
42                 // Thus, after this call, this is reset to null and is now a dummy object.
43                 this.ptr = 0;;
44                 return ret_hu_conv;
45         }
46
47         /**
48          * Sets the [`InvoiceRequest::chain`] of the given [`Network`] for paying an invoice. If not
49          * called, [`Network::Bitcoin`] is assumed. Errors if the chain for `network` is not supported
50          * by the offer.
51          * 
52          * Successive calls to this method will override the previous setting.
53          */
54         public Result_NoneBolt12SemanticErrorZ chain(org.ldk.enums.Network network) {
55                 long ret = bindings.InvoiceRequestWithDerivedPayerIdBuilder_chain(this.ptr, network);
56                 Reference.reachabilityFence(this);
57                 Reference.reachabilityFence(network);
58                 if (ret >= 0 && ret <= 4096) { return null; }
59                 Result_NoneBolt12SemanticErrorZ ret_hu_conv = Result_NoneBolt12SemanticErrorZ.constr_from_ptr(ret);
60                 if (this != null) { this.ptrs_to.add(this); };
61                 // Due to rust's strict-ownership memory model, in some cases we need to "move"
62                 // an object to pass exclusive ownership to the function being called.
63                 // In most cases, we avoid this being visible in GC'd languages by cloning the object
64                 // at the FFI layer, creating a new object which Rust can claim ownership of
65                 // However, in some cases (eg here), there is no way to clone an object, and thus
66                 // we actually have to pass full ownership to Rust.
67                 // Thus, after this call, this is reset to null and is now a dummy object.
68                 this.ptr = 0;;
69                 return ret_hu_conv;
70         }
71
72         /**
73          * Sets the [`InvoiceRequest::amount_msats`] for paying an invoice. Errors if `amount_msats` is
74          * not at least the expected invoice amount (i.e., [`Offer::amount`] times [`quantity`]).
75          * 
76          * Successive calls to this method will override the previous setting.
77          * 
78          * [`quantity`]: Self::quantity
79          */
80         public Result_NoneBolt12SemanticErrorZ amount_msats(long amount_msats) {
81                 long ret = bindings.InvoiceRequestWithDerivedPayerIdBuilder_amount_msats(this.ptr, amount_msats);
82                 Reference.reachabilityFence(this);
83                 Reference.reachabilityFence(amount_msats);
84                 if (ret >= 0 && ret <= 4096) { return null; }
85                 Result_NoneBolt12SemanticErrorZ ret_hu_conv = Result_NoneBolt12SemanticErrorZ.constr_from_ptr(ret);
86                 if (this != null) { this.ptrs_to.add(this); };
87                 // Due to rust's strict-ownership memory model, in some cases we need to "move"
88                 // an object to pass exclusive ownership to the function being called.
89                 // In most cases, we avoid this being visible in GC'd languages by cloning the object
90                 // at the FFI layer, creating a new object which Rust can claim ownership of
91                 // However, in some cases (eg here), there is no way to clone an object, and thus
92                 // we actually have to pass full ownership to Rust.
93                 // Thus, after this call, this is reset to null and is now a dummy object.
94                 this.ptr = 0;;
95                 return ret_hu_conv;
96         }
97
98         /**
99          * Sets [`InvoiceRequest::quantity`] of items. If not set, `1` is assumed. Errors if `quantity`
100          * does not conform to [`Offer::is_valid_quantity`].
101          * 
102          * Successive calls to this method will override the previous setting.
103          */
104         public Result_NoneBolt12SemanticErrorZ quantity(long quantity) {
105                 long ret = bindings.InvoiceRequestWithDerivedPayerIdBuilder_quantity(this.ptr, quantity);
106                 Reference.reachabilityFence(this);
107                 Reference.reachabilityFence(quantity);
108                 if (ret >= 0 && ret <= 4096) { return null; }
109                 Result_NoneBolt12SemanticErrorZ ret_hu_conv = Result_NoneBolt12SemanticErrorZ.constr_from_ptr(ret);
110                 if (this != null) { this.ptrs_to.add(this); };
111                 // Due to rust's strict-ownership memory model, in some cases we need to "move"
112                 // an object to pass exclusive ownership to the function being called.
113                 // In most cases, we avoid this being visible in GC'd languages by cloning the object
114                 // at the FFI layer, creating a new object which Rust can claim ownership of
115                 // However, in some cases (eg here), there is no way to clone an object, and thus
116                 // we actually have to pass full ownership to Rust.
117                 // Thus, after this call, this is reset to null and is now a dummy object.
118                 this.ptr = 0;;
119                 return ret_hu_conv;
120         }
121
122         /**
123          * Sets the [`InvoiceRequest::payer_note`].
124          * 
125          * Successive calls to this method will override the previous setting.
126          */
127         public void payer_note(java.lang.String payer_note) {
128                 bindings.InvoiceRequestWithDerivedPayerIdBuilder_payer_note(this.ptr, payer_note);
129                 Reference.reachabilityFence(this);
130                 Reference.reachabilityFence(payer_note);
131                 if (this != null) { this.ptrs_to.add(this); };
132                 // Due to rust's strict-ownership memory model, in some cases we need to "move"
133                 // an object to pass exclusive ownership to the function being called.
134                 // In most cases, we avoid this being visible in GC'd languages by cloning the object
135                 // at the FFI layer, creating a new object which Rust can claim ownership of
136                 // However, in some cases (eg here), there is no way to clone an object, and thus
137                 // we actually have to pass full ownership to Rust.
138                 // Thus, after this call, this is reset to null and is now a dummy object.
139                 this.ptr = 0;;
140         }
141
142 }